-
Notifications
You must be signed in to change notification settings - Fork 64
feat: Add RemoveUnusedDeclarations
#1342
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: develop
Are you sure you want to change the base?
Conversation
Generate changelog in
|
break; | ||
} | ||
return true; | ||
return input.getKind() == Diagnostic.Kind.ERROR |
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.
extract this.
kindly request some feedback. |
I feel that formatters should focus on formatting the code and avoid changing the code. At Palantir we use other tools (eg error-prone) to achieve these kind of code changes, and I'd prefer to keep it that way rather than add extra complexity to this formatter. Is there buy-in from spotless for this feature? |
they rejected due to backwards compability. Will integrate it there when its done. Already created draft PR for this. |
could live in google as well but they seem absent. |
implementation for:
RemoveUnusedDeclarations
diffplug/spotless#2547feat: Add
RemoveUnusedDeclarations
formatting ruleThis PR introduces a new Java formatting rule that automatically removes redundant modifiers and declarations that are either:
Motivation
During codebase modernization efforts (#2524), we identified recurring patterns where:
public
in interfaces)final static
instead ofstatic final
)As highlighted in this comment, such redundancies:
Key Features
The rule handles:
Interface members:
public
,static
,final
,abstract
modifierspublic static final int CONST
→int CONST
Nested types:
public static class Inner
→static class Inner
Enum declarations:
public static final VALUE
→VALUE
Modern Java features:
public final
params → implicit)Annotation declarations:
@interface
formatting)Benefits
Reduced Noise:
Maintenance Efficiency:
Modern Java Support:
Non-intrusive:
Implementation Notes
private
when meaningful)@Nullable final
parametersIntegration
Works seamlessly with: