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

Fixing some SonarLint findings. #580

Merged
merged 3 commits into from
Apr 16, 2024

Conversation

gregschohn
Copy link
Collaborator

Description

Fixing some SonarLint findings.

  • Category Code Cleanup
  • What is the old behavior before changes and new behavior after changes? There should be no behavioral changes

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

  • New functionality includes testing
    • All tests pass, including unit test, integration test and doctest
  • New functionality has been documented
  • Commits are signed per the DCO using --signoff

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.

Copy link

codecov bot commented Apr 15, 2024

Codecov Report

Attention: Patch coverage is 58.82353% with 14 lines in your changes are missing coverage. Please review.

Project coverage is 75.53%. Comparing base (ffd5066) to head (eac17ba).
Report is 59 commits behind head on main.

Files Patch % Lines
...search/migrations/replay/datatypes/RawPackets.java 0.00% 5 Missing ⚠️
...ions/trafficcapture/netty/PassThruHttpHeaders.java 0.00% 2 Missing ⚠️
.../datatypes/TimeToResponseFulfillmentFutureMap.java 0.00% 2 Missing ⚠️
...tions/trafficcapture/netty/LoggingHttpHandler.java 0.00% 0 Missing and 1 partial ⚠️
...fficcapture/proxyserver/netty/BacksideHandler.java 0.00% 1 Missing ⚠️
...org/opensearch/migrations/replay/KafkaPrinter.java 0.00% 1 Missing ⚠️
...nsearch/migrations/replay/TrafficReplayerCore.java 75.00% 1 Missing ⚠️
...ns/replay/traffic/source/InputStreamOfTraffic.java 0.00% 1 Missing ⚠️
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     
Flag Coverage Δ
unittests 75.53% <58.82%> (-0.52%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


@Override
public int hashCode() {
int result = 29;
Copy link
Member

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

Copy link
Member

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());

Copy link
Collaborator Author

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);

@gregschohn gregschohn merged commit e5aafc6 into opensearch-project:main Apr 16, 2024
5 of 7 checks passed
@gregschohn gregschohn deleted the LintingApril2024 branch April 16, 2024 13:36
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