Skip to content
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

Merged
merged 2 commits into from
Jun 22, 2018
Merged

Conversation

iemejia
Copy link
Member

@iemejia iemejia commented Jun 21, 2018

Copy link
Contributor

@swegner swegner left a 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!

@@ -560,6 +560,10 @@ ext.applyJavaNature = {
tasks.withType(JavaCompile) {
options.compilerArgs += "-XepDisableWarningsInGeneratedCode"
}
dependencies {
Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Contributor

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.

Copy link
Member Author

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")
Copy link
Contributor

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().

Copy link
Member Author

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.

Copy link
Contributor

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");

Copy link
Member Author

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.

@@ -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
Copy link
Contributor

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.

Copy link
Member Author

@iemejia iemejia Jun 21, 2018

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'.

Copy link
Contributor

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

Copy link
Contributor

@swegner swegner left a 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")
Copy link
Contributor

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");

@@ -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
Copy link
Contributor

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

@iemejia iemejia force-pushed the enable-errorprone-globally branch 2 times, most recently from 9edfa0a to 1b84c6b Compare June 21, 2018 22:38
@iemejia iemejia force-pushed the enable-errorprone-globally branch from 1b84c6b to 580767d Compare June 22, 2018 08:56
@iemejia iemejia force-pushed the enable-errorprone-globally branch from 580767d to 359110e Compare June 22, 2018 09:20
@iemejia
Copy link
Member Author

iemejia commented Jun 22, 2018

retest this please

@iemejia iemejia merged commit d75365e into apache:master Jun 22, 2018
@iemejia
Copy link
Member Author

iemejia commented Jun 22, 2018

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.

@iemejia iemejia deleted the enable-errorprone-globally branch June 22, 2018 12:15
@swegner
Copy link
Contributor

swegner commented Jun 22, 2018

Makes sense to me-- I can send a notification once we're fully-migrated. I probably won't get to the remaining sdks-java-core work until next week. If anybody has time before that, feel free to pick it up.

charlesccychen pushed a commit to charlesccychen/beam that referenced this pull request Jul 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants