Return True if the ``match`` LicenseMatch is a candidate false positive license list match.
(
match,
max_length=20,
trace=TRACE_FILTER_LICENSE_LIST_DETAILED,
)
| 2649 | |
| 2650 | |
| 2651 | def 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 | |
| 2691 | def refine_matches( |
no test coverage detected