diff --git a/AUTHORS.rst b/AUTHORS.rst index 9a8224dc7d..6fc80f05ce 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -102,6 +102,7 @@ The following organizations or individuals have contributed to ScanCode: - Vibhu Agarwal @Vibhu-Agarwal - Viktor Tiulpin @tiulpin - Vinay Kumar Singh @Vinay0001 +- w3lld1 @w3lld1 - Virag Umathe @viragumathe5 - Yash D. Saraf @yashdsaraf - Yash Nisar @yash-nisar diff --git a/CHANGELOG.rst b/CHANGELOG.rst index d9a5a6b402..1472f7877e 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -4,6 +4,9 @@ Changelog Next release -------------- +- Ensure each license rule has a unique generated validation test name. + https://github.com/aboutcode-org/scancode-toolkit/issues/5257 + - Fix the optional ``licenses`` extra dependency typo to install ``licensedcode-data``. https://github.com/aboutcode-org/scancode-toolkit/pull/5056 diff --git a/src/licensedcode/data/rules/cnri-python-1.6_1.RULE b/src/licensedcode/data/rules/cnri-python-1.6_19.RULE similarity index 100% rename from src/licensedcode/data/rules/cnri-python-1.6_1.RULE rename to src/licensedcode/data/rules/cnri-python-1.6_19.RULE diff --git a/src/licensedcode/data/rules/proprietary_10.RULE b/src/licensedcode/data/rules/proprietary_155.RULE similarity index 100% rename from src/licensedcode/data/rules/proprietary_10.RULE rename to src/licensedcode/data/rules/proprietary_155.RULE diff --git a/tests/licensedcode/test_detect.py b/tests/licensedcode/test_detect.py index 5dbf7b369b..a1475c390f 100644 --- a/tests/licensedcode/test_detect.py +++ b/tests/licensedcode/test_detect.py @@ -1075,8 +1075,8 @@ def test_match_has_correct_line_positions_in_automake_perl_file(self): expected = [ # detected, match.lines(), match.qspan, ('gpl-2.0-plus', (12, 25), Span(51, 160)), - ('fsf-unlimited-no-warranty', (231, 238), Span(986, 1049)), - ('warranty-disclaimer', (306, 307), Span(1359, 1381)), + ('fsf-unlimited-no-warranty', (231, 238), Span(998, 1061)), + ('warranty-disclaimer', (306, 307), Span(1371, 1393)), ] self.check_position('positions/automake.pl', expected) diff --git a/tests/licensedcode/test_rule_file_names.py b/tests/licensedcode/test_rule_file_names.py new file mode 100644 index 0000000000..1f6adc8e54 --- /dev/null +++ b/tests/licensedcode/test_rule_file_names.py @@ -0,0 +1,32 @@ +# +# Copyright (c) nexB Inc. and others. All rights reserved. +# ScanCode is a trademark of nexB Inc. +# SPDX-License-Identifier: Apache-2.0 +# See http://www.apache.org/licenses/LICENSE-2.0 for the license text. +# See https://github.com/nexB/scancode-toolkit for support or download. +# See https://aboutcode.org for more information about nexB OSS projects. +# + +from collections import defaultdict +from pathlib import Path + +from commoncode.text import python_safe_name + + +RULES_DATA_DIR = Path(__file__).parents[2] / "src" / "licensedcode" / "data" / "rules" + + +def test_rule_file_names_generate_unique_python_names(): + rule_names_by_python_name = defaultdict(list) + + for rule_file in RULES_DATA_DIR.glob("*.RULE"): + python_name = python_safe_name(rule_file.name) + rule_names_by_python_name[python_name].append(rule_file.name) + + duplicate_names = { + python_name: sorted(rule_names) + for python_name, rule_names in rule_names_by_python_name.items() + if len(rule_names) > 1 + } + + assert not duplicate_names, duplicate_names