-
Notifications
You must be signed in to change notification settings - Fork 25k
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
Update checkstyle and fix violations #20909
Conversation
I'll reviewing it. I like boring PRs while drinking coffee in the morning. |
I think if we think our reasons are good we should pop over to the checkstyle project and file an issue asking to be able to disable that portion of the check. Is our reason that we want implementers to declare those parameters final and we like that IDEs do that by default if the parameters are final in the interfaces? Beyond that I can't think of any reason to declare parameters on interface methods final. |
@@ -209,7 +209,7 @@ public void testPathPrefix() throws IOException { | |||
final HttpContext context = | |||
httpServer.createContext("/" + pathPrefix + statusCode + uniqueContextSuffix, new ResponseHandler(statusCode)); | |||
|
|||
try (final RestClient client = | |||
try (RestClient client = |
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'd never really thought of this but it makes sense.
Yes, this is the "good reason" I'm talking about. I didn't check every place but each time such a violation was reported I found a good reason to let the
Makes sense. |
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.
All the code changes look good to me. They fall into three categories:
public
methods on non-public
classes don't make sense. Remove the modifier and let the method inherit the modifier.- try-with-resources variables should not be declared
final
because they are implicitlyfinal
.final
adds no extra information for the reader. I guess that makes them names rather than variables.... enum
s are alwaystatic
so there is no need to declare themstatic
.final
doesn't do anything on anonymous classes because they can't be extended anyway. So we just remove the modifier.- Classes declared inside of interfaces are always
static
so we shouldn't also declare them asstatic
.
Personally I'm not sure that "because implementers should declare them |
Question: why do we have all these violations to fix just because we are upgrading checkstyle? Did the set of applied rules change as well? This all makes sense (I was tired too of seeing all these warnings in my IDE) but it would be good (for next time) to do one category at a time maybe? Can we also update the description of the PR with the nice summary that Nik posted? |
The meaning of the |
Not really the set of rules but rather the way the rule are working.
Sadly we can't because we can't really configure the granularity of the checks.
Sure, I should have done that. |
Maybe we could have fixed the issues one category at a time before updating checkstyle for instance? Not sure though. Anyways, thanks for fixing these! |
Yeah, we certainly could have. If these changes hadn't been super mechanical stuff I could review while leisurely sipping coffee I'd have asked for that. And we should totally keep that as an option for next time! |
Closed in favor of #22960 |
This PR updates the version of Checkstyle from current
5.9
to7.1
and fix a bunch of new violations.A more recent version would allow us to use some new checkstyle modules (like Javadocs).
RedundantModifier
is improved and now detects more violations that are fixed by this PR. The changes fall into three categories (thanks @nik9000 for the nice summary):public
methods on non-public
classes don't make sense. Remove the modifier and let the method inherit the modifier.final
because they are implicitlyfinal
.final
adds no extra information for the reader. I guess that makes them names rather than variables....enum
s are alwaystatic
so there is no need to declare themstatic
.final
doesn't do anything on anonymous classes because they can't be extended anyway. So we just remove the modifier.static
so we shouldn't also declare them asstatic
.For the record, most of the changes were automated using this small Bash script:
Checkstyle was not updated to the latest version 7.1.2 because it reports violations for
final
parameters in interface methods (checkstyle/checkstyle#3322) and we have a lot of these for good reason.I'm really sorry for the boringness of this kind of pull request.