-
Notifications
You must be signed in to change notification settings - Fork 41.8k
Add UseStaticImport #48669
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
Add UseStaticImport #48669
Conversation
|
Thanks for the proposal. There's some overlap with what's already covered by Spring Java Format and its Checkstyle rules. I'd like to discuss this with the team as that duplication doesn't feel great. We may want to take a similar approach to the Framework team where they applied (some of) the code changes without introducing the new tooling infrastructure. |
Yes, more or less all tools try to solve the same issue. Still, it’s just software, which means it’s full of bugs and flaws—like everything else we are used to. For whitespace checks, Checkstyle has an estimated ~90% error rate for whitespace-related issues and remains quite blind because it is not type-aware. PMD, Rewrite, and Error Prone address this problem, which makes them strong candidates for layering. No single tool is capable of catching everything on its own.
Of course, it’s nice to have the issues actually fixed. Still, this approach isn’t ideal—it addresses the symptoms rather than the root cause. As a result, the effort is somewhat wasted, because the problem is never truly done, only temporarily mitigated. In the end, only automation can scale properly. That’s why automation is the correct approach to solve this issue once and properly, instead of fixing it once while still allowing the same flaws and issues to reoccur later. Otherwise, the entire effort and initiative become questionable if they are not done in a sustainable way. I understand that it’s not pleasant to introduce a new tool, as humans tend to struggle with adapting to new standards. Nevertheless, that is ultimately what life is about: adaptation. For those who don’t adapt, nature itself has a clear and direct response. From my perspective, there are only two options. The first is to adapt to the new reality and incorporate the tool, using it to fix flaws systematically instead of repeatedly patching symptoms. The second is to continue with the current approach, which leaves doors wide open for flaws, issues, and potentially even bugs that could otherwise be addressed by this kind of tooling—especially considering Thanks for the attention given. |
In this case, it's called redundancy—imposing a common principle for critical infrastructure. |
1a3ce30 to
0417e12
Compare
SanityCheck#EqualityRulesRecipes #48630UseStaticImport #48630
Signed-off-by: Vincent Potucek <[email protected]>
0417e12 to
da8537f
Compare
| displayName: Use static import | ||
| recipeList: | ||
| - org.openrewrite.java.UseStaticImport: | ||
| methodPattern: org.assertj.core.api.Assertions *(..) |
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.
so its actually not working as expected. Might be an bug or wrong regex.
Kindly asking @timtebeek how to solve this, please?
|
Updated PR accordingly to just match the |
|
We discussed this today and decided that we don't want to adopt any additional static analysis tools at this time. We're happy with our current approach using Checkstyle and ArchUnit. Thanks anyway for the PR. |
Inspired by the change initiated in #48630, this appears to be the matching counterpart to the
StaticImportsrule.Although the rule is active and covered by tests (the
emptyListexample works as expected), it is currently not functioning as intended. This should therefore be filed as a simple bug report in the Rewrite repository and fixed afterward.org.openrewrite.java.testing.assertj.StaticImportsnot applied openrewrite/rewrite-testing-frameworks#885Despite this, we could also apply the same changes and alignments here, similar to what was done in the framework.
As in the framework, this change involves the same file- and time-based updates and could be aligned accordingly:
java.timeAPI usages spring-framework#35861Referes to:
rewritesupport forerrorprone.refasterrules#46749org.springframework.boot.openrewrite.SanityCheck#48530Changes: