Mobile-178: Add custom detekt rules for Gson @SerializedName enforcement#718
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces a project-wide Detekt setup with a custom ruleset to enforce @SerializedName on Gson-serialized Kotlin data class constructor properties (to prevent field-name issues after shrinking/obfuscation), and updates several SDK DTOs/wrappers to satisfy the new enforcement.
Changes:
- Added a new
:detekt-rulesmodule providing custom Detekt rules (GsonMissingSerializedName,UnmonitoredGsonWrapper) with unit tests and RuleSet registration. - Wired Detekt into the build (plugin + config + custom rules plugin dependency) and CI (runs
detektDebug). - Annotated multiple Gson-serialized SDK
data classconstructor properties with@SerializedNameand added targeted suppressions for generic Gson wrappers that the SDK cannot strictly validate.
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| settings.gradle | Registers the new :detekt-rules module in the build. |
| modulesCommon.gradle | Applies Detekt plugin, points to detekt.yml, and loads the custom rules plugin into Detekt. |
| gradle/libs.versions.toml | Adds Detekt version and coordinates for the Gradle plugin + detekt API/test deps. |
| detekt.yml | Adds Detekt configuration enabling only the custom mindbox ruleset/rules. |
| .github/workflows/lint_unitTests_build.yml | Adds a CI step to run ./gradlew detektDebug. |
| detekt-rules/build.gradle | Defines the JVM module used to build the custom Detekt rules and tests. |
| detekt-rules/src/main/kotlin/cloud/mindbox/detekt/MindboxRuleSetProvider.kt | Registers the custom rules in a Detekt RuleSet. |
| detekt-rules/src/main/kotlin/cloud/mindbox/detekt/GsonSerializedNameRule.kt | Implements the GsonMissingSerializedName rule using type resolution to trace Gson usage and enforce @SerializedName. |
| detekt-rules/src/main/kotlin/cloud/mindbox/detekt/UnmonitoredGsonWrapperRule.kt | Implements the UnmonitoredGsonWrapper rule to flag new generic Gson wrappers not covered by monitoring. |
| detekt-rules/src/main/resources/META-INF/services/io.gitlab.arturbosch.detekt.api.RuleSetProvider | Service registration so Detekt discovers the custom RuleSetProvider. |
| detekt-rules/src/test/kotlin/cloud/mindbox/detekt/GsonSerializedNameRuleTest.kt | Test coverage for the GsonMissingSerializedName rule. |
| detekt-rules/src/test/kotlin/cloud/mindbox/detekt/UnmonitoredGsonWrapperRuleTest.kt | Test coverage for the UnmonitoredGsonWrapper rule. |
| sdk/src/main/java/cloud/mindbox/mobile_sdk/pushes/PushToken.kt | Adds @SerializedName to persisted token DTO and suppresses the generic Gson wrapper rule for a constrained use case. |
| sdk/src/main/java/cloud/mindbox/mobile_sdk/models/operation/response/InAppConfigResponse.kt | Adds missing @SerializedName annotations for fields participating in Gson serialization. |
| sdk/src/main/java/cloud/mindbox/mobile_sdk/models/operation/CustomFields.kt | Documents the @SerializedName requirement for caller-supplied types and suppresses generic wrapper detection. |
| sdk/src/main/java/cloud/mindbox/mobile_sdk/managers/MindboxEventManager.kt | Suppresses generic wrapper detection for a client-supplied request body type. |
| sdk/src/main/java/cloud/mindbox/mobile_sdk/inapp/domain/models/InAppFailuresWrapper.kt | Adds @SerializedName to the Gson-serialized wrapper field. |
| sdk/src/main/java/cloud/mindbox/mobile_sdk/inapp/domain/models/GeoTargeting.kt | Adds @SerializedName to all Gson-serialized constructor properties. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
added 2 commits
May 25, 2026 14:43
enotniy
reviewed
May 26, 2026
enotniy
approved these changes
May 26, 2026
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.
https://tracker.yandex.ru/MOBILE-178