diff --git a/AUTHORS.rst b/AUTHORS.rst index 9a8224dc7d..0e46a7772c 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -108,3 +108,4 @@ The following organizations or individuals have contributed to ScanCode: - Yash Sharma @yasharmaster - Yunus Rahbar @yns88 - Stefano Zacchiroli @zacchiro +- Harish Wargad @harishwargad diff --git a/CHANGELOG.rst b/CHANGELOG.rst index cf4db41092..0e0e6a9c7f 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -8,6 +8,11 @@ Next release ``licensedcode-data``. https://github.com/aboutcode-org/scancode-toolkit/pull/5056 +- Ensure each license rule has a unique generated validation + test name, by renaming colliding rule files and adding a + regression test to prevent rule name collisions. + https://github.com/aboutcode-org/scancode-toolkit/issues/5257 + - Improve copyright detection for statements with parens or trailing "authors" 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_rule_file_names.py b/tests/licensedcode/test_rule_file_names.py new file mode 100644 index 0000000000..700430b13b --- /dev/null +++ b/tests/licensedcode/test_rule_file_names.py @@ -0,0 +1,21 @@ +from collections import defaultdict +from pathlib import Path + +from commoncode.text import python_safe_name +from licensedcode.models import rules_data_dir + + +def test_rule_file_names_generate_unique_test_method_names(): + method_to_files = defaultdict(list) + + for rule_file in Path(rules_data_dir).glob("*.RULE"): + method_name = python_safe_name(rule_file.stem) + method_to_files[method_name].append(rule_file.name) + + duplicate_names = [ + (method_name, files) + for method_name, files in method_to_files.items() + if len(files) > 1 + ] + + assert not duplicate_names, f"Duplicate test method names found: {duplicate_names}" \ No newline at end of file