Skip to content

Commit 35029f3

Browse files
committed
Fix bug in any and all conditions
Due to wrong handling of any and all functions license matches are categorized as having full relevance or copyrights, even if they do not. This leads to a regression in false positive detection. Correct the any and all conditions to correctly detect copyrights and relevance. Signed-off-by: alexzurbonsen <[email protected]>
1 parent c40476a commit 35029f3

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

src/licensedcode/detection.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,26 +1166,22 @@ def is_false_positive(license_matches, package_license=False):
11661166
# FIXME: actually run copyright detection here?
11671167
copyright_words = ["copyright", "(c)"]
11681168
has_copyrights = all(
1169-
True
1170-
for license_match in license_matches
1171-
if any(
1172-
True
1169+
any(
1170+
word in license_match.matched_text().lower()
11731171
for word in copyright_words
1174-
if word in license_match.matched_text().lower()
1175-
)
1172+
)
1173+
for license_match in license_matches
11761174
)
11771175
has_full_relevance = all(
1178-
True
1176+
license_match.rule.relevance == 100
11791177
for license_match in license_matches
1180-
if license_match.rule.relevance == 100
11811178
)
11821179
if has_copyrights or has_full_relevance:
11831180
return False
11841181

11851182
has_low_relevance = all(
1186-
True
1183+
license_match.rule.relevance < 60
11871184
for license_match in license_matches
1188-
if license_match.rule.relevance < 60
11891185
)
11901186

11911187
start_line_region = min(

0 commit comments

Comments
 (0)