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

None yet

4 participants