apache / apache/maven-dependency-tree
VerboseJavaScopeSelector.ScopeComparator is inconsistent for scopes outside the ordered list
- Dominant language
- Java
- Stars
- 27
- Forks
- 31
- Avg merge
- 5h 53m
- Merged PRs (30d)
- 1
Description
## Summary
`VerboseJavaScopeSelector.ScopeComparator` orders scopes by `indexOf` in the fixed list `["compile", "runtime", "provided", "test"]`. Any scope not in that list (e.g. `system`, or a custom scope) returns `indexOf == -1` for both operands, so the comparator returns `0` for such pairs and can select the wrong “max” scope. This violates the `Comparator` contract and can corrupt the `REDUCED_SCOPE` value recorded on the winning node.
## Affected code
`src/main/java/org/apache/maven/shared/dependency/graph/internal/VerboseJavaScopeSelector.java:50-57`
## Suggested fix
Give unknown scopes a deterministic ordering (e.g. treat as lower/least, or fall back to the full known Java scope list including `system`), and add a test for scopes outside the four listed ones.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in src/main/java/org/apache/maven/shared/dependency/graph/internal/VerboseJavaScopeSelector.java at lines 50-57 and inspect how ScopeComparator handles scopes outside its fixed list. Add coverage for system or a custom scope, then verify that unknown scopes have deterministic ordering and that the resulting REDUCED_SCOPE is correct.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 75/100