From 3c607416b5133639bad3ea4a6001ef0d424ea37b Mon Sep 17 00:00:00 2001 From: Istvan Soos Date: Wed, 1 Oct 2025 15:31:20 +0200 Subject: [PATCH 1/2] Fix bug in removeOverLappingMatches --- lib/src/license_detection/license_detector.dart | 2 +- test/licenses/license_coverage_test.dart | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/src/license_detection/license_detector.dart b/lib/src/license_detection/license_detector.dart index cc6897a25..2c62c569b 100644 --- a/lib/src/license_detection/license_detector.dart +++ b/lib/src/license_detection/license_detector.dart @@ -216,7 +216,7 @@ List removeOverLappingMatches(List matches) { // Retain both the licenses in case of an exact match, // so that it can be resolved by the user. if (aConf > bConf) { - proposals[j] = true; + proposals[j] = false; } else if (bConf > aConf) { keep = false; } diff --git a/test/licenses/license_coverage_test.dart b/test/licenses/license_coverage_test.dart index 339056df0..2ddf0e146 100644 --- a/test/licenses/license_coverage_test.dart +++ b/test/licenses/license_coverage_test.dart @@ -16,10 +16,10 @@ void main() { license.content, relativePath: 'LICENSE', ); - final match = detected - .where((l) => l.spdxIdentifier == license.identifier) - .single; - + // should only match the same license + expect(detected, hasLength(1)); + final match = detected.single; + expect(match.spdxIdentifier, license.identifier); expect(match.range!.coverages, hasLength(2)); } }); From 36a7fe1f914e96f77acc83f38433ae504a4f87a2 Mon Sep 17 00:00:00 2001 From: Istvan Soos Date: Wed, 1 Oct 2025 16:03:37 +0200 Subject: [PATCH 2/2] updated test --- test/license_detector_test.dart | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/test/license_detector_test.dart b/test/license_detector_test.dart index 29f29077d..aee61d283 100644 --- a/test/license_detector_test.dart +++ b/test/license_detector_test.dart @@ -127,7 +127,7 @@ void main() { ); _testOverLappingMatches( - name: 'Does not discard match contained in other with less token density', + name: 'discard a match contained in other with less token density', input: [ _dummyLicenseMatchInstance( 1, @@ -146,13 +146,6 @@ void main() { _dummyLicenseMatchInstance(0.65, 'matchC', start: 140, end: 200), ], expected: [ - _dummyLicenseMatchInstance( - 1, - 'matchB', - start: 5, - end: 95, - tokensClaimed: 75, - ), _dummyLicenseMatchInstance( 0.9, 'matchA',