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

SOLR-16427: Evaluate and fix errorprone rules #1037

Merged
merged 2 commits into from
Sep 22, 2022

Conversation

risdenk
Copy link
Contributor

@risdenk risdenk commented Sep 22, 2022

https://issues.apache.org/jira/browse/SOLR-16427

Enables the following errorprone rules:

  • ArrayEquals
  • ArrayHashCode
  • ArrayToString
  • CollectionUndefinedEquality
  • EqualsIncompatibleType
  • FormatString
  • UndefinedEquals

Most of the fixes are straight forward - use .equals and Objects.equals where appropriate. Used contentEquals for char sequences. Make sure to compare Instant instead of just Date. Ensure proper string format number of arguments. Make sure to use proper Array methods for hashCode and toString

@risdenk risdenk self-assigned this Sep 22, 2022
@risdenk
Copy link
Contributor Author

risdenk commented Sep 22, 2022

Tests pass with these changes and pass ./gradlew check -Pvalidation.errorprone=true

@epugh
Copy link
Contributor

epugh commented Sep 22, 2022

I'm hoping to rerun the warnings report from IntelliJ with a before and after this PR, as I suspect these fixes will directly impact those warnings! I love how you are enabling errorprone for these.. I never quite cracked "how to prevent them from coming back" with my work on SOLR-16222.

@risdenk risdenk changed the title enable more errorprone rules and fix those things that fail SOLR-16427: Evaluate and fix errorprone rules Sep 22, 2022
@risdenk risdenk marked this pull request as ready for review September 22, 2022 14:21
Copy link
Contributor

@epugh epugh left a comment

Choose a reason for hiding this comment

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

LGTM

@risdenk risdenk merged commit 83de120 into apache:main Sep 22, 2022
@risdenk risdenk deleted the errorprone-fixes branch September 22, 2022 19:42
risdenk added a commit that referenced this pull request Sep 23, 2022
Enables the following errorprone rules:
* `ArrayEquals`
* `ArrayHashCode`
* `ArrayToString`
* `CollectionUndefinedEquality`
* `EqualsIncompatibleType`
* `FormatString`
* `UndefinedEquals`

Most of the fixes are straight forward - use `.equals` and `Objects.equals` where appropriate. Used `contentEquals` for char sequences. Make sure to compare `Instant` instead of just `Date`. Ensure proper string format number of arguments. Make sure to use proper Array methods for `hashCode` and `toString`
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