Skip to content

Commit

Permalink
Fix bug in any and all conditions
Browse files Browse the repository at this point in the history
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 <alexander.zur.bonsen@tngtech.com>
  • Loading branch information
alexzurbonsen committed Dec 9, 2024
1 parent c40476a commit 7212179
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/licensedcode/detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -1166,18 +1166,15 @@ def is_false_positive(license_matches, package_license=False):
# FIXME: actually run copyright detection here?
copyright_words = ["copyright", "(c)"]
has_copyrights = all(
True
for license_match in license_matches
if any(
True
any(
word in license_match.matched_text().lower()
for word in copyright_words
if word in license_match.matched_text().lower()
)
)
for license_match in license_matches
)
has_full_relevance = all(
True
license_match.rule.relevance == 100
for license_match in license_matches
if license_match.rule.relevance == 100
)
if has_copyrights or has_full_relevance:
return False
Expand Down

0 comments on commit 7212179

Please sign in to comment.