Files
sousa-gecko/mobile/android/android-components/components/tooling/detekt
t-p-white a9da1766d7 Bug 2040405 - Add an Android detekt rule to enforce the Kotlin acronym naming convention. r=android-reviewers,marcin
The rule is based on the official [Kotlin coding conventions guidance for acronym naming in classes](https://kotlinlang.org/docs/coding-conventions.html#choose-good-names):
> When using an acronym as part of a declaration name, follow these rules:
>
> * For two-letter acronyms, use uppercase for both letters. For example, IOStream.
> * For acronyms longer than two letters, capitalize only the first letter. For example, XmlFormatter or HttpInputStream.

The intent is to align with Kotlin conventions and maintain a consistent naming approach across the codebase. This does not prevent the use of acronyms such as AMO, CFR, or JSON; it only affects how those acronyms are incorporated into class names.

for example in this contrived class definition, instead of:
```kotlin
class AMOCFRPrompt
```
the preferred form would be:
```kotlin
class AmoCfrPrompt
```
which this rule would help to surface. This is not a proposal to rename existing APIs that do not follow this convention. Rather, it establishes a consistent guideline for new code going forward.

Differential Revision: https://phabricator.services.mozilla.com/D305839
2026-06-17 21:57:55 +00:00
..
…

Android Components > Tooling > Detekt

Custom Detekt rules for the components repository.

These additional detekt rules are run as part of the Android Components build pipeline. Published for internal usage only.

Usage

Add into build.gradle:

dependencies {
    // ...

    detektPlugins "org.mozilla.components:tooling-detekt:$android_components_version"
}

Rules

Section mozilla-rules:

  • AbsentOrWrongFileLicense - check for correct license header in Kotlin files.

Section acorn-detekt-rules:

  • HardcodedPaddingUsage - check for usage of Acorn spacing tokens for padding in Kotlin files.

License

This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/