From 500bd9d8a04bc9a4e9a456643cafe88bfc803da7 Mon Sep 17 00:00:00 2001 From: w3lld1 <42353747+w3lld1@users.noreply.github.com> Date: Mon, 3 Aug 2026 02:15:55 +0200 Subject: [PATCH 1/2] Ensure unique license validation test names Signed-off-by: w3lld1 <42353747+w3lld1@users.noreply.github.com> --- AUTHORS.rst | 1 + CHANGELOG.rst | 3 ++ ...hon-1.6_1.RULE => cnri-python-1.6_19.RULE} | 0 ...oprietary_10.RULE => proprietary_155.RULE} | 0 tests/licensedcode/test_rule_file_names.py | 32 +++++++++++++++++++ 5 files changed, 36 insertions(+) rename src/licensedcode/data/rules/{cnri-python-1.6_1.RULE => cnri-python-1.6_19.RULE} (100%) rename src/licensedcode/data/rules/{proprietary_10.RULE => proprietary_155.RULE} (100%) create mode 100644 tests/licensedcode/test_rule_file_names.py diff --git a/AUTHORS.rst b/AUTHORS.rst index 9a8224dc7da..6fc80f05ce1 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 d9a5a6b4026..1472f7877e7 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_rule_file_names.py b/tests/licensedcode/test_rule_file_names.py new file mode 100644 index 00000000000..1f6adc8e542 --- /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 From c0fa6d763342bfc2a76539cfeaa75a95505cbf09 Mon Sep 17 00:00:00 2001 From: w3lld1 <42353747+w3lld1@users.noreply.github.com> Date: Mon, 3 Aug 2026 06:05:39 +0200 Subject: [PATCH 2/2] test: update license match spans Signed-off-by: w3lld1 <42353747+w3lld1@users.noreply.github.com> --- tests/licensedcode/test_detect.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/licensedcode/test_detect.py b/tests/licensedcode/test_detect.py index 5dbf7b369bf..a1475c390f7 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)