Add missing Override annotations#10324
Conversation
|
I'm a little hesitant to fix these, like a lot of the other checkstyle issues
From this I tend to say this is better to add in diffs that change related code, to ensure that the author of a given diff did what they expected. I wonder if we can collect warnings that only apply to the current diff like we do with checkstyle and ensure we fix when we change things, rather than bulk changes like this? From reviewdog/reviewdog#1087 it looks like this should be possible in theory (includes an example with errorprone), but it apparently doesn't work. (My quick attempt to match errorprone+ant, untested via command line, but seems to capture enough for our purposes) The flip side of course is that this is an obvious change (...after one reviews all 2126 changed lines), and if it compiles it must be correct. If we want this to be required, the build should also be changed to promote this to a compile failure. |
At work we configure errorprone checks which default to warning as error if we prefer the general intent of that check. And yes we do bulk updates to fix these checks (especially when updating errorprone and new checks have been added). We thought about doing it incremental as we came across it but given the code base is large it would probably never come to an end. So these checks would need to default to warning forever. Fixing them and configure them as error improves code style consistency, makes code more readable, produces less noise during reviews and developers learn something if they run into such compile errors. If the build output is too verbose then warnings are not always noticed and they end up in reviews as well. At least that is my experience. So in general I would be fine with that bulk change here. |
|
Agreed, I'm not against it, just want to caution against bulk "I fixed every typo in the project" changes (or worse a deluge of small "fix: Removed final from a private method" PRs from autonomous agents that gotta get those stats up). Ant output is pretty gross already too - though we could turn it up specifically for CI to capture related warnings. Override is sort of a special case too, since there are so many missing, more than 10x the next most common errorprone warning, about about 2x every other warning combined. If we do fix it and turn up warnings overall, we're adding 2k or so more warnings in CI builds... though at least a few hundred of the next most common types are just a facet of GWT/JS and not going away any time soon. But if it's important enough to fix, we should ratchet up warn to error, and at least start capturing/alerting other warnings so we can fix/ratchet or downgrade. |
Then those probably should be disabled? |
|
They all are disabled - Line 58 in 4e6ae10 The greater context is that if you turn that back on (and ask javac to print more than a handful of warnings), you get all these EP issues. #10322 (comment) Maybe you're saying "if we do this change and if we turn on those other warnings and if we somehow don't make any other changes to isolate/permit accepted issues" then we should disable those checks? But the premise is "let's enable appropriate checks" so I think that's a given? |
Yes, but we could also settle on some contribution guidelines saying that such bulk updates are generally only accepted from core members with the goal to make better use of errorprone.
At work we have javac warnings turned on (with some javac warnings excluded) and we disabled ALL errorprone checks which default to warning and showed up when we introduced errorprone or when we update errorprone so we do not get overwhelmed. Then we turn them on in errorprone one by one, fix them and switch them to error. So yes we should not just remove |
|
I was specifically talking about those “at least a few hundred of the next most common types [that] are just a facet of GWT/JS”: if we enable warnings (as a whole), then disable those "next most common types" that we don't care about (we've ignored them for all these years, so even if there are "real positives" there, it might not be worth getting the spam of the ones we consider "false positives"). And BTW, if we otherwise don't care at all about warnings (any warning, like today), then we should probably use We could also |
a459c7b to
a861fb7
Compare
|
With the last commit the most common patterns are suppressed + reviewdog should report the less common ones as comments (we can use separate invocation of reviewdog since we only care about annotations and no merged summary). Also |
| reviewdog -f=checkstyle -filter-mode=diff_context -reporter=github-pr-annotations -level=info < $f | ||
| reviewdog -f=checkstyle -filter-mode=diff_context -reporter=github-pr-annotations -level=info < $f || true | ||
| done | ||
| reviewdog -efm=" [javac] %f:%l: warning: %m" -filter-mode=diff_context -reporter=github-pr-annotations -level=info < log.txt || true |
There was a problem hiding this comment.
Could you introduce a deliberate EP warning so we can validate that this is working?
|
|
||
| import javax.annotation.processing.Generated; | ||
|
|
||
| @Generated("remotemessage.proto") |
There was a problem hiding this comment.
Teeeeeechnically protobuf uses the javax.annotation.Generated annotation, though now they also use @com.google.protobuf.Generated
protocolbuffers/protobuf@31e57fc
This isn't worth changing, since our version of protobuf is so old (and can't change, since Google never open sourced the build for the dev mode plugins...), just pointing it out.
| <attribute name="excludes" default="" /> | ||
| <attribute name="processorpath" default="" /> | ||
| <attribute name="errorprone.args" default="" /> | ||
| <attribute name="errorprone.args" default="-XepDisableWarningsInGeneratedCode -xEp:MissingOverridde:ERROR -Xep:UnrecognisedJavadocTag:OFF -Xep:InvalidBlockTag:OFF -Xep:AnnotateFormatMethod:OFF -Xep:ProtectedMembersInFinalClass:OFF -Xep:TypeParameterUnusedInFormals:OFF -Xep:InvalidLink:OFF -Xep:NotJavadoc:OFF -Xep:OperatorPrecedence:OFF -Xep:IdentityHashMapUsage:OFF -Xep:DefaultCharset:OFF -Xep:StringSplitter:OFF -Xep:BadImport:OFF -Xep:UnusedVariable:OFF -Xep:JdkObsolete:OFF -Xep:SameNameButDifferent:OFF -Xep:InlineMeSuggester:OFF -Xep:UnnecessaryParentheses:OFF -Xep:NonApiType:OFF -Xep:InvalidInlineTag:OFF -Xep:ReferenceEquality:OFF -Xep:JavaUtilDate:OFF -xEp:MissingSummary:OFF -xEp:EmptyBlockTag:OFF" /> |
There was a problem hiding this comment.
It seems that this is selectively disabling some options, but by doing so in errorprone.args, the suggestion seems to be that we want to re-enable them for certain projects. Instead however, only user/build.xml overrides this, by disabling all warnings.
Wouldn't it make more sense to move these to the compilerarg tags where we want them disabled globally? Otherwise, if we were to, for example, attempt to selectively disable one more check in dev/build.xml, we would end up re-enabling all of the rest? Or, something like only put -XepDisableWarningsInGeneratedCode -xEp:MissingOverridde:ERROR here in a compiler arg, then leave user disabling all warnings (except that), and leave the rest of these as warnings until we fix them as we interact with the code?
No firm thoughts here except these are all potential bugs.
There was a problem hiding this comment.
I didn't really consider using different settings for different modules. Maybe we can look into that once we need it?
The only override is in the no-servlet compilation (user/build.xml, as you pointed out) that prevents all issues from user module to be reported twice (technically there could be some issues specific to Jakarta, but IMHO not worth the overhead).
The selection of things to ignore is based on number of reports which is not a great metric, but should avoid having too many annotations in PRs. Follow-up tickets can be made to reduce this list.
a87eae2 to
3fb4f41
Compare
Reported warnings with the current filter: |
|
Looking at #10348, it doesnt look like they are being reported in the PR still? |
@niloc132 now it worked (I forgot reviewdog only considers the changed parts of the file), but it reports it twice |
niloc132
left a comment
There was a problem hiding this comment.
Sorry it took me a while, but i've read it all now. Just a few comments.
Used ErrorProne's patch functionality to add override annotations where possible. Used regular expressions to make sure overrides are on a separate line.
This should make it easier to show errorprone warnings during compilation without going through much spam -- this is the most common errorprone as pointed out in #10322 (comment).