Skip to content

refactor(server): Drop redundant equals/hashCode from data classes#499

Merged
marandaneto merged 1 commit intoPostHog:mainfrom
saunter511:refactor/drop-redundant-equals-hashcode
Apr 29, 2026
Merged

refactor(server): Drop redundant equals/hashCode from data classes#499
marandaneto merged 1 commit intoPostHog:mainfrom
saunter511:refactor/drop-redundant-equals-hashcode

Conversation

@saunter511
Copy link
Copy Markdown
Contributor

@saunter511 saunter511 commented Apr 27, 2026

💡 Motivation and Context

FeatureFlagCacheEntry and FeatureFlagCacheKey are data classes. Kotlin auto-generates equals() and hashCode().
The manual overrides duplicated this logic and required manual updates whenever fields were added (see commits 472cc44 and 74b4f49 in FeatureFlagCacheEntry).
Removing them reduces the maintenance surface and makes the code more Kotlin idiomatic.

💚 How did you test it?

  • Unit tests
  • Compiler checks

📝 Checklist

  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • I updated the docs if needed.
  • No breaking change or entry added to the changelog.

If releasing new changes

  • Ran pnpm changeset to generate a changeset file
  • Added the "release" label to the PR to indicate we're publishing new versions for the affected packages

@saunter511 saunter511 requested a review from a team as a code owner April 27, 2026 21:34
@marandaneto
Copy link
Copy Markdown
Member

@dustinbyrne do you remember why you added custom equals and hashcodes if dataclasses generate them?

@marandaneto
Copy link
Copy Markdown
Member

@dustinbyrne
Copy link
Copy Markdown
Contributor

This is either an artifact from before the server-side SDK had distinct animal sniffer rules or a copy-paste from core to this library. I see no reason we should keep it 👍

@saunter511 saunter511 force-pushed the refactor/drop-redundant-equals-hashcode branch from 585116f to fabaa08 Compare April 29, 2026 19:24
FeatureFlagCacheEntry and FeatureFlagCacheKey are data classes. Kotlin
auto-generates equals() and hashCode(). The manual overrides duplicated
this logic and required manual updates whenever fields were added (see
commits 472cc44 and 74b4f49 in FeatureFlagCacheEntry). Removing them reduces
the maintenance surface and makes the code more Kotlin idiomatic.
@saunter511 saunter511 force-pushed the refactor/drop-redundant-equals-hashcode branch from fabaa08 to 4a7f73f Compare April 29, 2026 19:25
@saunter511 saunter511 requested a review from marandaneto April 29, 2026 20:10
@saunter511
Copy link
Copy Markdown
Contributor Author

@marandaneto Added the changeset.

@marandaneto marandaneto enabled auto-merge (squash) April 29, 2026 20:24
@marandaneto marandaneto merged commit a11db4b into PostHog:main Apr 29, 2026
12 checks passed
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.

3 participants