Skip to content

Commit

Permalink
chores(analyzer): Print warning if duplicate packages
Browse files Browse the repository at this point in the history
When duplicate packages or projects are found in the dependency tree, print a
warning instead of throwing an exception and inteerrupting the scan.
Duplicate packages may arise when the same package is imported twice, in these
cases the dependency tree will be completed as the package is imported at
least once.

Signed-off-by: Stefano Bennati <[email protected]>
  • Loading branch information
bennati committed Oct 9, 2024
1 parent 546550e commit 46924a6
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions analyzer/src/main/kotlin/AnalyzerResultBuilder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
* License-Filename: LICENSE
*/

import org.apache.logging.log4j.kotlin.logger

package org.ossreviewtoolkit.analyzer

import org.ossreviewtoolkit.model.AnalyzerResult
Expand All @@ -41,9 +43,8 @@ class AnalyzerResultBuilder {

fun build(excludes: Excludes = Excludes.EMPTY): AnalyzerResult {
val duplicates = (projects.map { it.toPackage() } + packages).getDuplicates { it.id }
require(duplicates.isEmpty()) {
"Unable to create the AnalyzerResult as it contains packages and projects with the same ids: " +
duplicates.values
if (duplicates.isNotEmpty()) {
logger.warn {"Unable to create the AnalyzerResult as it contains packages and projects with the same ids: ${duplicates.values}"}

Check warning

Code scanning / detekt

Line detected, which is longer than the defined maximum line length in the code style. Warning

Line detected, which is longer than the defined maximum line length in the code style.

Check warning

Code scanning / detekt

Reports missing newlines (e.g. between parentheses of a multi-line function call Warning

Missing newline after "{"

Check warning

Code scanning / detekt

Reports spaces around curly braces Warning

Missing spacing after "{"

Check warning

Code scanning / detekt

Reports spaces around curly braces Warning

Missing spacing before "}"
}

return AnalyzerResult(projects, packages, issues, dependencyGraphs)
Expand Down

0 comments on commit 46924a6

Please sign in to comment.