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

Fix error prone warnings #2316

Merged
merged 26 commits into from
Feb 15, 2023

Conversation

MaicolAntali
Copy link
Contributor

In this PR I have fixed some ErrorProne warns.

I have also add the flag -XepExcludedPaths: to the ErrorProne plugin to exclude tests and proto path

Copy link
Member

@eamonnmcmanus eamonnmcmanus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this!

gson/src/main/java/com/google/gson/Gson.java Outdated Show resolved Hide resolved
gson/src/main/java/com/google/gson/stream/JsonWriter.java Outdated Show resolved Hide resolved
@@ -98,7 +98,7 @@
<compilerArgs>
<!-- Args related to Error Prone, see: https://errorprone.info/docs/installation#maven -->
<arg>-XDcompilePolicy=simple</arg>
<arg>-Xplugin:ErrorProne</arg>
<arg>-Xplugin:ErrorProne -XepExcludedPaths:.*gson/src/test.*|.*extras/src/test.*|.*proto.*</arg>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eventually we might want to have the tests pass Error Prone too, but I agree that is a much lower priority.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

@Marcono1234 Marcono1234 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry to bring this up again, but would you mind fixing (respectively removing) the incorrect @SuppressWarnings("TruthSelfEquals") suppressions as mentioned in https://github.com/google/gson/pull/2308/files#r1096471723 (simply change it to a.equals(a) for now)? The warnings are true-positives; regardless of whether guava-testlib will be added in the future, the current test code on master is incorrect and the @SuppressWarnings hide that, suggesting the code is correct.

My concern is that we forget about this, or for whatever reason guava-testlib is not integrated, and in that case the incorrect code remains unnoticed.

@@ -98,7 +98,7 @@
<compilerArgs>
<!-- Args related to Error Prone, see: https://errorprone.info/docs/installation#maven -->
<arg>-XDcompilePolicy=simple</arg>
<arg>-Xplugin:ErrorProne</arg>
<arg>-Xplugin:ErrorProne -XepExcludedPaths:.*gson/src/test.*|.*extras/src/test.*|.*proto.*</arg>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it intended that you disable warnings for the complete proto module? Maybe it would be better to only disable warnings for the generated source code, as suggested in #2308 (comment).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to go ahead and merge this anyway, but we could indeed consider refining the pattern here.

Copy link
Member

@eamonnmcmanus eamonnmcmanus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm merging this snapshot under the assumption that if there are further changes in the pipeline they can just be applied in a followup PR.

@@ -98,7 +98,7 @@
<compilerArgs>
<!-- Args related to Error Prone, see: https://errorprone.info/docs/installation#maven -->
<arg>-XDcompilePolicy=simple</arg>
<arg>-Xplugin:ErrorProne</arg>
<arg>-Xplugin:ErrorProne -XepExcludedPaths:.*gson/src/test.*|.*extras/src/test.*|.*proto.*</arg>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to go ahead and merge this anyway, but we could indeed consider refining the pattern here.

@eamonnmcmanus eamonnmcmanus changed the title Fix error prone warns Fix error prone warnings Feb 15, 2023
@eamonnmcmanus eamonnmcmanus merged commit 2658aca into google:master Feb 15, 2023
@MaicolAntali MaicolAntali deleted the fix-error-prone-warns branch February 15, 2023 15:07
tibor-universe pushed a commit to getuniverse/gson that referenced this pull request Sep 14, 2024
* Fix `OperatorPrecedence` warn in `JsonWriter#close`

* Fix `ReferenceEquality` warn in `LinkedTreeMap#replaceInParent`

* Fix `UnnecessaryParentheses` warn in `LinkedTreeMap#replaceInParent`

* Fix `ReferenceEquality` warn in `LinkedTreeMap#hasNext`

* Fix `ReferenceEquality` warn in `LinkedTreeMap#nextNode`

* Adds `error_prone_annotations` to the `pom.xml` of `gson`

* Fix `InlineMeSuggester` warns in `JsonParser`

* Fix `UnnecessaryParentheses` warns in `ConstructorConstructor#newDefaultImplementationConstructor`

* Fix `ThreadLocalUsage` warn in `Gson`

* Fix `JdkObsolete` warn in `GsonBuilder`

* Fix `ReferenceEquality` warn in `LazilyParsedNumber#equals`

* Fix `OperatorPrecedence` warn in `TreeTypeAdapter#create`

* Fix `OperatorPrecedence` warn in `ArrayTypeAdapter`

* Fix `UnnecessaryParentheses` warn in `TypeAdapters`

* Adds `-XepExcludedPaths` flag to ErrorProne plugin to exclude tests and proto path

* Fix `ClassNewInstance` warn in `InterceptorAdapter`

* Fix `ThreadLocalUsage` warn in `GraphAdapterBuilder`

* Fix `JdkObsolete` warn in `GraphAdapterBuilder`

* Revert "Adds `error_prone_annotations` to the `pom.xml` of `gson`"

This reverts commit 14af14d.

* Revert "Fix `InlineMeSuggester` warns in `JsonParser`"

This reverts commit 095bfd5.

* Adds `@SuppressWarnings("ThreadLocalUsage")`

* Fix `OperatorPrecedence` in `JsonWriter`

* Revert "Fix `ReferenceEquality` warn in `LinkedTreeMap#nextNode`"

This reverts commit 387746c.

* Adds `@SuppressWarnings("ReferenceEquality")`

* Adds `guava-testlib` to the gson `pom.xml`

* `@SuppressWarnings("TruthSelfEquals")` removed to use `EqualsTester()`
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.

4 participants