Skip to content

Fix wildcard support in RemoveRedundantDependencies - #194

Merged
timtebeek merged 2 commits into
mainfrom
tim/redundant-deps-wildcard-support
Jul 31, 2026
Merged

Fix wildcard support in RemoveRedundantDependencies#194
timtebeek merged 2 commits into
mainfrom
tim/redundant-deps-wildcard-support

Conversation

@timtebeek

Copy link
Copy Markdown
Member

The visitor guarded every removal candidate with a check that it did not match the recipe’s groupId/artifactId globs — intended to protect the provider dependency itself, but the effect was to suppress removal of anything the glob matched, so */* was a complete no-op and spring-boot-starter-* missed spring-boot-starter-json even though spring-boot-starter-web provides it. This records which direct dependency contributed each transitive on TransitiveDependency.providedBy and skips only genuine self-provision instead of every glob match. Adds seven tests covering match-all, wildcard artifactId, ?, glob groupId, a guard that match-all does not over-delete, and two glob-matching starters where one provides the other — three of these fail without the fix and all 18 pre-existing tests still pass. Note that TransitiveDependency is a public accumulator type, so its shape changes here. The two Gradle tooling-API tests could not be exercised locally because this machine is being HTTP 429’d by Maven Central (the pre-existing one fails identically on unmodified main), so they need CI to confirm.

…ndencies`

The visitor guarded every removal candidate with a check that it did not
match the recipe's `groupId`/`artifactId` globs. The intent was to avoid
deleting the provider dependency itself, but the effect was to suppress
removal of anything the glob matched. The wider the glob, the more it
suppressed: `*`/`*` matched every declaration and made the recipe a
complete no-op, and `spring-boot-starter-*` missed `spring-boot-starter-json`
even though `spring-boot-starter-web` provides it.

Record which direct dependency contributed each transitive on
`TransitiveDependency.providedBy`, and skip only genuine self-provision
rather than every glob match.
@timtebeek
timtebeek marked this pull request as ready for review July 31, 2026 15:12
@timtebeek timtebeek added bug Something isn't working recipe labels Jul 31, 2026
@timtebeek
timtebeek requested a review from nmck257 July 31, 2026 15:13
@timtebeek
timtebeek merged commit 1efeb96 into main Jul 31, 2026
1 check passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in OpenRewrite Jul 31, 2026
@timtebeek
timtebeek deleted the tim/redundant-deps-wildcard-support branch July 31, 2026 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working recipe

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant