fix(sonar): array-aware equals/hashCode/toString on ZstdEncodingEncoder records#175
Merged
Conversation
…er records SonarCloud flagged the private FrameLayout (long[] components) and Frames (byte[] metadata) records as reliability bugs (java:S6218): a record with array components gets a default equals/hashCode that compares array identity, not content. Both are BUG-severity and fail the new-code reliability gate. Fix by overriding equals/hashCode/toString with Arrays.equals/hashCode/toString (and Objects for the List/scalar fields) so they consider array content, rather than suppressing the rule. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
c45b841 to
c8efd73
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On-demand SonarCloud run on main failed the quality gate: new_reliability_rating = C (ERROR), from 2
java:S6218BUGs inZstdEncodingEncoder:FrameLayout(long[]components)Frames(byte[] metadata)S6218 fires because a record with array components gets a default
equals/hashCodethat compares array identity, not content — a latent reliability bug if the records are ever value-compared.Fixed by overriding
equals/hashCode/toStringwithArrays.equals/hashCode/toString(andObjectsfor theList/scalar fields), so the records consider array content — rather than suppressing the BUG.Clears the new-code reliability gate. No behavior change to the encode path.
🤖 Generated with Claude Code