Add ForbiddenPublicSealedClass detekt rule#3503
Draft
tonidero wants to merge 1 commit into
Draft
Conversation
Public sealed classes and interfaces in SDK public APIs are a binary compatibility hazard: adding a new subclass breaks any exhaustive `when` in consumer code. This adds a custom `:detekt-rules` module with a `ForbiddenPublicSealedClass` rule that mirrors the existing `ForbiddenPublicDataClass` enforcement, suppressed via `@InternalRevenueCatAPI`. Pre-existing violations are baselined. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3503 +/- ##
=======================================
Coverage 79.89% 79.89%
=======================================
Files 369 369
Lines 14871 14871
Branches 2048 2048
=======================================
Hits 11881 11881
Misses 2157 2157
Partials 833 833 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Summary
:detekt-rulesGradle module with a customForbiddenPublicSealedClassdetekt rulepublic sealed classandpublic sealed interfacedeclarations in non-example paths, unless annotated with@InternalRevenueCatAPIForbiddenPublicDataClassenforcement pattern fromdetekt-rules-librariesinternalclasses (e.g.SubscriberAttributeKeysubtypes)Why: Adding a new subclass to a public sealed class/interface is a binary-incompatible change — any exhaustive
whenin consumer code breaks at runtime. Catching this at lint time prevents accidental API breakage.Baselined pre-existing violations (to be addressed in follow-up PRs if needed):
AmazonPurchasingData,GalaxyPurchasingData,GooglePurchasingDataRedeemWebPurchaseListener.ResultPaywallResult,PaywallFont,PurchaseLogicResultPurchases.DeepLink(custom entitlement computation variant)Test plan
./gradlew detektAllpasses with no new violationspublic sealed classwithout@InternalRevenueCatAPIinpurchases/src/main/kotlin/causesdetektAllto fail@InternalRevenueCatAPIto that class suppresses the violationinternalclasses are not flagged🤖 Generated with Claude Code