Modern-Apps.git
Publicgit clone https://git.maproj.org/Modern-Apps.gitModern-Apps.git / lint-rules / src / main / java / com / vayunmathur / lint / LintPackageExclusions.kt
LintPackageExclusions.kt45 lines · 2.3 KiBRaw
| 1 | package com.vayunmathur.lint |
| 2 | |
| 3 | /** |
| 4 | * Package prefixes that are exempt from the app-structure lints |
| 5 | * ([PackageStructureDetector] and [OneComposablePerFileDetector]). |
| 6 | * |
| 7 | * Both rules encode APP conventions — the closed canonical root allow-list and |
| 8 | * one public @Composable per screen file. The prefixes below are NOT apps, so |
| 9 | * those conventions do not apply and must be skipped by both detectors (kept in |
| 10 | * one place so the two stay in sync): |
| 11 | * - `com.vayunmathur.library` — shared UI/util library. `library/ui` is a |
| 12 | * Material + icon shim that is intentionally many-composables-per-file |
| 13 | * (e.g. Icons.kt, MaterialComponents.kt), and its flat package layout is |
| 14 | * not the app root structure. |
| 15 | * - `com.vayunmathur.e2ee` — shared end-to-end-encryption library |
| 16 | * (`library/e2ee-p2p`); a flat crypto API package, not an app root. |
| 17 | * - `com.vayunmathur.sdk` — shared SDK modules. |
| 18 | * - `com.vayunmathur.cast.protocol` - the MA Cast wire format (`cast/protocol`), shared by the |
| 19 | * phone and the TV app. A flat protocol package like `e2ee`, not an app root: it holds no |
| 20 | * screens, and `protocol` is the module name rather than a package the app chose. |
| 21 | * - `com.vayunmathur.auto.protocol` - the Google Automotive Link wire format |
| 22 | * (`auto/protocol`). Same shape and same reasoning as `cast.protocol`: framing, TLS and |
| 23 | * the generated protobuf, deliberately free of Android and of screens. |
| 24 | * - `com.vayunmathur.games` — games use their own UI structure; the |
| 25 | * one-public-composable-per-file splits were deliberately deferred. |
| 26 | * - `com.vayunmathur.tools` — internal tooling, not shipped apps. |
| 27 | * - `com.vayunmathur.personal` — personal/scratch modules. |
| 28 | */ |
| 29 | object LintPackageExclusions { |
| 30 | |
| 31 | val EXCLUDED_PREFIXES: List<String> = listOf( |
| 32 | "com.vayunmathur.library", |
| 33 | "com.vayunmathur.e2ee", |
| 34 | "com.vayunmathur.sdk", |
| 35 | "com.vayunmathur.cast.protocol", |
| 36 | "com.vayunmathur.auto.protocol", |
| 37 | "com.vayunmathur.games", |
| 38 | "com.vayunmathur.tools", |
| 39 | "com.vayunmathur.personal", |
| 40 | ) |
| 41 | |
| 42 | /** True if [packageName] is (or is nested under) an excluded module prefix. */ |
| 43 | fun isExcluded(packageName: String): Boolean = |
| 44 | EXCLUDED_PREFIXES.any { packageName == it || packageName.startsWith("$it.") } |
| 45 | } |