From 72121795a88fbd4de3bdae0e46384c21fc4fff69 Mon Sep 17 00:00:00 2001 From: alexzurbonsen Date: Mon, 9 Dec 2024 11:32:22 +0100 Subject: [PATCH] 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 --- src/licensedcode/detection.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/licensedcode/detection.py b/src/licensedcode/detection.py index 7e5bf1dcf8..37075c6e79 100644 --- a/src/licensedcode/detection.py +++ b/src/licensedcode/detection.py @@ -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