-
Notifications
You must be signed in to change notification settings - Fork 332
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
Feature/remove unused properties #4636
Conversation
rewrite-maven/src/test/java/org/openrewrite/maven/RemoveUnusedPropertiesTest.java
Outdated
Show resolved
Hide resolved
…PropertiesTest.java Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Great to see; I know this has come up as a request quite a bit over the past couple years, but it's always been tricky to get right. Have you given any though to properties used in resource filtering for instance? I feel that might complicate matters here. |
zero thought into that! but at a glance, extending the scanner to check |
if (findPomUsagesVisitor.isAcceptable(sf, ctx)) { // ie: is a pom | ||
findPomUsagesVisitor.visit(sf, ctx); | ||
findFilteredResourcePathsVisitor.visit(sf, ctx); | ||
} else if (!(tree instanceof JavaSourceFile)) { // optimization: avoid visiting code files which are almost always not filtered resources |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my first instinct was to check the JavaSourceSet
marker for this, but I didn't see a way to differentiate between code files and resources with that marker
fyi @timtebeek I'll probably merge this along later today, if no other concerns. I believe the added handling for filtered resources should be fairly robust |
Apologies for the delay in reviewing this @nmck257 ; I'd been out since last Wednesday and only just now trying to catch up. I did just spot perhaps a small oversight: the default delimiters for resource filtering include On my end to test this I have the Apache Maven repositories checked out with downloaded LSTs :
Then once configured in the Moderne IntelliJ plugin: Ideally there's no false positives in such a run; whereas currently nearly all projects would see properties removed, which is perhaps a bit too enthusiastic (although not necessarily wrong). Something to perhaps follow up, especially if you're similarly considering a run over there making changes with false positives. |
What's changed?
Added a new
RemoveUnusedProperties
maven recipeWhat's your motivation?
Seems useful for certain hygiene tasks
Anything in particular you'd like reviewers to focus on?
My
parentHasProperty
method -- I think that it:PomCache
hits and not actually cause new downloads...but open to other ideas :)
Anyone you would like to review specifically?
Have you considered any alternatives or workarounds?
Any additional context
Running this with the default
.+
matcher can be a little over-eager, particularly for properties which support custom plugins, but the recipe seems quite practical for specific use cases (eg cleaning invalid.+\\.version
properties for a Spring Boot project)Checklist