Skip to content

fix: skip deep dependency comparison for Gradle projects #9817

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion model/src/main/kotlin/Identifier.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,12 @@ data class Identifier(
/**
* The version of the component.
*/
val version: String
val version: String,

/**
* The selected variants of the component.
*/
val variants: Set<String> = emptySet()
) : Comparable<Identifier> {
companion object {
/**
Expand Down
9 changes: 8 additions & 1 deletion model/src/main/kotlin/utils/DependencyGraphBuilder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,14 @@

val dependencies1 = ref.dependencies.mapTo(mutableSetOf()) { dependencyIds[it.pkg] }
val dependencies2 = dependencies.associateBy { dependencyHandler.identifierFor(it) }
if (dependencies1 != dependencies2.keys) return false

if (dependencies1 == dependencies2.keys) {
if (!dependencyHandler.requiresDeepDependencyTreeComparison()) {
return true

Check warning on line 334 in model/src/main/kotlin/utils/DependencyGraphBuilder.kt

View check run for this annotation

Codecov / codecov/patch

model/src/main/kotlin/utils/DependencyGraphBuilder.kt#L334

Added line #L334 was not covered by tests
}
} else {
return false

Check warning on line 337 in model/src/main/kotlin/utils/DependencyGraphBuilder.kt

View check run for this annotation

Codecov / codecov/patch

model/src/main/kotlin/utils/DependencyGraphBuilder.kt#L337

Added line #L337 was not covered by tests
}

return ref.dependencies.all { refDep ->
dependencies2[dependencyIds[refDep.pkg]]?.let { dependencyTreeEquals(refDep, it) } == true
Expand Down
7 changes: 7 additions & 0 deletions model/src/main/kotlin/utils/DependencyHandler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,11 @@ interface DependencyHandler<D> {
* implementation returns an empty collection.
*/
fun issuesForDependency(dependency: D): List<Issue> = emptyList()

/**
* Does node comparison require a deep comparison of the whole dependency subtree or not? If the underlying
* dependency management system, gives the guarantee for the latter, a costly comparison can be avoided and
* speed up the analysis process.
*/
fun requiresDeepDependencyTreeComparison() = true
}
Loading
Loading