-
Notifications
You must be signed in to change notification settings - Fork 135
Error prone RedundantModifier check supports more interface components #1021
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
Error prone RedundantModifier check supports more interface components #1021
Conversation
Generate changelog in
|
07cc7a8 to
0700dd3
Compare
|
I haven't had a chance to test this on a large internal project yet, will post here once I've verified it. |
|
Verified on a large internal project. |
```diff
public interface Iface {
- public static void a() {}
+ static void a() {}
}
```
```diff
public interface Iface {
- public static final int VALUE = 1;
+ int VALUE = 1;
}
```
d0cba81 to
82042b8
Compare
|
Verified the new change on a large internal project as well. |
| link = "https://github.com/palantir/gradle-baseline#baseline-error-prone-checks", | ||
| linkType = BugPattern.LinkType.CUSTOM, | ||
| providesFix = BugPattern.ProvidesFix.REQUIRES_HUMAN_ATTENTION, | ||
| severity = BugPattern.SeverityLevel.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.
i'm a tiny bit concerned that having this at ERROR level might introduce unnecessary friction when people just want to run things like ./gradlew test locally. We're just detecting redundant code, not actually 'wrong' in anywa way... given that excavator can come around and auto-fix, what do you think about putting this as suggestion?
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.
Agreed, I initially used error because this in some part replaces a checkstyle check which we verify premerge.
Given that robots can fix this for us, and it's not a correctness issue, I don't mind moving it to a suggestion, and allowing minor regressions until the robots sweep through.
| } | ||
| if (INTERFACE_STATIC_METHOD_MODIFIERS.matches(tree, state)) { | ||
| return buildDescription(tree) | ||
| .setMessage("Interface components are public by default. The 'public' modifier is unnecessary.") |
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.
interesting that java9 lets people define private methods in interfaces! https://bugs.openjdk.java.net/browse/JDK-8071453
This should be all fine though, because we're explicitly only detecting and fixing the public keyword.
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.
Yep, I designed this with JEP 213 in mind.
public interface Iface { - public static void a() {} + static void a() {} }public interface Iface { - public static final int VALUE = 1; + int VALUE = 1; }Before this PR
After this PR
==COMMIT_MSG==
Error prone RedundantModifier check supports interface static methods and fields.
==COMMIT_MSG==