-
Notifications
You must be signed in to change notification settings - Fork 339
refactor(model): Stop implementing Comparable with DependencyReference #8697
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
base: main
Are you sure you want to change the base?
Changes from all commits
3f2a0eb
87fd707
9ece42c
5d8f9d9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,8 +23,6 @@ import com.fasterxml.jackson.annotation.JsonIgnore | |
import com.fasterxml.jackson.annotation.JsonInclude | ||
import com.fasterxml.jackson.databind.annotation.JsonSerialize | ||
|
||
import java.util.SortedSet | ||
|
||
import org.ossreviewtoolkit.model.utils.DependencyGraphEdgeSortedSetConverter | ||
import org.ossreviewtoolkit.model.utils.DependencyReferenceSortedSetConverter | ||
import org.ossreviewtoolkit.model.utils.PackageLinkageValueFilter | ||
|
@@ -86,7 +84,8 @@ data class DependencyGraph( | |
* declared by scopes that cannot be reached via other paths in the dependency graph. Note that this property | ||
* exists for backwards compatibility only; it is replaced by the lists of nodes and edges. | ||
*/ | ||
val scopeRoots: SortedSet<DependencyReference> = sortedSetOf(), | ||
@JsonSerialize(converter = DependencyReferenceSortedSetConverter::class) | ||
val scopeRoots: Set<DependencyReference> = emptySet(), | ||
|
||
/** | ||
* A mapping from scope names to the direct dependencies of the scopes. Based on this information, the set of | ||
|
@@ -109,12 +108,6 @@ data class DependencyGraph( | |
val edges: Set<DependencyGraphEdge>? = null | ||
) { | ||
companion object { | ||
/** | ||
* A comparator for [DependencyReference] objects. Note that the concrete order does not really matter, it | ||
* just has to be well-defined. | ||
*/ | ||
val DEPENDENCY_REFERENCE_COMPARATOR = compareBy<DependencyReference>({ it.pkg }, { it.fragment }) | ||
|
||
/** | ||
* Return a name for the given [scope][scopeName] that is qualified with parts of the identifier of the given | ||
* [project]. This is used to ensure that the scope names are unique when constructing a dependency graph from | ||
|
@@ -302,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( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Commit message: Could you please add a permalink to the exact test case? I'm having trouble finding it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've also re-written the commit message as the thing with the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change makes me worry. The class comment says "This is by intention no data class. Equality is tested via references and not via the values contained." If you now have a generated There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm, the tests which started failing when stopping to implement There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another alternative could be to hold these dependency references always in lists, not sets, to avoid the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
/** | ||
* 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. | ||
|
@@ -333,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 | ||
} | ||
} | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure what the original motivation for this Maybe @oheger-bosch can chime in here to confirm that this change (by now, with the preceding changes) is uncritical? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's been a while... But as far as I remember, the purpose of the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Do you remember in what way this could be problematic? Was it non-deterministic without implementing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not 100% sure, but I think for a given order in which the graph builder was called, the results were the same. |
||
|
||
/** | ||
* A data class representing a node in the dependency graph. | ||
|
Uh oh!
There was an error while loading. Please reload this page.