Skip to content

Commit

Permalink
refactor(model): Stop implementing Comparable with DependencyReference
Browse files Browse the repository at this point in the history
The `AnalayzerResultBuilder` uses `copy()` which creates copies of
`DependencyReference`s in its second test case. The assertion then
checks the equality which succeeds with the `Comparable` interface
implemented, but fails without. So, turn the `DependencyReference` into
a data class to fix that.

Signed-off-by: Frank Viernau <[email protected]>
  • Loading branch information
fviernau committed May 27, 2024
1 parent cf8d8d0 commit 4569367
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions model/src/main/kotlin/DependencyGraph.kt
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ data class RootDependencyIndex(
* Note: This is by intention no data class. Equality is tested via references and not via the values contained.
*/
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
class DependencyReference(
data class DependencyReference(
/**
* Stores the numeric index of the package dependency referenced by this object. The package behind this index can
* be resolved by evaluating the list of identifiers stored in [DependencyGraph] at this index.
Expand Down Expand Up @@ -326,17 +326,7 @@ class DependencyReference(
* A list of [Issue]s that occurred handling this dependency.
*/
val issues: List<Issue> = emptyList()
) : Comparable<DependencyReference> {
/**
* Define an order on [DependencyReference] instances. Instances are ordered by their indices and fragment indices.
*/
override fun compareTo(other: DependencyReference): Int =
if (pkg != other.pkg) {
pkg - other.pkg
} else {
fragment - other.fragment
}
}
)

/**
* A data class representing a node in the dependency graph.
Expand Down

0 comments on commit 4569367

Please sign in to comment.