apps-android-commons icon indicating copy to clipboard operation
apps-android-commons copied to clipboard

Fix Detekt Naming convention findings (28 issues)

Open nicolas-raoul opened this issue 1 month ago • 4 comments

Part of the post-#7020 Detekt static analysis cleanup.

Scope

Fix the following Detekt findings and remove their <ID> entries from app/detekt-baseline.xml:

  • VariableNaming (12 findings)
  • MemberNameEqualsClassName (5 findings)
  • FunctionNaming (4 findings)
  • FunctionParameterNaming (4 findings)
  • TopLevelPropertyNaming (2 findings)
  • MatchingDeclarationName (1 finding)

Steps

  1. Delete the matching <ID>... lines from app/detekt-baseline.xml.
  2. Run ./gradlew :app:detekt to see the exact file and line locations of each violation.
  3. Fix the violations in code. Rename identifiers to follow Kotlin camelCase/PascalCase conventions (be careful not to rename fields serialized by Gson/Retrofit unless annotated with @SerializedName).
  4. Manually check that the changes are correct, sensible, and do not break the logic. Keeping some exceptions might make sense sometimes, in that case add a comment explaining why.
  5. Run ./gradlew :app:ktlintCheck :app:detekt testBetaDebugUnitTest and verify all checks pass.
  6. Create a pull request with these changes.

nicolas-raoul avatar Oct 21 '26 02:10 nicolas-raoul

@nicolas-raoul can i work on this ?

devendrachoudharycodes avatar Oct 22 '26 17:10 devendrachoudharycodes

Hi @nicolas-raoul,

Detekt's FunctionNaming rule flags Compose functions like CategoryItem and CategoryItemPreview because they use UpperCamelCase , i.e. what the naming convention for composable functions is.

Would you prefer individual suppressions or configuring Detekt to ignore @Composable functions? I think the configuration approach would be more maintainable for future Compose functions.

What are your thoughts?

devendrachoudharycodes avatar Oct 23 '26 06:10 devendrachoudharycodes

Good catch @devendrachoudharycodes!

Yes, configuring Detekt to ignore @Composable functions is definitely the better and more maintainable approach (as recommended by the Detekt Compose setup guide).

Please add a detekt.yml configuration file (e.g. app/detekt.yml or config/detekt/detekt.yml) wired up via config.setFrom(...) in app/build.gradle.kts (keeping buildUponDefaultConfig = true), with:

naming:
  FunctionNaming:
    ignoreAnnotated: ['Composable']

If you find other relevant rules in the article above, can you also add them too? Thanks!

nicolas-raoul avatar Oct 23 '26 06:10 nicolas-raoul

Hi @nicolas-raoul,

Issue #7051 was automatically closed when PR #7173 merged. Could you please reopen #7051?

My PR #7173 description included "Fixes #7051", which auto-closed the issue, but there are still a few remaining findings from the issue scope that I am submitting in follow-up PRs:

  • FunctionParameterNaming (4 findings) — PR submitted
  • TopLevelPropertyNaming (2 findings in Monuments.kt) — next PR
  • MatchingDeclarationName (1 finding for Costants.kt) — next PR

Thanks!

devendrachoudharycodes avatar Oct 25 '26 07:10 devendrachoudharycodes