Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <stefano.bennati@here.com>
bennati committed Oct 9, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
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
@@ -17,6 +17,8 @@
* License-Filename: LICENSE
*/

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

package org.ossreviewtoolkit.analyzer

import org.ossreviewtoolkit.model.AnalyzerResult
@@ -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)

0 comments on commit 46924a6

Please sign in to comment.