-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Enable errorprone globally #5716
Conversation
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.
This is amazing. Thanks for pushing us over the finish-line!
build_rules.gradle
Outdated
@@ -560,6 +560,10 @@ ext.applyJavaNature = { | |||
tasks.withType(JavaCompile) { | |||
options.compilerArgs += "-XepDisableWarningsInGeneratedCode" | |||
} | |||
dependencies { |
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.
Should this be outside the enableErrorProne
block? My understanding is that these annotations are for Findbugs.
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.
Well these imports were mostly added to remove warnings on module-info.java files reported by error-prone. I can relocate it if you prefer but I have the impression that this scope is tighter.
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 don't have a strong preference. Maybe add a comment explaining why it's here since it's not totally obvious why ErrorProne usage should require a FindBugs dependency.
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.
ok
@@ -255,6 +255,7 @@ public Integer answer(InvocationOnMock invocation) { | |||
* is invoked. | |||
*/ | |||
@Test | |||
@SuppressWarnings("AssertionFailureIgnored") |
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.
Can this test be improved such that we don't need this suppression? The ErrorProne AssertionFailureIgnored page suggests using JUnit's assertThrows()
.
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 did not find an easy way to do this and also the proposed solution by errorprone is invalid. See google/error-prone#1059
Any suggestions are welcome.
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.
You could re-create the idea behind assertThrows
with:
Throwable failure = null;
try {
getRequest.execute();
} catch (Throwable e) {
failure = e;
}
assertNotNull("Expected execute to throw an exception", failure);
assertThat(failure, Matchers.instanceOf(SocketTimeoutException.class));
assertEquals(1 + defaultNumberOfRetries, executeCount.get());
expectedLogs.verifyWarn("performed 10 retries due to IOExceptions");
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 don't know why I was thinking in a way more complex idea. Thanks, added this.
build_rules.gradle
Outdated
@@ -344,7 +344,7 @@ class JavaNatureConfiguration { | |||
/** Controls whether the errorprone plugin is enabled and configured */ | |||
boolean enableErrorProne = true | |||
/** Controls whether compiler warnings are treated as errors */ | |||
boolean failOnWarning = false |
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.
My preference is to remove this configuration altogether and make the failOnWarning
behavior default.
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.
We can't remove this for the moment we have modules still skipping using this e.g. 'sdks/java/core'.
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.
Got it. I'll work on finishing up sdks/java/core
as I have time and then remove this. /cc @pabloem
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.
LGTM once feedback is addressed.
@@ -255,6 +255,7 @@ public Integer answer(InvocationOnMock invocation) { | |||
* is invoked. | |||
*/ | |||
@Test | |||
@SuppressWarnings("AssertionFailureIgnored") |
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.
You could re-create the idea behind assertThrows
with:
Throwable failure = null;
try {
getRequest.execute();
} catch (Throwable e) {
failure = e;
}
assertNotNull("Expected execute to throw an exception", failure);
assertThat(failure, Matchers.instanceOf(SocketTimeoutException.class));
assertEquals(1 + defaultNumberOfRetries, executeCount.get());
expectedLogs.verifyWarn("performed 10 retries due to IOExceptions");
build_rules.gradle
Outdated
@@ -344,7 +344,7 @@ class JavaNatureConfiguration { | |||
/** Controls whether the errorprone plugin is enabled and configured */ | |||
boolean enableErrorProne = true | |||
/** Controls whether compiler warnings are treated as errors */ | |||
boolean failOnWarning = false |
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.
Got it. I'll work on finishing up sdks/java/core
as I have time and then remove this. /cc @pabloem
9edfa0a
to
1b84c6b
Compare
1b84c6b
to
580767d
Compare
580767d
to
359110e
Compare
retest this please |
Addressed all comments, rebased after the plugin changes, and merged, only missing thing now is 'sdks/java/core'. Probably it would be a good idea to submit an email when finished @swegner to notify and thank the contributors to this. |
Makes sense to me-- I can send a notification once we're fully-migrated. I probably won't get to the remaining |
R: @swegner