diff --git a/providers/summary/scancode-new.js b/providers/summary/scancode-new.js index c3e863d0d..0658eff12 100644 --- a/providers/summary/scancode-new.js +++ b/providers/summary/scancode-new.js @@ -115,12 +115,12 @@ class ScanCodeSummarizerNew { _getDeclaredLicenseFromFiles(harvestedData, coordinates) { const rootFiles = this._getRootFiles(coordinates, harvestedData.content.files, harvestedData.content.packages) - return this._getLicenseFromLicenseDetections(rootFiles) + return this._getLicensesFromLicenseDetections(rootFiles) } - _getLicenseFromLicenseDetections(files) { + _getLicensesFromLicenseDetections(files) { const fullLicenses = files - .filter(file => file.percentage_of_license_text >= 80 && file.license_detections) + .filter(file => file.percentage_of_license_text >= 90 && file.license_detections) .reduce((licenses, file) => { file.license_detections.forEach(licenseDetection => { licenses.add(normalizeLicenseExpression(licenseDetection.license_expression, this.logger)) @@ -130,7 +130,7 @@ class ScanCodeSummarizerNew { return joinExpressions(fullLicenses) } - _getLicenseByFileName(files, coordinates) { + _getLicenseByFileName(files, coordinates, licenseClarityScoreThreshold = 90) { const fullLicenses = files .filter(file => isLicenseFile(file.path, coordinates) && file.license_detections) .reduce((licenses, file) => { @@ -140,7 +140,7 @@ class ScanCodeSummarizerNew { return } licenseDetection.matches.forEach(match => { - if (match.score >= 90) { + if (match.score >= licenseClarityScoreThreshold) { licenses.add(normalizeLicenseExpression(match.license_expression, this.logger)) } }) @@ -157,14 +157,13 @@ class ScanCodeSummarizerNew { const result = { path: file.path } - const licenseExpressionFromFromLicenseDetections = this._getLicenseFromLicenseDetections([file]) const licenseExpression = file.detected_license_expression_spdx || normalizeLicenseExpression(file.detected_license_expression, this.logger) || - licenseExpressionFromFromLicenseDetections + this._getLicenseByFileName([file], coordinates, 80) setIfValue(result, 'license', licenseExpression) - if (licenseExpressionFromFromLicenseDetections || this._getLicenseByFileName([file], coordinates)) { + if (this._getLicensesFromLicenseDetections([file]) || this._getLicenseByFileName([file], coordinates)) { result.natures = result.natures || [] if (!result.natures.includes('license')) result.natures.push('license') } diff --git a/test/providers/summary/scancode-new.js b/test/providers/summary/scancode-new.js index 57cb8838e..3080fe136 100644 --- a/test/providers/summary/scancode-new.js +++ b/test/providers/summary/scancode-new.js @@ -173,10 +173,10 @@ describe('ScancodeSummarizerNew basic compatability', () => { ) assert.equal(result.described.releaseDate, '2021-01-13', `releaseDate mismatch for version ${version}`) assert.deepEqual(uniq(compact(flatten(result.files.map(x => x.attributions)))).length, 6) - assert.deepEqual(result.files.find(x => x.path === 'COPYRIGHT').natures, ['license']) + assert.equal(result.files.find(x => x.path === 'COPYRIGHT').natures, null) assert.deepEqual(result.files.find(x => x.path === 'LICENSE-APACHE').natures, ['license']) assert.deepEqual(result.files.find(x => x.path === 'LICENSE-MIT').natures, ['license']) - assert.equal(compact(flatten(result.files.map(x => x.natures))).length, 3) + assert.equal(compact(flatten(result.files.map(x => x.natures))).length, 2) } }) })