-
Notifications
You must be signed in to change notification settings - Fork 30
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
Fixing some SonarLint findings. #580
Fixing some SonarLint findings. #580
Conversation
Signed-off-by: Greg Schohn <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #580 +/- ##
============================================
- Coverage 76.05% 75.53% -0.52%
+ Complexity 1499 1491 -8
============================================
Files 162 162
Lines 6339 6357 +18
Branches 563 569 +6
============================================
- Hits 4821 4802 -19
- Misses 1143 1179 +36
- Partials 375 376 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
|
||
@Override | ||
public int hashCode() { | ||
int result = 29; |
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.
I don't love these magic numbers, would prefer some constants here
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.
Discussed offline, i'll leave it up to Greg on whether or not to use Arrays.hashCode(toArray());
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.
I'm much more comfortable with 2 primes for a hash function than doing an copy.
Honestly, I'd rather see this as a one-liner map-reduce operation like this, but most hashCode operations, especially those generated by IDEs and code generators (we have a lot of protobuf generated ones in out captureProtobufs package).
return stream().mapToInt(Arrays::hashCode).reduce(29, (a,b) -> 31*a+b);
Description
Fixing some SonarLint findings.
Issues Resolved
https://opensearch.atlassian.net/browse/MIGRATIONS-1635
Is this a backport? If so, please add backport PR # and/or commits #
Testing
Unit tests
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.