-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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 additional Error Prone checks & fix violations #2561
Enable additional Error Prone checks & fix violations #2561
Conversation
Some of them also enforce additional Google Java Format requirements which are not handled by google-java-format, such as disallowing wildcard imports. Not all experimental checks have been listed because some are not applicable, such as Dependency Injection framework checks, or checks related to Guava's immutable collections (since Gson's main code does not have a dependency on Guava). Other checks have been omitted because they are probably not relevant (this was a subjective choice), or would require larger refactoring or would flag issues with the public API, which cannot be changed easily.
gson/src/main/java/com/google/gson/internal/JsonReaderInternalAccess.java
Show resolved
Hide resolved
default: | ||
throw new IllegalArgumentException("Unexpected token" + reader.peek()); |
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.
switch
covers all enum constants (this redundant default
was flagged by Error Prone).
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 great. Thanks for all this work!
I did have a few minor comments.
gson/src/main/java/com/google/gson/internal/JsonReaderInternalAccess.java
Show resolved
Hide resolved
gson/src/test/java/com/google/gson/functional/CustomTypeAdaptersTest.java
Outdated
Show resolved
Hide resolved
try { | ||
// Invoke the ProtoClass.newBuilder() method |
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 related to #2561 (comment).
I removed the inner try-catch
because there is already an enclosing catch (Exception e)
which wraps the exception in a JsonParseException
, so this would probably have lead to JsonParseException -> JsonParseException -> actual exception
.
(Compare this with whitespace diff turned off to properly see the changes.)
gson/src/main/java/com/google/gson/internal/NonNullElementWrapperList.java
Show resolved
Hide resolved
* Enable additional Error Prone checks & fix violations Some of them also enforce additional Google Java Format requirements which are not handled by google-java-format, such as disallowing wildcard imports. Not all experimental checks have been listed because some are not applicable, such as Dependency Injection framework checks, or checks related to Guava's immutable collections (since Gson's main code does not have a dependency on Guava). Other checks have been omitted because they are probably not relevant (this was a subjective choice), or would require larger refactoring or would flag issues with the public API, which cannot be changed easily. * Address review feedback --------- Co-authored-by: Éamonn McManus <[email protected]>
Purpose
Enable additional Error Prone checks which are disabled by default
Description
Some of them also enforce additional Google Java Format requirements which are not handled by google-java-format, such as disallowing wildcard imports.
Not all experimental checks have been listed because some are not applicable, such as Dependency Injection framework checks, or checks related to Guava's immutable collections (since Gson's main code does not have a dependency on Guava).
Other checks have been omitted because they are probably not relevant (this was a subjective choice), or would require larger refactoring or would flag issues with the public API, which cannot be changed easily.
Open questions:
Though might not be easily possible without separate
testCompile
configuration, which duplicates configuration, or without disabling all Error Prone checks for a certain file path. There are also the (undocumented?) flags-XepCompilingTestOnlyCode
and-XepCompilingPubliclyVisibleCode
, but it is not clear which checks consider them, and it would probably still be necessary to have a separatetestCompile
configuration then which sets these flags.Checklist
This is automatically checked by
mvn verify
, but can also be checked on its own usingmvn spotless:check
.Style violations can be fixed using
mvn spotless:apply
; this can be done in a separate commit to verify that it did not cause undesired changes.null
@since $next-version$
(
$next-version$
is a special placeholder which is automatically replaced during release)TestCase
)mvn clean verify javadoc:jar
passes without errors