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 | - Gradle: :lint-rules / dir: lint-rules/ |
| 6 | - Package roots present: (custom lint detectors — `com.vayunmathur.lint` package) |
| 7 | - Entry files: ModernAppsIssueRegistry.kt (no MainActivity/Route — lint registry) |
| 8 | - Deps: (lint APIs only) |
| 9 | - Metadata: metadata_data/lint-rules.md (absent — infra has none by design) |
| 10 | - Rust: no / screenshotTest: no |
| 11 | |
| 12 | ## Overview |
| 13 | **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. |
| 14 | **Blocking:** every Modern-Apps detector is fatal in the app and library conventions. That includes `ToastUsage` (no `Toast` — use messenger), `DirectComposeAnimation` (no raw animation at call sites), `FileLength`, `DirectAndroidLog` (no direct `android.util.Log`), `DirectBuildDatabase` (subclass `RoomRepository`), `OneComposablePerFile`, `PackageStructure` (closed roots and flat `widget`), `RawScaffoldInApp` (use `AppScaffold`), `ScaffoldLoading` (scaffold owns refresh indication; standalone loading icons in app UI flagged), `ScaffoldSearch` (scaffold owns screen-level search via its `search` parameter; standalone `CommonSearchBar`/`SearchBar`/`SearchBarInputField` and reliably search-identified text fields in app UI flagged, exception marker `// SCAFFOLD SEARCH EXCEPTION: <reason>` for dialog/sheet/drawer-local and expandable-overlay search), `Room2Usage` (Room 3 only), `RouteScreenshotCoverage` (every `Route` leaf needs a screenshot capture), `DialogAsRoute` (dialogs are `Route` destinations with `DialogPage()` metadata, not `remember`-state-gated `AlertDialog`/`Dialog`/`ModalBottomSheet`/`ConfirmDialog`/`…Dialog` calls in screens; definitions under `ui/dialogs/` and unconditional route-entry hosts are legal, escape `// DIALOG LOCAL EXCEPTION: <reason>`), `WindowInsetsInReusableComponent` (no padding in `library.ui`), `FixtureDeterminism` (no relative-now/unseeded randomness in `src/test` + `src/screenshotTest` fixtures; named fixed constants or seeded `Random(seed)` instead, deadline/elapsed/freshness idioms in unit tests excluded, escape `// FIXTURE RELATIVE-TIME EXCEPTION: <reason>`), `NoDeadClick` (no empty/comment-only `onClick` on Button/IconButton/FAB/MenuItem/ListItem-clickable in `src/main` unless `enabled = false`; label chips excluded by widget type, escape `// DEAD CLICK EXCEPTION: <reason>` for drag handles), and the comment-hygiene detectors (`CommentedOutCode`, `ExceptionMarkerFormat`, `TodoEvasion` with `CommentOnlyMatcher`). |
| 15 | **Entry points:** `ModernAppsIssueRegistry.kt` → the detector for your rule → `LintPackageExclusions.kt` for scope. |
| 16 | **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). |
| 17 | |
| 18 | ## Key files |
| 19 | - com/vayunmathur/lint/ModernAppsIssueRegistry.kt — registry (all detectors listed here) |
| 20 | - com/vayunmathur/lint/ToastDetector.kt — fatal Toast ban |
| 21 | - com/vayunmathur/lint/DirectComposeAnimationDetector.kt — fatal raw-animation ban |
| 22 | - com/vayunmathur/lint/FileLengthDetector.kt — fatal file length |
| 23 | - com/vayunmathur/lint/DirectBuildDatabaseDetector.kt — RoomRepository rule |
| 24 | - com/vayunmathur/lint/Room2UsageDetector.kt — Room 3 rule |
| 25 | - com/vayunmathur/lint/RawScaffoldInAppDetector.kt — AppScaffold rule |
| 26 | - com/vayunmathur/lint/ScaffoldLoadingDetector.kt — scaffold-owned loading rule |
| 27 | - com/vayunmathur/lint/ScaffoldSearchDetector.kt — scaffold-owned search 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/RouteScreenshotCoverageDetector.kt — route screenshot coverage |
| 36 | - com/vayunmathur/lint/DialogAsRouteDetector.kt — dialogs-as-routes rule |
| 37 | - com/vayunmathur/lint/FixtureDeterminismDetector.kt — deterministic test/screenshot fixtures (disk scan of `src/test` + `src/screenshotTest` in `afterCheckProject`) |
| 38 | - com/vayunmathur/lint/NoDeadClickDetector.kt — empty click handlers on clickable widgets in `src/main` |
| 39 | - com/vayunmathur/lint/LintPackageExclusions.kt — detector scoping |
| 40 | |
| 41 | ## Verify (this module only) |
| 42 | ``` |
| 43 | ./gradlew :lint-rules:compileDevKotlin |
| 44 | ./gradlew :lint-rules:lint |
| 45 | ``` |