Skip to content

Commit 7eb8db7

Browse files
committed
improve extra-words detection
Also i regenerate the tests for https://github.com/aboutcode-org/scancode-toolkit/blob/develop/tests/packagedcode/test_license_detection.py#L265 previously there is not detection of `extra-words` due to `referenced_filenames` tag in license rule Signed-off-by: Alok Kumar <alokkumarjipura9973@gmail.com>
1 parent 193aeb8 commit 7eb8db7

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/licensedcode/detection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1382,7 +1382,7 @@ def has_references_to_local_files(license_matches):
13821382
Return True if any of the matched Rule for the ``license_matches`` has a
13831383
non empty `referenced_filenames`, otherwise return False.
13841384
"""
1385-
return any(
1385+
return not has_extra_words(license_matches) and any(
13861386
bool(match.rule.referenced_filenames)
13871387
for match in license_matches
13881388
)

tests/packagedcode/data/license_detection/reference-to-package/paddlenlp.expected.json

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,9 @@
725725
"license_expression": "apache-2.0",
726726
"license_expression_spdx": "Apache-2.0",
727727
"detection_count": 2,
728-
"detection_log": [],
728+
"detection_log": [
729+
"extra-words"
730+
],
729731
"reference_matches": [
730732
{
731733
"license_expression": "apache-2.0",
@@ -1024,7 +1026,9 @@
10241026
"matched_text_diagnostics": "License\n\n[PaddleNLP] is provided under the [Apache-2.0 License](./LICENSE)."
10251027
}
10261028
],
1027-
"detection_log": [],
1029+
"detection_log": [
1030+
"extra-words"
1031+
],
10281032
"identifier": "apache_2_0-4571361c-d5af-4e7e-c015-6cc10c1b8174"
10291033
}
10301034
],
@@ -1577,7 +1581,9 @@
15771581
"matched_text_diagnostics": "License\n\n[PaddleNLP] is provided under the [Apache-2.0 License](./LICENSE)."
15781582
}
15791583
],
1580-
"detection_log": [],
1584+
"detection_log": [
1585+
"extra-words"
1586+
],
15811587
"identifier": "apache_2_0-4571361c-d5af-4e7e-c015-6cc10c1b8174"
15821588
}
15831589
],

0 commit comments

Comments
 (0)