Skip to content

Mobile-178: Add custom detekt rules for Gson @SerializedName enforcement#718

Merged
sergeysozinov merged 5 commits into
developfrom
feature/MOBILE-178-detekt
May 26, 2026
Merged

Mobile-178: Add custom detekt rules for Gson @SerializedName enforcement#718
sergeysozinov merged 5 commits into
developfrom
feature/MOBILE-178-detekt

Conversation

@sergeysozinov
Copy link
Copy Markdown
Collaborator

Copilot AI review requested due to automatic review settings May 25, 2026 09:09
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-rules module 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 class constructor properties with @SerializedName and 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.

Copilot AI review requested due to automatic review settings May 25, 2026 12:55
@sergeysozinov sergeysozinov requested a review from enotniy May 25, 2026 12:57
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 17 out of 17 changed files in this pull request and generated 2 comments.

Comment thread sdk/src/main/java/cloud/mindbox/mobile_sdk/DetektSmokeTest.kt Outdated
Comment thread .github/workflows/lint_unitTests_build.yml
@sergeysozinov sergeysozinov merged commit f7d52fc into develop May 26, 2026
6 checks passed
@sergeysozinov sergeysozinov deleted the feature/MOBILE-178-detekt branch May 26, 2026 13:09
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