MCPcopy Create free account
hub / github.com/aboutcode-org/scancode-toolkit / is_candidate_false_positive

Function is_candidate_false_positive

src/licensedcode/match.py:2651–2688  ·  view source on GitHub ↗

Return True if the ``match`` LicenseMatch is a candidate false positive license list match.

(
    match,
    max_length=20,
    trace=TRACE_FILTER_LICENSE_LIST_DETAILED,
)

Source from the content-addressed store, hash-verified

2649
2650
2651def is_candidate_false_positive(
2652 match,
2653 max_length=20,
2654 trace=TRACE_FILTER_LICENSE_LIST_DETAILED,
2655):
2656 """
2657 Return True if the ``match`` LicenseMatch is a candidate false positive
2658 license list match.
2659 """
2660 is_candidate = (
2661 # only tags, refs, or clues
2662 (
2663 match.rule.is_license_reference
2664 or match.rule.is_license_tag
2665 or match.rule.is_license_intro
2666 or match.rule.is_license_clue
2667 )
2668 # but not tags that are SPDX license identifiers
2669 and not match.matcher == '1-spdx-id'
2670 # exact matches only
2671 and match.coverage() == 100
2672
2673 # not too long
2674 and match.len() <= max_length
2675 )
2676
2677 if trace:
2678 print(' MATCH:', match)
2679 print(' is_candidate_false_positive:', is_candidate,
2680 'is_license_reference:', match.rule.is_license_reference,
2681 'is_license_tag:', match.rule.is_license_tag,
2682 'is_license_intro:', match.rule.is_license_intro,
2683 'is_license_clue:', match.rule.is_license_clue,
2684 'coverage:', match.coverage(),
2685 'match.len():', match.len(), '<=', 'max_length:', max_length,
2686 ':', match.len() <= max_length
2687 )
2688 return is_candidate
2689
2690
2691def refine_matches(

Calls 2

coverageMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected