diff --git a/plugins/reporters/evaluated-model/src/funTest/assets/evaluated-model-reporter-test-deduplicate-expected-output.yml b/plugins/reporters/evaluated-model/src/funTest/assets/evaluated-model-reporter-test-deduplicate-expected-output.yml index d19012efff0da..f70d45594bfb6 100644 --- a/plugins/reporters/evaluated-model/src/funTest/assets/evaluated-model-reporter-test-deduplicate-expected-output.yml +++ b/plugins/reporters/evaluated-model/src/funTest/assets/evaluated-model-reporter-test-deduplicate-expected-output.yml @@ -8,6 +8,9 @@ path_excludes: pattern: "**/*.java" reason: "EXAMPLE_OF" comment: "These are example files." +- _id: 2 + pattern: "analyzer/src/funTest/assets/projects/synthetic/gradle/lib/excluded-file.dat" + reason: "DATA_FILE_OF" scope_excludes: - _id: 0 pattern: "testCompile" @@ -976,9 +979,7 @@ repository: paths: - 0 - 1 - - _id: 2 - pattern: "analyzer/src/funTest/assets/projects/synthetic/gradle/lib/excluded-file.dat" - reason: "DATA_FILE_OF" + - 2 scopes: - 0 resolutions: diff --git a/plugins/reporters/evaluated-model/src/funTest/assets/evaluated-model-reporter-test-expected-output.json b/plugins/reporters/evaluated-model/src/funTest/assets/evaluated-model-reporter-test-expected-output.json index 3d43e0aca2164..df559f1740b35 100644 --- a/plugins/reporters/evaluated-model/src/funTest/assets/evaluated-model-reporter-test-expected-output.json +++ b/plugins/reporters/evaluated-model/src/funTest/assets/evaluated-model-reporter-test-expected-output.json @@ -9,6 +9,10 @@ "pattern" : "**/*.java", "reason" : "EXAMPLE_OF", "comment" : "These are example files." + }, { + "_id" : 2, + "pattern" : "analyzer/src/funTest/assets/projects/synthetic/gradle/lib/excluded-file.dat", + "reason" : "DATA_FILE_OF" } ], "scope_excludes" : [ { "_id" : 0, @@ -1073,11 +1077,7 @@ }, "config" : { "excludes" : { - "paths" : [ 0, 1, { - "_id" : 2, - "pattern" : "analyzer/src/funTest/assets/projects/synthetic/gradle/lib/excluded-file.dat", - "reason" : "DATA_FILE_OF" - } ], + "paths" : [ 0, 1, 2 ], "scopes" : [ 0 ] }, "resolutions" : { diff --git a/plugins/reporters/evaluated-model/src/funTest/assets/evaluated-model-reporter-test-expected-output.yml b/plugins/reporters/evaluated-model/src/funTest/assets/evaluated-model-reporter-test-expected-output.yml index 67c85f2008fd8..8989432e8b14d 100644 --- a/plugins/reporters/evaluated-model/src/funTest/assets/evaluated-model-reporter-test-expected-output.yml +++ b/plugins/reporters/evaluated-model/src/funTest/assets/evaluated-model-reporter-test-expected-output.yml @@ -8,6 +8,9 @@ path_excludes: pattern: "**/*.java" reason: "EXAMPLE_OF" comment: "These are example files." +- _id: 2 + pattern: "analyzer/src/funTest/assets/projects/synthetic/gradle/lib/excluded-file.dat" + reason: "DATA_FILE_OF" scope_excludes: - _id: 0 pattern: "testCompile" @@ -980,9 +983,7 @@ repository: paths: - 0 - 1 - - _id: 2 - pattern: "analyzer/src/funTest/assets/projects/synthetic/gradle/lib/excluded-file.dat" - reason: "DATA_FILE_OF" + - 2 scopes: - 0 resolutions: diff --git a/plugins/reporters/evaluated-model/src/main/kotlin/EvaluatedModelMapper.kt b/plugins/reporters/evaluated-model/src/main/kotlin/EvaluatedModelMapper.kt index f12c0d5539f82..7911b88ff3c32 100644 --- a/plugins/reporters/evaluated-model/src/main/kotlin/EvaluatedModelMapper.kt +++ b/plugins/reporters/evaluated-model/src/main/kotlin/EvaluatedModelMapper.kt @@ -147,7 +147,7 @@ internal class EvaluatedModelMapper(private val input: ReporterInput) { vulnerabilitiesResolutions = vulnerabilitiesResolutions, vulnerabilities = vulnerabilities, statistics = with(input) { getStatistics(ortResult, licenseInfoResolver, ortConfig) }, - repository = input.ortResult.repository.deduplicateResolutions(), + repository = input.ortResult.repository.deduplicateResolutionsAndExcludes(), severeIssueThreshold = input.ortConfig.severeIssueThreshold, severeRuleViolationThreshold = input.ortConfig.severeRuleViolationThreshold, repositoryConfiguration = input.ortResult.repository.config.toYaml(), @@ -724,23 +724,26 @@ internal class EvaluatedModelMapper(private val input: ReporterInput) { values.map { addIfRequired(it) }.distinct() /** - * Return a copy of the [RepositoryConfiguration] with [Resolutions] that refer to the same instances as the - * [ResolvedConfiguration] for equal [Resolutions]. This is required for the [EvaluatedModel] to contained indexed - * references instead of duplicate [Resolutions]. + * Return a copy of the [RepositoryConfiguration] with [Resolutions] and [Excludes] that refer to the same instances + * as the [ResolvedConfiguration] for equal entries. This is required for the [EvaluatedModel] to contain indexed + * entries instead of duplicate ones. */ - private fun Repository.deduplicateResolutions(): Repository { + private fun Repository.deduplicateResolutionsAndExcludes(): Repository { val resolutions = with(config.resolutions) { copy( - issues = issues.map { resolution -> issueResolutions.find { resolution == it } ?: resolution }, - ruleViolations = ruleViolations.map { resolution -> - ruleViolationResolutions.find { resolution == it } ?: resolution - }, - vulnerabilities = vulnerabilities.map { resolution -> - vulnerabilitiesResolutions.find { resolution == it } ?: resolution - } + issues = issues.map { issueResolutions.addIfRequired(it) }, + ruleViolations = ruleViolations.map { ruleViolationResolutions.addIfRequired(it) }, + vulnerabilities = vulnerabilities.map { vulnerabilitiesResolutions.addIfRequired(it) } + ) + } + + val excludes = with(config.excludes) { + copy( + paths = paths.map { pathExcludes.addIfRequired(it) }, + scopes = scopes.map { scopeExcludes.addIfRequired(it) } ) } - return copy(config = config.copy(resolutions = resolutions)) + return copy(config = config.copy(excludes = excludes, resolutions = resolutions)) } }