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

Remove hashCode calls on arrays #128

Merged
merged 4 commits into from
Jun 26, 2023

Conversation

AlekSimpson
Copy link
Contributor

@AlekSimpson AlekSimpson commented Jun 22, 2023

What's changed?

This is related to my other PR. @timtebeek suggested to me that I split the recipe because the toString() part required more checks since toString() is such a widely used method. This recipe basically does the same thing but on a smaller scale for hashCode() calls on array instances.

What's your motivation?

#44

Anything in particular you'd like reviewers to focus on?

I think this recipe should be finished but maybe there are other edge case methods that implicitly call hashCode() I'm forgetting.

Anyone you would like to review specifically?

@timtebeek

Any additional context

RSPEC-2116

Checklist

  • I've added unit tests to cover both positive and negative cases
  • I've added the license header to any new files through ./gradlew licenseFormat
  • I've used the IntelliJ auto-formatter on affected files
  • I've updated the documentation (if applicable)

@AlekSimpson AlekSimpson self-assigned this Jun 22, 2023
@AlekSimpson AlekSimpson marked this pull request as draft June 22, 2023 19:11
@timtebeek timtebeek requested a review from joanvr June 22, 2023 19:14
@timtebeek timtebeek marked this pull request as ready for review June 22, 2023 19:40
@rpau rpau linked an issue Jun 23, 2023 that may be closed by this pull request
@timtebeek timtebeek changed the title Alek/remove hash code calls from array instances Remove hashCode calls on arrays Jun 26, 2023
- Remove `Preconditions.or` for single element
- Collapse `if` statements for select type check
- Inline `builder_string`, as variable name does not conform to Java standards & limited use & scope allows for inlining
- Remove unnecessary elements from test cases to prevent confusion
- Remove public visibility from test class
@timtebeek timtebeek merged commit a6e524c into main Jun 26, 2023
1 check passed
@timtebeek timtebeek deleted the alek/RemoveHashCodeCallsFromArrayInstances branch June 26, 2023 09:56
@timtebeek
Copy link
Contributor

Merged after some small clean ups in 1d9871f ; thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

hashCode and toString should not be called on array instances. RSPEC-2116
2 participants