Modern-Apps.git
Publicgit clone https://git.maproj.org/Modern-Apps.gitModern-Apps.git / lint-rules / AGENTS.md
| 1 | # AGENTS.md — lint-rules/ (':lint-rules') |
| 2 | |
| 3 | > Scoped supplement. Global rules in root `AGENTS.md` apply. Stay inside `lint-rules/` + allowed shared modules. Do not root-scan. |
| 4 | |
| 5 | <!-- last-reviewed: 2026-10-16 --> |
| 6 | - Gradle: :lint-rules / dir: lint-rules/ |
| 7 | - Package roots present: (custom lint detectors — `com.vayunmathur.lint` package) |
| 8 | - Entry files: ModernAppsIssueRegistry.kt (no MainActivity/Route — lint registry) |
| 9 | - Deps: (lint APIs only) |
| 10 | - Metadata: metadata_data/lint-rules.md (absent — infra has none by design) |
| 11 | - Rust: no / screenshotTest: no |
| 12 | |
| 13 | ## Overview |
| 14 | **Purpose:** Custom Android-lint detectors enforcing repo conventions at build time — the executable form of root `AGENTS.md` §2. Fatal detectors break the build; advisory ones warn. |
| 15 | **Fatal:** `ToastUsage` (no `Toast` — use messenger), `DirectComposeAnimation` (no raw animation at call sites), `FileLength`, `DirectAndroidLog` (no `androidx.room.`/`android.util.Log` literals), plus comment-hygiene detectors (`CommentedOutCode`, `ExceptionMarkerFormat`, `TodoEvasion` with `CommentOnlyMatcher`). |
| 16 | **Advisory:** `DirectBuildDatabase` (subclass `RoomRepository`), `OneComposablePerFile`, `PackageStructure` (closed roots), `RawScaffoldInApp` (use `AppScaffold`), `Room2Usage` (Room 3 only), `WindowInsetsInReusableComponent` (no padding in `library.ui`). |
| 17 | **Entry points:** `ModernAppsIssueRegistry.kt` → the detector for your rule → `LintPackageExclusions.kt` for scope. |
| 18 | **Gotchas:** New detectors need registry entries + severity decisions (fatal vs advisory is a deliberate call). Fix code to green modules, never relax config (`detekt.yml` rationale is inline per the root card). |
| 19 | |
| 20 | ## Key files |
| 21 | - com/vayunmathur/lint/ModernAppsIssueRegistry.kt — registry (all detectors listed here) |
| 22 | - com/vayunmathur/lint/ToastDetector.kt — fatal Toast ban |
| 23 | - com/vayunmathur/lint/DirectComposeAnimationDetector.kt — fatal raw-animation ban |
| 24 | - com/vayunmathur/lint/FileLengthDetector.kt — fatal file length |
| 25 | - com/vayunmathur/lint/DirectBuildDatabaseDetector.kt — RoomRepository rule |
| 26 | - com/vayunmathur/lint/Room2UsageDetector.kt — Room 3 rule |
| 27 | - com/vayunmathur/lint/RawScaffoldInAppDetector.kt — AppScaffold rule |
| 28 | - com/vayunmathur/lint/PackageStructureDetector.kt — closed-roots rule |
| 29 | - com/vayunmathur/lint/OneComposablePerFileDetector.kt |
| 30 | - com/vayunmathur/lint/WindowInsetsInReusableComponentDetector.kt |
| 31 | - com/vayunmathur/lint/CommentedOutCodeDetector.kt — comment hygiene |
| 32 | - com/vayunmathur/lint/ExceptionMarkerFormatDetector.kt — escape-hatch marker format |
| 33 | - com/vayunmathur/lint/TodoEvasionDetector.kt — TODO discipline |
| 34 | - com/vayunmathur/lint/CommentOnlyMatcher.kt — shared matcher for comment detectors |
| 35 | - com/vayunmathur/lint/LintPackageExclusions.kt — detector scoping |
| 36 | |
| 37 | ## Verify (this module only) |
| 38 | ``` |
| 39 | ./gradlew :lint-rules:compileDevKotlin |
| 40 | ./gradlew :lint-rules:lint |
| 41 | ``` |