1use serde_json::Value;
8
9pub struct RuleDef {
11 pub id: &'static str,
14 pub category: &'static str,
21 pub name: &'static str,
23 pub short: &'static str,
25 pub full: &'static str,
27 pub docs_path: &'static str,
30}
31
32pub const CHECK_RULES: &[RuleDef] = &[
34 RuleDef {
35 id: "fallow/unused-file",
36 category: "Dead code",
37 name: "Unused Files",
38 short: "File is not reachable from any entry point",
39 full: "Source files that are not imported by any other module and are not entry points (scripts, tests, configs). These files can safely be deleted. Detection uses graph reachability from configured entry points.",
40 docs_path: "rules/unused-file",
41 },
42 RuleDef {
43 id: "fallow/unused-export",
44 category: "Dead code",
45 name: "Unused Exports",
46 short: "Export is never imported",
47 full: "Named exports that are never imported by any other module in the project. Includes both direct exports and re-exports through barrel files. The export may still be used locally within the same file. An export with a JSDoc tag that `keepExportTags` lists is not reported; the default list is `public`, `internal`, `alpha` and `beta`. A test import keeps an export alive in the default mode; turn on `test-only-export` to report the exports that only test-side files use.",
48 docs_path: "rules/unused-export",
49 },
50 RuleDef {
51 id: "fallow/unused-type",
52 category: "Dead code",
53 name: "Unused Type Exports",
54 short: "Type export is never imported",
55 full: "Type-only exports (interfaces, type aliases, enums used only as types) that are never imported. These do not generate runtime code but add maintenance burden.",
56 docs_path: "rules/unused-type",
57 },
58 RuleDef {
59 id: "fallow/private-type-leak",
60 category: "Dead code",
61 name: "Private Type Leaks",
62 short: "Exported signature references a private type",
63 full: "Exported values or types whose public TypeScript signature references a same-file type declaration that is not exported. Consumers cannot name that private type directly, so the backing type should be exported or removed from the public signature.",
64 docs_path: "rules/private-type-leak",
65 },
66 RuleDef {
67 id: "fallow/deprecated-export-in-use",
68 category: "Dead code",
69 name: "Deprecated Exports in Use",
70 short: "Export marked @deprecated is still referenced",
71 full: "Exports whose leading JSDoc carries @deprecated and that still have at least one consumer in a reachable file. Each finding lists the exact consumer count, a sample of up to 10 consumers sorted by path and line, and the deprecation message. A deprecated export with no consumer is reported as an unused export instead, marked deprecated. A consumer in an unreachable file does not count, because that file is dead code itself. `public_api` is true when the export lives in an entry point or a re-export chain reaches one: external consumers are not visible, so the finding makes no removal claim. The rule is opt-in and defaults to off. A per-path override resolves on the file that declares the export, not on the consumer.",
72 docs_path: "rules/deprecated-export-in-use",
73 },
74 RuleDef {
75 id: "fallow/unused-dependency",
76 category: "Dependencies",
77 name: "Unused Dependencies",
78 short: "Dependency listed but never imported",
79 full: "Packages listed in dependencies that are never imported or required by any source file. A package that only a framework or a CLI tool loads can be reported when no plugin of fallow knows that use. To keep such a package, add it to `ignoreDependencies`.",
80 docs_path: "rules/unused-dependency",
81 },
82 RuleDef {
83 id: "fallow/unused-dev-dependency",
84 category: "Dependencies",
85 name: "Unused Dev Dependencies",
86 short: "Dev dependency listed but never imported",
87 full: "Packages listed in devDependencies that are never imported by test files, config files, or scripts. A build tool or a Jest preset that only a config file names is reported when no plugin of fallow reads that config file. To keep such a package, add it to `ignoreDependencies`.",
88 docs_path: "rules/unused-dev-dependency",
89 },
90 RuleDef {
91 id: "fallow/unused-optional-dependency",
92 category: "Dependencies",
93 name: "Unused Optional Dependencies",
94 short: "Optional dependency listed but never imported",
95 full: "Packages listed in optionalDependencies that are never imported. Optional dependencies are typically platform-specific; verify they are not needed on any supported platform before removing.",
96 docs_path: "rules/unused-optional-dependency",
97 },
98 RuleDef {
99 id: "fallow/type-only-dependency",
100 category: "Dependencies",
101 name: "Type-only Dependencies",
102 short: "Production dependency only used via type-only imports",
103 full: "Production dependencies that are only imported via `import type` statements. These can be moved to devDependencies since they generate no runtime code and are stripped during compilation.",
104 docs_path: "rules/type-only-dependency",
105 },
106 RuleDef {
107 id: "fallow/test-only-dependency",
108 category: "Dependencies",
109 name: "Test-only Dependencies",
110 short: "Production dependency only imported by test files",
111 full: "Production dependencies that are only imported from test files. These can usually move to devDependencies because production entry points do not require them at runtime.",
112 docs_path: "rules/test-only-dependency",
113 },
114 RuleDef {
115 id: "fallow/dev-dependency-in-production",
116 category: "Dependencies",
117 name: "Dev Dependencies Used in Production",
118 short: "devDependency imported by production code with a runtime import",
119 full: "A package in `devDependencies` that is imported by production (non-test, non-config) source code via a runtime/value import. Whether it should be promoted to `dependencies` depends on the deployment: a production-only install (`pnpm install --prod`) omits devDependencies, so an import resolved at runtime breaks, while a build that inlines the package into its output resolves nothing at runtime and promoting it can instead make the deployment require an install it did not need. This is the promote-side mirror of `test-only-dependency` and `type-only-dependency`. A dev dependency imported from production code only via `import type` is not flagged (types are erased at build time), and a package also listed in `dependencies`, `peerDependencies`, or `optionalDependencies` is left alone because another manifest section provides it at runtime.",
120 docs_path: "rules/dev-dependency-in-production",
121 },
122 RuleDef {
123 id: "fallow/unused-enum-member",
124 category: "Dead code",
125 name: "Unused Enum Members",
126 short: "Enum member is never referenced",
127 full: "Enum members that are never referenced in the codebase. Uses scope-aware binding analysis to track all references including computed access patterns.",
128 docs_path: "rules/unused-enum-member",
129 },
130 RuleDef {
131 id: "fallow/unused-class-member",
132 category: "Dead code",
133 name: "Unused Class Members",
134 short: "Class member is never referenced",
135 full: "Public class methods and properties that are never referenced, checked project-wide. Members marked `private` and `#private` members are not checked. Protected members have their own rule, `unused-protected-class-member`.",
136 docs_path: "rules/unused-class-member",
137 },
138 RuleDef {
139 id: "fallow/unused-store-member",
140 category: "Dead code",
141 name: "Unused Store Members",
142 short: "Store member is never accessed by any consumer",
143 full: "Pinia store members (a `state` / `getters` / `actions` key, or a setup-store returned key) declared but never accessed by any consumer project-wide. The store binding is imported (so the module is reachable) yet a specific member is dead. Defaults to warn, not error: a store has an open declaration surface (plugins, dynamic dispatch) so confidence is lower. Activates only when pinia or @pinia/nuxt is a declared dependency.",
144 docs_path: "rules/unused-store-member",
145 },
146 RuleDef {
147 id: "fallow/unused-protected-class-member",
148 category: "Dead code",
149 name: "Unused Protected Class Members",
150 short: "Protected class member is never referenced",
151 full: "Class methods and properties with the `protected` modifier that neither the class nor a subclass reads. A read through `this` or `super` in the class or in a subclass counts as a use. A subclass override counts as used when the base class calls the member. Classes of the public API of a package are not checked, because a consumer can subclass them. Production mode ignores reads in test files. Defaults to off. Known limits: a read through a string key (`this[\"member\"]()`) gives no credit, and a constructor parameter property (`constructor(protected readonly x: X)`) is not checked.",
152 docs_path: "rules/unused-protected-class-member",
153 },
154 RuleDef {
155 id: "fallow/namespace-escape",
156 category: "Dead code",
157 name: "Namespace Escapes",
158 short: "Namespace binding is used as a whole value, so its exports are not checked",
159 full: "A namespace import (`import * as Ns`) that the code uses as a whole value: a cast, an assignment, a call argument, a spread, a computed member read, a reflective call such as `Object.keys(Ns)`, or a re-export with `export { Ns }`. Fallow cannot see which members such a use reads, so it credits every export of the target module and of the modules that the target re-exports from. These exports are then not checked by `unused-exports` and `unused-types`. The finding is on the import and gives the count of exports that the credit hides. A binding that hides no export is not reported. Defaults to off.",
160 docs_path: "rules/namespace-escape",
161 },
162 RuleDef {
163 id: "fallow/test-only-export",
164 category: "Dead code",
165 name: "Test-Only Exports",
166 short: "Export is used only by test-side files",
167 full: "An exported value that production code does not use, while a test-side file does. Test-side files are the files that `--production` leaves out: test, story, fixture and bench files and the `production.ignore` globs, plus the files that only tests reach, such as a test helper. A file that a runtime or support entry reaches, such as a source file that a bundler config names, is production code. In the default mode the tests keep such an export alive, so `unused-export` does not report it. In `--production` mode the same export is an `unused-export` finding, and this rule does not run. One export is never in both kinds in one run. Only values are checked in this version, not types. Entry exports, `keepExportTags`, `ignoreExports` and plugin rules keep an export, as for `unused-export`. The `colocated_only` field is true when each test-side importer is next to the module, which can mean a deliberate internal seam. A test-only use does not make an `@expected-unused` tag stale. Defaults to off.",
168 docs_path: "rules/test-only-export",
169 },
170 RuleDef {
171 id: "fallow/unused-namespace-member",
172 category: "Dead code",
173 name: "Unused Namespace Members",
174 short: "Namespace member is never referenced",
175 full: "Exported members of an exported TypeScript namespace that no code reads. A nested namespace member has a dotted name (`Inner.x`). A whole use of the namespace (an argument, an alias, a spread) counts every member as used. Declaration files, `declare global`, module augmentations and the public API of an entry point are not checked. Defaults to warn.",
176 docs_path: "rules/unused-namespace-member",
177 },
178 RuleDef {
179 id: "fallow/unresolved-import",
180 category: "Dead code",
181 name: "Unresolved Imports",
182 short: "Import could not be resolved",
183 full: "Import specifiers that could not be resolved to a file on disk. Common causes: deleted files, typos in paths, missing path aliases in tsconfig, or uninstalled packages.",
184 docs_path: "rules/unresolved-import",
185 },
186 RuleDef {
187 id: "fallow/unlisted-dependency",
188 category: "Dependencies",
189 name: "Unlisted Dependencies",
190 short: "Dependency used but not in package.json",
191 full: "Packages imported without an applicable dependency declaration in package.json. This includes workspace packages imported from the repository root: npm workspace links make a package resolvable, but do not declare a dependency. Package self-references are allowed. Private packages and tooling may use ancestor declarations; publishable runtime code must declare its own dependencies.",
192 docs_path: "rules/unlisted-dependency",
193 },
194 RuleDef {
195 id: "fallow/unlisted-binary",
196 category: "Dependencies",
197 name: "Unlisted Binaries",
198 short: "Binary used but provided by no installed package",
199 full: "Binaries that package.json scripts or process calls in source (`spawn`, `execSync`, `execa`, the `$` template of zx or execa, `Bun.spawn`) run with a literal command, when no installed or listed package provides them. A binary counts as provided when a `node_modules/.bin` link exists, a declared dependency or a workspace package declares it in `bin`, or it maps to a declared dependency. Shell builtins, commands that `npx` or `pnpm dlx` download, and a fixed list of common operating-system tools are skipped. The check needs installed dependencies and reports nothing without a root `node_modules`. Defaults to warn.",
200 docs_path: "rules/unlisted-binary",
201 },
202 RuleDef {
203 id: "fallow/duplicate-export",
204 category: "Dead code",
205 name: "Duplicate Exports",
206 short: "Export name appears in multiple modules",
207 full: "The same export name is defined in multiple modules. Consumers may import from the wrong module, leading to subtle bugs. Consider renaming or consolidating.",
208 docs_path: "rules/duplicate-export",
209 },
210 RuleDef {
211 id: "fallow/duplicate-export-alias",
212 category: "Dead code",
213 name: "Duplicate Export Aliases",
214 short: "One module exports one binding under two or more names",
215 full: "One module exports the same binding under two or more names, for example `export const layer = make(); export default layer;` or `export { a, a as b }`. Consumers can import one value under several names, so the export surface is larger than it needs to be. Fallow groups the exports of a file by binding: a local binding name, or the source and imported name of a named re-export. Value and type-only exports are separate groups, and a plain specifier of a name that the file declares only as a type joins the type group. Two bindings with the same initializer are two bindings and are not reported. `export *`, files with CommonJS exports (`export =`, `module.exports`), component files and unreachable files are skipped. `ignoreExports` exempts a file with `*`, or a binding when one of its names is listed. Default warn. The rule differs from `duplicate-export`, which reports one export name in several files.",
216 docs_path: "rules/duplicate-export-alias",
217 },
218 RuleDef {
219 id: "fallow/circular-dependency",
220 category: "Architecture",
221 name: "Circular Dependencies",
222 short: "Circular dependency chain detected",
223 full: "A cycle in the module import graph. Circular dependencies cause undefined behavior with CommonJS (partial modules) and initialization ordering issues with ESM. Break cycles by extracting shared code.",
224 docs_path: "rules/circular-dependency",
225 },
226 RuleDef {
227 id: "fallow/re-export-cycle",
228 category: "Architecture",
229 name: "Re-Export Cycles",
230 short: "Two or more barrel files re-export from each other in a loop",
231 full: "A barrel file re-exports from another barrel that ultimately re-exports back. When this happens, imports from any file in the loop may silently come up empty, because the re-export chain has no terminating module to resolve names against. To fix this: open any one file in the loop and remove the `export * from` (or `export { ... } from`) statement that points back into the cycle. Any single removal will break the cycle and restore working re-exports. A self-loop (a single barrel re-exporting from itself, often a rename leftover) is reported under the same rule with kind `self-loop`.",
232 docs_path: "rules/re-export-cycle",
233 },
234 RuleDef {
235 id: "fallow/package-cycle",
236 category: "Architecture",
237 name: "Package Cycles",
238 short: "Two or more workspace packages import each other in a loop",
239 full: "Workspace packages whose resolved imports form a cycle. Each workspace package is a node and each resolved import from one package to another is an edge, so a package cycle can exist when no file-level cycle exists. Imports from test, spec, story, fixture and tooling config files are not edges, because those files are not part of the package build. Packages in a cycle cannot be built in dependency order. Each hop shows one example import and a `type_only` flag; a type-only hop still matters for declaration builds. To fix this, remove the imports on one hop, for example by moving the shared code to a package that both packages import.",
240 docs_path: "rules/package-cycle",
241 },
242 RuleDef {
243 id: "fallow/boundary-violation",
244 category: "Architecture",
245 name: "Boundary Violations",
246 short: "Import crosses a configured architecture boundary",
247 full: "A module imports from a zone that its configured boundary rules do not allow. Boundary checks help keep layered architecture, feature slices, and package ownership rules enforceable.",
248 docs_path: "rules/boundary-violation",
249 },
250 RuleDef {
251 id: "fallow/boundary-coverage",
252 category: "Architecture",
253 name: "Boundary Coverage",
254 short: "Source file matches no configured architecture boundary zone",
255 full: "A reachable source file is not assigned to any configured boundary zone while boundaries.coverage.requireAllFiles is enabled. Add the file to a zone pattern, move it under an existing zone, or allow-list generated and intentionally unzoned paths with boundaries.coverage.allowUnmatched.",
256 docs_path: "rules/boundary-coverage",
257 },
258 RuleDef {
259 id: "fallow/boundary-call-violation",
260 category: "Architecture",
261 name: "Boundary Call Violation",
262 short: "Zoned file calls a callee its zone forbids",
263 full: "A file classified into a boundary zone calls or constructs a callee matching one of the zone's boundaries.calls.forbidden patterns. The check is syntactic: it matches the written callee path and the import-resolved canonical path of calls and new expressions, and it only applies to files classified into a zone. Move the call behind an allowed abstraction, or adjust the zone's forbidden patterns if the rule was wrong.",
264 docs_path: "rules/boundary-call-violation",
265 },
266 RuleDef {
267 id: "fallow/policy-violation",
268 category: "Policy",
269 name: "Policy Violation",
270 short: "Usage violates a configured rule-pack policy",
271 full: "A call, import, export, catalogue-derived effect, or graph-resolved GDP proof producer violates a configured rule pack (the rulePacks config key). Packs are pure declarative data. Call rules match calls and new expressions, on written plus import-resolved canonical callees. Effect rules match calls only. Import rules match the raw specifier. GDP rules trace @gdp-ts/core proof producers through unambiguous re-exports and restrict which files may create proof factories, optionally by exact static proof kind. This is syntactic ownership analysis, not a runtime authorization guarantee. Follow the rule's message, move a producer into an allowed file, scope the rule with files/exclude globs, or adjust its severity.",
272 docs_path: "rules/policy-violation",
273 },
274 RuleDef {
275 id: "fallow/stale-suppression",
276 category: "Suppressions",
277 name: "Stale Suppressions",
278 short: "Suppression comment or tag no longer matches any issue",
279 full: "A fallow-ignore-next-line, fallow-ignore-file, or @expected-unused suppression that no longer matches any active issue. The underlying problem was fixed but the suppression was left behind. Remove it to keep the codebase clean.",
280 docs_path: "rules/stale-suppression",
281 },
282 RuleDef {
283 id: "fallow/missing-suppression-reason",
284 category: "Suppressions",
285 name: "Missing Suppression Reason",
286 short: "Suppression comment omits a required reason",
287 full: "A fallow-ignore-next-line or fallow-ignore-file suppression omits the explanatory reason required by the requireSuppressionReason rule. Add a short reason after the suppression token, or remove the suppression if the issue is no longer intentional.",
288 docs_path: "rules/missing-suppression-reason",
289 },
290 RuleDef {
291 id: "fallow/unused-catalog-entry",
292 category: "Dependencies",
293 name: "Unused catalog entry",
294 short: "Catalog entry not referenced by any workspace package",
295 full: "An entry in a package manager catalog (`pnpm-workspace.yaml` `catalog:` / `catalogs:` or Bun root `package.json` `workspaces.catalog` / `workspaces.catalogs`) that no workspace package.json dependency and no pnpm override (`pnpm-workspace.yaml` `overrides`, skipped when `packageManager` names a pnpm version that ignores it: pnpm before 10.5.1, or pnpm 10 or earlier when the root `package.json` declares non-empty `pnpm.overrides` or `resolutions`; root `package.json` `pnpm.overrides`, skipped when `packageManager` names pnpm 11 or later; root `package.json` `resolutions`, read only when `packageManager` names pnpm 10 or earlier) references via the `catalog:` protocol. Catalog entries are leftover dependency metadata once a package is removed from every consumer; delete the entry to keep the catalog truthful. See also: fallow/unresolved-catalog-reference (the inverse: consumer references a catalog that does not declare the package).",
296 docs_path: "rules/unused-catalog-entry",
297 },
298 RuleDef {
299 id: "fallow/empty-catalog-group",
300 category: "Dependencies",
301 name: "Empty catalog group",
302 short: "Named catalog group has no entries",
303 full: "A named group under `catalogs:` in `pnpm-workspace.yaml` or Bun root `package.json` has no package entries. Empty named groups are leftover catalog structure after the last entry is removed. The default `catalog` map is intentionally ignored because some projects keep it as a stable hook.",
304 docs_path: "rules/empty-catalog-group",
305 },
306 RuleDef {
307 id: "fallow/unresolved-catalog-reference",
308 category: "Dependencies",
309 name: "Unresolved catalog reference",
310 short: "package.json references a catalog that does not declare the package",
311 full: "A workspace package.json declares a dependency with the `catalog:` or `catalog:<name>` protocol, but the catalog has no entry for that package. The package manager install will fail until the catalog is fixed. To fix: add the package to the named catalog, switch the reference to a different catalog that does declare it, or remove the reference and pin a hardcoded version. Scope: the detector scans `dependencies`, `devDependencies`, `peerDependencies`, and `optionalDependencies` in every workspace `package.json`, plus the pnpm override values in `pnpm-workspace.yaml` `overrides` (skipped when `packageManager` names a pnpm version that ignores it: pnpm before 10.5.1, or pnpm 10 or earlier when the root `package.json` declares non-empty `pnpm.overrides` or `resolutions`), root `package.json` `pnpm.overrides` (skipped when `packageManager` names pnpm 11 or later, because pnpm 11 does not read it), and root `package.json` `resolutions` (read only when `packageManager` names pnpm 10 or earlier), using `pnpm-workspace.yaml` catalogs when present and Bun root `package.json` catalogs otherwise. See also: fallow/unused-catalog-entry (the inverse: catalog entries no consumer references).",
312 docs_path: "rules/unresolved-catalog-reference",
313 },
314 RuleDef {
315 id: "fallow/unused-dependency-override",
316 category: "Dependencies",
317 name: "Unused dependency override",
318 short: "Package-manager override target is not declared or resolved",
319 full: "An entry in `pnpm-workspace.yaml`'s `overrides:` section (skipped when `packageManager` names a pnpm version that ignores it: pnpm before 10.5.1, or pnpm 10 or earlier when the root `package.json` declares non-empty `pnpm.overrides` or `resolutions`), `package.json#pnpm.overrides` (skipped when `packageManager` names pnpm 11 or later, which does not read it), npm or Bun's top-level `package.json#overrides`, or Bun's `package.json#resolutions` whose target package is not declared by any workspace package and is not present in the active readable lockfile (`pnpm-lock.yaml`, `package-lock.json`, `npm-shrinkwrap.json`, or `bun.lock`). Override entries linger after their target package leaves the resolved dependency tree. pnpm and npm projects without a readable lockfile fall back to workspace package manifests and keep a `hint` so transitive CVE pins can be reviewed before removal. Bun projects with only binary `bun.lockb` fail closed: fallow reports a workspace diagnostic and emits no unused-override finding until a readable `bun.lock` exists. To fix: delete the entry, refresh the active lockfile if it is stale, or add the entry to `ignoreDependencyOverrides` when the override is intentionally retained. See also: fallow/misconfigured-dependency-override.",
320 docs_path: "rules/unused-dependency-override",
321 },
322 RuleDef {
323 id: "fallow/misconfigured-dependency-override",
324 category: "Dependencies",
325 name: "Misconfigured dependency override",
326 short: "Package-manager override has an unparsable key or value",
327 full: "An entry in `pnpm-workspace.yaml#overrides` (skipped when `packageManager` names a pnpm version that ignores it: pnpm before 10.5.1, or pnpm 10 or earlier when the root `package.json` declares non-empty `pnpm.overrides` or `resolutions`), `package.json#pnpm.overrides` (skipped when `packageManager` names pnpm 11 or later, which does not read it), npm or Bun's top-level `package.json#overrides`, or Bun's `package.json#resolutions` whose key or value cannot be interpreted in that source's override grammar. Common shapes include an empty key, an empty value, a malformed version selector (`@types/react@<<18`), or an unbalanced parent matcher (`react>`). The active package manager may reject or ignore the entry. To fix: correct the key or value according to that package manager's grammar, or remove the entry. See also: fallow/unused-dependency-override.",
328 docs_path: "rules/misconfigured-dependency-override",
329 },
330 RuleDef {
331 id: "fallow/invalid-client-export",
332 category: "Policy",
333 name: "Invalid client export",
334 short: "\"use client\" file exports a server-only / route-config name",
335 full: "A file carrying the `\"use client\"` directive also exports a Next.js server-only or route-segment config name (such as `metadata`, `generateMetadata`, `revalidate`, `generateStaticParams`, or a route HTTP method like `GET`/`POST`). Next.js rejects this combination at build time. Move the server-only export to a non-client module (a server component, a `route.ts`, or a separate config file), or remove the `\"use client\"` directive if the module does not need to be a client boundary. The check runs only when the project declares `next`.",
336 docs_path: "rules/invalid-client-export",
337 },
338 RuleDef {
339 id: "fallow/mixed-client-server-barrel",
340 category: "Policy",
341 name: "Mixed client/server barrel",
342 short: "Barrel re-exports both a \"use client\" module and a server-only module",
343 full: "A barrel file (a module whose exports are `export ... from` re-exports) forwards a name from a `\"use client\"` module alongside a name from a server-only module (one carrying `\"use server\"`, importing the `server-only` package, or importing a server-only Next.js API such as `next/headers`). Importing one name from such a barrel drags the other's directive context across the React Server Components boundary, a known Next.js App Router problem. Type-only re-exports are ignored (erased at build), and a barrel re-exporting a client module alongside an ordinary undirected utility is not reported. To fix: split the barrel so client and server-only modules are re-exported from separate entry points. The check runs only when the project declares a React Server Components bundler: `next`, `waku`, `@lazarv/react-server`, `react-server-dom-webpack`, `react-server-dom-vite`, `react-server-dom-parcel` or `@vitejs/plugin-rsc`.",
344 docs_path: "rules/mixed-client-server-barrel",
345 },
346 RuleDef {
347 id: "fallow/misplaced-directive",
348 category: "Policy",
349 name: "Misplaced directive",
350 short: "\"use client\" / \"use server\" directive is not in the leading position and is ignored",
351 full: "A `\"use client\"` or `\"use server\"` directive string appears as an expression statement after a non-directive statement (an `import`, a `const`). React Server Components bundlers only honor a directive in the leading prologue, before any other statement; once any statement precedes it the string is parsed as an ordinary expression and silently ignored. The intended client/server boundary never takes effect, so the file is treated as a server module. To fix: move the directive to the very top of the file, above every import. The check runs only when the project declares a React Server Components bundler: `next`, `waku`, `@lazarv/react-server`, `react-server-dom-webpack`, `react-server-dom-vite`, `react-server-dom-parcel` or `@vitejs/plugin-rsc`.",
352 docs_path: "rules/misplaced-directive",
353 },
354 RuleDef {
355 id: "fallow/unprovided-inject",
356 category: "Dead code",
357 name: "Unprovided injects",
358 short: "inject() / getContext() reads a key that no provide() / setContext() supplies",
359 full: "A Vue `inject(KEY)` or Svelte `getContext(KEY)` reads a dependency-injection key (an imported or module-local symbol) that no matching `provide(KEY)` / `setContext(KEY)` supplies anywhere in the project. The read resolves to undefined at runtime, surfaced only at render. To fix: add a matching provider for the key, or remove the dead inject. Defaults to warn, not error: a provider may live outside the analyzed graph (an app-level provide registered elsewhere, a plugin, a host application). String-literal keys and keys imported from a package are abstained.",
360 docs_path: "rules/unprovided-inject",
361 },
362 RuleDef {
363 id: "fallow/unrendered-component",
364 category: "Dead code",
365 name: "Unrendered components",
366 short: "A component is reachable through a barrel but rendered nowhere",
367 full: "A component is reachable in the module graph (a barrel re-exports it) but rendered nowhere in the project. The rule covers Vue, Svelte and Astro single-file components (the default export of a `.vue`, `.svelte` or `.astro` file), Angular components with an element selector, and Lit elements. For a single-file component: no `<Tag>`, no `:is` / `this=` binding, no `components` / `app.component` registration, no `h()` / auto-import use, and no script value-read. It survives unused-file (the barrel keeps it reachable) and unused-export (the re-export counts as a use), yet no file actually renders it. To fix: render the component somewhere, or delete it and drop the dead re-export. Defaults to warn, not error: a component can be rendered reflectively (a dynamic `<component :is>` resolved from a non-literal value), so analyzer confidence is lower. Components that are themselves entry points (route pages, layouts, `App.vue`) and components re-exported from a non-private package entry point are abstained.",
368 docs_path: "rules/unrendered-component",
369 },
370 RuleDef {
371 id: "fallow/absent-component-prop",
372 category: "Dead code",
373 name: "Absent optional component props",
374 short: "Known reachable callers omit an optional prop consumed inside its component",
375 full: "A used optional component input is supplied by none of its inspected reachable callers. The finding includes the declaration, framework, default presence and caller locations. Enable absent-component-props explicitly; it defaults to off. Supported contracts cover React, Preact, Solid, Qwik, Vue, Svelte, Astro, Angular, Lit and Ember. Unknown spreads, dynamic or escaped component references, ambiguous bindings, incomplete contracts and externally exposed APIs abstain. Review defaults and API intent manually; static analysis does not prove runtime unreachability.",
376 docs_path: "rules/absent-component-prop",
377 },
378 RuleDef {
379 id: "fallow/constant-parameter",
380 category: "Dead code",
381 name: "Constant parameters",
382 short: "Each visible call passes a function parameter in the same way",
383 full: "A parameter of a module-scope function gets the same literal at each visible call (reason identical-argument), or an optional parameter is passed by no call (reason never-passed). The finding lists the value, the call count, the calls, and the count of conditions that test the parameter; a condition that tests a constant points at a branch that cannot run. Enable constant-parameters explicitly; it defaults to off. The rule fires only when each caller is visible. It abstains for public API and entry-point exports, exports that a plugin marks as used, dynamic imports, CommonJS, escaped namespaces, a function used as a value or through call/apply/bind, template hosts that can import the function, direct eval, classic scripts, framework auto-imports, open contracts (arguments, overloads, a reassigned binding, decorators, generators), a module with a parse error that can import the function, and fewer than 2 calls. A self-call that passes an optional parameter on blocks never-passed. For an object-pattern parameter, the rule reports each option key on its own: a key that no call sets (never-passed), or a key that each call sets to the same literal (identical-argument). A written or rest parameter, an array pattern, and an object pattern with a default other than {} give no finding. In the default mode a test file is a caller; with --production only production callers count. Review the parameter manually; static analysis does not prove that no caller outside the project exists.",
384 docs_path: "rules/constant-parameter",
385 },
386 RuleDef {
387 id: "fallow/unused-component-prop",
388 category: "Dead code",
389 name: "Unused component props",
390 short: "A Vue, Svelte, or React component prop is referenced nowhere in its own component",
391 full: "A declared component prop referenced nowhere inside its own component, in these framework shapes: a Vue `<script setup>` defineProps prop, a Svelte 5 `$props()` prop, or a React/Preact prop destructured from a component's first parameter and read nowhere in its body. Framework type checkers check caller-side prop correctness, not this in-component dead-input direction. Conservative: Vue abstains on `$attrs` fallthrough, whole-object props use, defineExpose, defineModel, and imported prop-type aliases; Svelte abstains on rest, computed, nested, and whole-object `$props()` shapes; React abstains on rest spread (`{...rest}`), props forwarded by spread, props passed wholesale to a hook, `forwardRef` / imported-interface props, and exported public-API component props. Default warn; suppress or remove the prop.",
392 docs_path: "rules/unused-component-prop",
393 },
394 RuleDef {
395 id: "fallow/unused-component-emit",
396 category: "Dead code",
397 name: "Unused component emits",
398 short: "A Vue <script setup> defineEmits event is emitted nowhere in its own component",
399 full: "A Vue `<script setup>` defineEmits declared event that is emitted nowhere in its own component (no `emit('<name>')` call). vue-tsc / Volar check caller-side emit correctness, not this in-component dead-output direction. Conservative: abstains on `$attrs` fallthrough, whole-object emit use, defineExpose, defineModel, and imported emit-type aliases. Default warn; suppress or remove the emit.",
400 docs_path: "rules/unused-component-emit",
401 },
402 RuleDef {
403 id: "fallow/unused-component-input",
404 category: "Dead code",
405 name: "Unused component inputs",
406 short: "An Angular @Input() / signal input() / model() input is read nowhere in its own component",
407 full: "An Angular `@Input()` / signal `input()` / `model()` declared input that is read nowhere in its own component (neither the inline / external template nor the class body). The Angular compiler never flags a declared-but-unread `@Input`, and there is no `@angular-eslint` rule for it. Conservative: usage detection over-credits by design (a template sentinel ref, any class-body member access by that name, or a bare identifier read counts as used), and the whole component abstains on an unresolved `extends` heritage clause (a base class in another file may read the input). A `model()` is recorded as an input only. Default warn; suppress or remove the input. The check runs only when the project declares `@angular/core`.",
408 docs_path: "rules/unused-component-input",
409 },
410 RuleDef {
411 id: "fallow/unused-component-output",
412 category: "Dead code",
413 name: "Unused component outputs",
414 short: "An Angular @Output() / signal output() output is emitted nowhere in its own component",
415 full: "An Angular `@Output()` / signal `output()` declared output that is emitted nowhere in its own component (no `this.<output>.emit(...)`). The Angular compiler never flags a declared-but-unemitted `@Output`, and there is no `@angular-eslint` rule for it. Conservative: usage detection over-credits by design (a `this.<output>.emit` call site, or any value read of `this.<output>` that might forward it, counts as used), and the whole component abstains on an unresolved `extends` heritage clause. A `model()`-derived implicit output is never flagged. Default warn; suppress or remove the output. The check runs only when the project declares `@angular/core`.",
416 docs_path: "rules/unused-component-output",
417 },
418 RuleDef {
419 id: "fallow/unused-svelte-event",
420 category: "Dead code",
421 name: "Unused Svelte events",
422 short: "A Svelte component dispatches a createEventDispatcher event whose name is listened to nowhere in the project",
423 full: "A Svelte component that dispatches a custom event via `createEventDispatcher` (`const dispatch = createEventDispatcher(); dispatch('save')`) whose event name is listened to nowhere in the analyzed project. This is the cross-file dead-output direction: the component fires an event nothing handles. No native tool covers the listener side: eslint-plugin-svelte and svelte-check are single-file / type-only. fallow builds a project-wide listened-event set from every component-tag `on:<name>` binding (event forwarding, an `on:<name>` with no handler, counts as a listen), then flags a dispatched event whose name is in no listened set. Conservative (zero false positives): the whole component abstains on a dynamic `dispatch(<nonLiteral>)` (the event name is unknowable) or a `dispatch` reference forwarded as a value; a DOM `on:click` on a lowercase element is not a custom event and is ignored; and any listener on any component anywhere credits the name (the liberal over-credit, false-negative-safe direction). Default warn; remove the dispatched event or wire a listener. The check runs only when the project declares `svelte`.",
424 docs_path: "rules/unused-svelte-event",
425 },
426 RuleDef {
427 id: "fallow/unused-effect-layer",
428 category: "Dead code",
429 name: "Unused Effect layers",
430 short: "An Effect layer is composed only into layers that nothing uses",
431 full: "An Effect `Layer` definition (a module-scope const or a class static property such as `static layer = Layer.effect(this, make)`) whose every reference sits inside other layer definitions that are themselves unused. The layer never reaches `Effect.provide`, `ManagedRuntime.make`, `Layer.launch` or any other runtime use. fallow builds a layer graph from `Layer.*` initializers and `.pipe(Layer.*)` chains. Any value reference outside a layer definition is a root, including references in functions and tests. A layer with zero references is not reported here: `unused-export` or `unused-class-member` reports it, so the rule reports the tail of a dead composition and names the unused consumers. Default warn. The check runs only when the project declares `effect`.",
432 docs_path: "rules/unused-effect-layer",
433 },
434 RuleDef {
435 id: "fallow/unused-tagged-error",
436 category: "Dead code",
437 name: "Unused tagged errors",
438 short: "An Effect tagged error class is referenced only as a type or a catchTag string, and no code constructs or fails with it",
439 full: "A class that extends `Data.TaggedError(\"X\")` or `Schema.TaggedError<Self>()(\"X\", ...)` that type positions or `catchTag(\"X\")` handlers reference, but that no code reads as a value. Any value reference counts as a producer: `new X()`, `X.make`, `Schema.Union(X)`, an API or RPC error declaration that decodes the error at a boundary, or passing the class to a function. Only type positions and catch-tag strings do not count. A class with zero references is left to `unused-export`. The finding lists the `catchTag` handlers of the tag. Default warn. The check runs only when the project declares `effect`.",
440 docs_path: "rules/unused-tagged-error",
441 },
442 RuleDef {
443 id: "fallow/unproduced-catch-tag",
444 category: "Dead code",
445 name: "Unproduced catch tags",
446 short: "A catchTag handler names a project error tag that no code produces",
447 full: "A `catchTag(\"X\", ...)` or `catchTags({ X: ... })` handler where every project class with tag `X` is never constructed or failed with, and no object literal `_tag: \"X\"` or tagged constructor produces the tag. A tag that no project class declares can come from a package, so the rule abstains. Effect built-in tags such as `TimeoutException` are never reported. The rule reports a handler only when no `unused-tagged-error` finding covers its classes: the error rule is off, or its finding is suppressed. Default warn. The check runs only when the project declares `effect`.",
448 docs_path: "rules/unproduced-catch-tag",
449 },
450 RuleDef {
451 id: "fallow/unused-server-action",
452 category: "Dead code",
453 name: "Unused server actions",
454 short: "A Next.js Server Action exported from a \"use server\" file is referenced by no code in the project",
455 full: "A Next.js Server Action (an export of a `\"use server\"` file) that no code in the project references: no import-and-call, no `action={fn}` JSX binding, no `<form action={fn}>`. This is the cross-graph \"declared but zero consumers\" direction, reclassified out of `unused-export` for `\"use server\"` files so the finding carries the action-specific signal. eslint-plugin-next is single-file and cannot see cross-file usage. It does not mean the endpoint is unreachable: Next.js still registers a generated action id, so it stays POST-able; it means no project code references it (likely forgotten or dead, and a candidate for removal to shrink surface area). Default warn; wire the action to a consumer or remove it. The check runs only when the project declares `next`.",
456 docs_path: "rules/unused-server-action",
457 },
458 RuleDef {
459 id: "fallow/unused-load-data-key",
460 category: "Dead code",
461 name: "Unused load data keys",
462 short: "A SvelteKit load() return-object key is read by no consumer",
463 full: "A SvelteKit route `load()` (in `+page.ts` / `+page.server.ts` and the `.js` variants) returns an object whose keys become the route's `data` prop. A returned key that NO consumer reads is dead: it runs a real server-side fetch / DB cost on every request for data nothing renders. fallow checks two channels: the sibling `+page.svelte`'s `data.<key>` reads (route-pinned), and project-wide `page.data.<key>` (Svelte 5 `$app/state`) / `$page.data.<key>` (Svelte 4 `$app/stores`) reads in any component. `svelte-check` types `data` via generated `$types` but never flags an unread returned key. The detector abstains (never false-flags) on a spread / non-literal / multi-return / computed-key / wrapped `load`, on a sibling that passes the whole `data` object opaquely, on a `+page.server.ts` whose universal `+page.ts` sibling forwards its `data`, and project-wide when any whole-object use of `page.data` / `$page.data` is seen. Default warn; delete the key or wire a consumer. A load fetch can have side effects, so there is no safe auto-fix. The check runs only when the project declares `@sveltejs/kit`.",
464 docs_path: "rules/unused-load-data-key",
465 },
466 RuleDef {
467 id: "fallow/prop-drilling",
468 category: "Dead code",
469 name: "Prop drilling",
470 short: "A React/Preact prop is forwarded unchanged through 2 or more components to a distant consumer",
471 full: "A React/Preact prop is received by a component and forwarded unchanged to a child, which forwards it unchanged again, until a component uses it. One intermediate \"pass-through\" component is enough: the prop then passes unchanged through two components before the consumer. The high-confidence signal is that the received identifier appears only as the root of forwarded child-JSX attribute values (so `<Child userName={user.name}/>` counts: the prop `user` is projected forward), not the attribute name matching. fallow emits located per-chain records (the source, each pass-through hop, and the consumer with file + line + component name) so CI and an agent can act: colocate the consumer with the data, lift the value to a React context/provider at a mid-chain hop, or compose the component so the intermediates no longer thread the prop. This is a graph-derived health signal, not a correctness error. The rule defaults to off (opt-in), like private-type-leak and the security rules: enable it with `prop-drilling: \"warn\"` in `rules`. Set `prop-drilling: \"error\"` to enforce remaining chains in CI. Warnings remain advisory even with strict flags. File overrides resolve at the source hop and can activate the rule when the base setting is off. Suppressed or baselined chains do not gate. Zero false positives by construction: any `{...props}` spread, `cloneElement`, element-as-prop / render-prop / children-as-function, or context `*.Provider` anywhere in the chain abstains the whole chain, as does an ambiguous or unresolvable hop. The check runs only when the project declares `react` / `react-dom` / `next` / `preact`.",
472 docs_path: "rules/prop-drilling",
473 },
474 RuleDef {
475 id: "fallow/thin-wrapper",
476 category: "Dead code",
477 name: "Thin wrapper",
478 short: "A React/Preact component whose whole body is a single spread-forwarded child render (a candidate for inlining)",
479 full: "A React/Preact component whose entire body is structural indirection: it returns exactly one capitalized component element that forwards the component's own props via a bare spread (`return <Child {...props}/>`), with no host-element wrapper, no extra children, no named attributes alongside the spread, no hooks, no branching, and no other statements. Such a component adds nothing of its own: it is a candidate for inlining at its call sites or deleting, not a correctness error. fallow emits a located per-wrapper record (file + line + the wrapper and child component names) so CI and an agent can act. The rule defaults to off (opt-in), like prop-drilling and the security rules: enable it with `thin-wrapper: \"warn\"` in `rules`. Zero false positives by construction: a `forwardRef` / `memo` wrapper (the sanctioned way to make a child ref-able or set a perf boundary), an exported component (a public-API re-brand / encapsulation), a context `*.Provider` wrapper, a `cloneElement` / render-prop forward, a wrapper that passes any named attribute alongside the spread (a fixed configuration), a self-render, or an unresolvable / member-expression child all abstain. A TypeScript-only type-narrowing wrapper (`const StrictButton = (p: StrictProps) => <Button {...p}/>`) is a known limitation, because fallow reads syntax and does not resolve types; suppress it with the inline comment. The check runs only when the project declares `react` / `react-dom` / `next` / `preact`.",
480 docs_path: "rules/thin-wrapper",
481 },
482 RuleDef {
483 id: "fallow/duplicate-prop-shape",
484 category: "Dead code",
485 name: "Duplicate prop shape",
486 short: "Three or more React/Preact components across two or more files declare an identical prop-name set (a missing shared Props type)",
487 full: "Three or more distinct React/Preact components, living in two or more files, whose statically-harvested prop name set is byte-for-byte identical after (a) excluding a fixed denylist of ubiquitous DOM / render-passthrough prop names (className, style, id, children, key, ref, the common event handlers, plus data-* / aria-* by prefix) and (b) requiring the remaining significant set to have four or more members. Identity is over names only, never types (fallow does not resolve types). This is a structural-refactor health signal: the recurring shape is a missing shared abstraction, so extract one shared `Props` type (or a base component) that every member reuses. It is never a correctness error and never an auto-fix. fallow emits one located record per participating component, each naming the shared `shape`, the `group_size`, and the other members in `sharing_components`. The rule defaults to off (opt-in), like thin-wrapper and the security rules: enable it with `duplicate-prop-shape: \"warn\"` in `rules`. Anti-noise gates (defended as rule-of-three plus a denylist-survivor floor, not tuned magic): the four-significant-prop floor turns `{label, onClick}` buttons into non-findings; the three-component floor is the rule-of-three abstraction trigger; the two-file floor keeps a local same-shaped variant pair (a render-prop pair, a Foo/FooImpl split) unflagged. A component whose props are not fully harvestable (a rest/spread signature, a forwardRef/memo over an imported interface) abstains, because a partial prop set can never be proven identical. Exact full-set identity only: a superset / subset relationship does not group, so a four-prop group and a five-prop superset form two findings (the price of zero invalid groups: the finding always fits one extracted shared type). The check runs only when the project declares `react` / `react-dom` / `next` / `preact`.",
488 docs_path: "rules/duplicate-prop-shape",
489 },
490 RuleDef {
491 id: "fallow/route-collision",
492 category: "Policy",
493 name: "Route collision",
494 short: "Two or more Next.js App Router route files resolve to the same URL",
495 full: "Two or more App Router route files (a `page` or a `route` handler) resolve to the same URL within one app-root. Route groups `(name)` and parallel slots `@name` do not change the URL, so `app/(marketing)/about/page.tsx` and `app/(shop)/about/page.tsx` both own `/about`. Next.js fails the build (\"You cannot have two parallel pages that resolve to the same path\") because a URL can have at most one owner, whether a Page or a Route Handler. fallow surfaces every colliding file at once; the build error names only one. Buckets are scoped per app-root (per workspace package), so a monorepo with several independent Next apps sharing a path is not flagged. Files under a private `_folder` or an intercepting marker `(.)`/`(..)`/`(...)` are excluded. There is no safe auto-fix: move or merge one of the files so each URL has a single owner. The check runs only when the project declares `next`.",
496 docs_path: "rules/route-collision",
497 },
498 RuleDef {
499 id: "fallow/dynamic-segment-name-conflict",
500 category: "Policy",
501 name: "Dynamic segment name conflict",
502 short: "Sibling Next.js dynamic route segments use different slug names at the same position",
503 full: "Two or more sibling dynamic route segments at the same App Router tree position use different param spellings (`[id]` vs `[slug]`, or a catch-all `[...x]` vs an optional catch-all `[[...x]]`). Next.js throws \"You cannot use different slug names for the same dynamic path\" at dev and production runtime when the position is hit. Each position has one slot for a single segment, one for a catch-all, and one for an optional catch-all. Each slot takes one param name, and a catch-all and an optional catch-all cannot be siblings. A single segment next to a catch-all (`[slug]` and `[...rest]`) is valid and gives no finding. `next build` does not catch this (the build succeeds), so CI passes while the route crashes on its first request; fallow's static catch closes that gap. Route groups are transparent to the position and parallel slots fork it, so only genuinely-sibling segments conflict. To fix: rename the dynamic segments at the position to one consistent slug name. The check runs only when the project declares `next`.",
504 docs_path: "rules/dynamic-segment-name-conflict",
505 },
506];
507
508#[must_use]
510pub fn rule_by_id(id: &str) -> Option<&'static RuleDef> {
511 CHECK_RULES
512 .iter()
513 .chain(HEALTH_RULES.iter())
514 .chain(DUPES_RULES.iter())
515 .chain(FLAGS_RULES.iter())
516 .chain(SECURITY_RULES.iter())
517 .chain(AUDIT_RULES.iter())
518 .chain(MUTATION_RULES.iter())
519 .find(|r| r.id == id)
520}
521
522pub fn all_rules() -> impl Iterator<Item = &'static RuleDef> {
526 CHECK_RULES
527 .iter()
528 .chain(HEALTH_RULES.iter())
529 .chain(DUPES_RULES.iter())
530 .chain(FLAGS_RULES.iter())
531 .chain(SECURITY_RULES.iter())
532 .chain(AUDIT_RULES.iter())
533 .chain(MUTATION_RULES.iter())
534}
535
536#[must_use]
542pub fn rule_command(rule: &RuleDef) -> &'static str {
543 let owns = |rules: &[RuleDef]| rules.iter().any(|candidate| candidate.id == rule.id);
544 if owns(HEALTH_RULES) {
545 "health"
546 } else if owns(DUPES_RULES) {
547 "dupes"
548 } else if owns(FLAGS_RULES) {
549 "flags"
550 } else if owns(SECURITY_RULES) {
551 "security"
552 } else if owns(AUDIT_RULES) {
553 "audit"
554 } else if owns(MUTATION_RULES) {
555 "mutation"
556 } else {
557 "dead-code"
558 }
559}
560
561#[must_use]
564pub fn bare_rule_id(rule: &RuleDef) -> &'static str {
565 rule.id.split_once('/').map_or(rule.id, |(_, bare)| bare)
566}
567
568#[must_use]
574pub fn rule_config_key(rule: &RuleDef) -> Option<&'static str> {
575 let bare = bare_rule_id(rule);
576 fallow_types::issue_meta::issue_meta_by_code(bare)
577 .and_then(|meta| meta.config_key)
578 .or(match bare {
579 "high-cyclomatic-complexity" => Some("complexity-cyclomatic"),
580 "high-cognitive-complexity" => Some("complexity-cognitive"),
581 "high-crap-score" => Some("complexity-crap"),
582 "long-file" => Some("complexity-file-lines"),
583 _ => None,
584 })
585}
586
587#[must_use]
600pub fn rule_severity_key(rule: &RuleDef) -> Option<&'static str> {
601 let bare = bare_rule_id(rule);
602 let candidate = rule_config_key(rule)
603 .or_else(|| {
604 fallow_types::issue_meta::issue_meta_by_code(bare).and_then(|meta| meta.suppress_token)
605 })
606 .or_else(|| match rule_command(rule) {
607 "security" => Some(if bare == "client-server-leak" {
608 "security-client-server-leak"
609 } else {
610 "security-sink"
611 }),
612 "health" if matches!(bare, "untested-file" | "untested-export") => {
613 Some("coverage-gaps")
614 }
615 _ => None,
616 })?;
617 crate::schemas::is_rule_severity_key(candidate).then_some(candidate)
618}
619
620#[must_use]
622pub fn rule_docs_url(rule: &RuleDef) -> String {
623 let docs_path = rule_result_meta(rule).map_or(rule.docs_path, |meta| meta.meta_docs_path);
624 fallow_output::rule_docs_url(docs_path)
625}
626
627fn rule_result_meta(rule: &RuleDef) -> Option<&'static fallow_types::issue_meta::IssueResultMeta> {
628 let code = rule.id.strip_prefix("fallow/")?;
629 fallow_types::issue_meta::issue_result_meta_by_code(code)
630}
631
632fn rule_explain_name(rule: &RuleDef) -> &'static str {
633 rule_result_meta(rule).map_or(rule.name, |meta| meta.meta_name)
634}
635
636fn rule_explain_summary(rule: &RuleDef) -> &'static str {
637 rule_result_meta(rule).map_or(rule.short, |meta| meta.sarif_description)
638}
639
640pub struct RuleGuide {
645 pub example: &'static str,
647 pub how_to_fix: &'static str,
649}
650
651#[must_use]
656pub fn rule_by_token(token: &str) -> Option<&'static RuleDef> {
657 let trimmed = token.trim();
658 if trimmed.is_empty() {
659 return None;
660 }
661 if let Some(rule) = rule_by_id(trimmed) {
662 return Some(rule);
663 }
664 let normalized = trimmed
665 .strip_prefix("fallow/")
666 .unwrap_or(trimmed)
667 .trim_start_matches("--")
668 .replace('_', "-")
669 .split_whitespace()
670 .collect::<Vec<_>>()
671 .join("-");
672 if let Some(rule) = dead_code_registry_rule(&normalized) {
673 return Some(rule);
674 }
675 if let Some(rule) = rule_by_id(&format!("fallow/{normalized}")) {
676 return Some(rule);
677 }
678 let alias = health_alias_id(&normalized).or_else(|| security_alias_id(&normalized));
679 if let Some(id) = alias
680 && let Some(rule) = rule_by_id(id)
681 {
682 return Some(rule);
683 }
684 let security_token = normalized.strip_prefix("security-").unwrap_or(&normalized);
685 let security_id = format!("security/{security_token}");
686 if let Some(rule) = rule_by_id(&security_id) {
687 return Some(rule);
688 }
689 let singular = normalized
690 .strip_suffix('s')
691 .filter(|_| normalized != "unused-class")
692 .unwrap_or(&normalized);
693 let singular_security_token = singular.strip_prefix("security-").unwrap_or(singular);
694 let singular_security_id = format!("security/{singular_security_token}");
695 if let Some(rule) = rule_by_id(&singular_security_id) {
696 return Some(rule);
697 }
698 let id = format!("fallow/{singular}");
699 rule_by_id(&id).or_else(|| {
700 CHECK_RULES
701 .iter()
702 .chain(HEALTH_RULES.iter())
703 .chain(DUPES_RULES.iter())
704 .chain(FLAGS_RULES.iter())
705 .chain(SECURITY_RULES.iter())
706 .chain(AUDIT_RULES.iter())
707 .chain(MUTATION_RULES.iter())
708 .find(|rule| {
709 rule.docs_path.ends_with(&normalized)
710 || rule.docs_path.ends_with(singular)
711 || rule_result_meta(rule).is_some_and(|meta| {
712 meta.meta_docs_path.ends_with(&normalized)
713 || meta.meta_docs_path.ends_with(singular)
714 || meta.meta_name.eq_ignore_ascii_case(trimmed)
715 })
716 || rule.name.eq_ignore_ascii_case(trimmed)
717 })
718 })
719}
720
721fn dead_code_registry_rule(normalized: &str) -> Option<&'static RuleDef> {
722 let meta = fallow_types::issue_meta::issue_meta_for_contract_token(normalized)?;
723 CHECK_RULES
724 .iter()
725 .find(|rule| rule.id.strip_prefix("fallow/") == Some(meta.code))
726}
727
728fn health_alias_id(normalized: &str) -> Option<&'static str> {
729 match normalized {
730 "complexity" | "high-complexity" => Some("fallow/high-complexity"),
731 "cyclomatic" | "high-cyclomatic" | "high-cyclomatic-complexity" => {
732 Some("fallow/high-cyclomatic-complexity")
733 }
734 "cognitive" | "high-cognitive" | "high-cognitive-complexity" => {
735 Some("fallow/high-cognitive-complexity")
736 }
737 "crap" | "high-crap" | "high-crap-score" => Some("fallow/high-crap-score"),
738 "long-file" | "file-lines" | "max-file-lines" | "complexity-file-lines" => {
739 Some("fallow/long-file")
740 }
741 "duplication"
742 | "dupes"
743 | "code-duplication"
744 | "introduced-clone-group"
745 | "introduced-clone-groups" => Some("fallow/code-duplication"),
746 "feature-flag" | "feature-flags" | "flags" => Some("fallow/feature-flag"),
747 "flag-retirement" | "flag-retirement-candidate" | "retirement" => {
748 Some("fallow/flag-retirement-candidate")
749 }
750 _ => None,
751 }
752}
753
754fn security_alias_id(normalized: &str) -> Option<&'static str> {
755 match normalized {
756 "security"
757 | "security-candidate"
758 | "security-candidates"
759 | "tainted-sink"
760 | "tainted-sinks"
761 | "security-sink"
762 | "security-sinks" => Some("security/tainted-sink"),
763 "client-server-leak"
764 | "client-server-leaks"
765 | "security-client-server-leak"
766 | "security-client-server-leaks" => Some("security/client-server-leak"),
767 "hardcoded-secret" | "hardcoded-secrets" | "hard-coded-secret" | "hard-coded-secrets" => {
768 Some("security/hardcoded-secret")
769 }
770 _ => None,
771 }
772}
773
774#[must_use]
777pub fn rule_rationale(rule: &RuleDef) -> &'static str {
778 crate::explain_rationale::rule_rationale(rule.id).unwrap_or(rule.full)
779}
780
781#[must_use]
783pub fn rule_guide(rule: &RuleDef) -> RuleGuide {
784 own_rule_guide(rule.id).unwrap_or_else(fallback_rule_guide)
785}
786
787#[must_use]
790pub fn rule_has_guide(rule: &RuleDef) -> bool {
791 own_rule_guide(rule.id).is_some()
792}
793
794fn own_rule_guide(id: &str) -> Option<RuleGuide> {
795 source_dead_code_rule_guide(id)
796 .or_else(|| member_rule_guide(id))
797 .or_else(|| import_rule_guide(id))
798 .or_else(|| architecture_rule_guide(id))
799 .or_else(|| catalog_rule_guide(id))
800 .or_else(|| health_runtime_rule_guide(id))
801 .or_else(|| duplication_rule_guide(id))
802 .or_else(|| security_rule_guide(id))
803 .or_else(|| audit_rule_guide(id))
804 .or_else(|| mutation_rule_guide(id))
805 .or_else(|| flags_rule_guide(id))
806}
807
808fn flags_rule_guide(id: &str) -> Option<RuleGuide> {
809 Some(match id {
810 "fallow/feature-flag" => RuleGuide {
811 example: "`src/checkout.ts` checks `process.env.FEATURE_NEW_CHECKOUT === 'true'`, or calls `client.variation('new-checkout', user, false)` of a flag SDK.",
812 how_to_fix: "Check if the flag still switches behavior. Run `fallow flags --retirement` to list the flags that are ready to go, then remove the flag check and the branch that production no longer runs.",
813 },
814 "fallow/flag-retirement-candidate" => RuleGuide {
815 example: "`FEATURE_NEW_CHECKOUT` has one read site, and `--flag-state` shows that the vendor rolled the flag out to all users.",
816 how_to_fix: "Confirm with the owner of the flag that the rollout is done. Remove the flag check, keep the branch that production runs, delete the other branch, then remove the flag from the vendor.",
817 },
818 _ => return None,
819 })
820}
821
822fn audit_rule_guide(id: &str) -> Option<RuleGuide> {
823 Some(match id {
824 "fallow/weakened-tests" => RuleGuide {
825 example: "A change turns `it('charges tax', ...)` into `it.skip('charges tax', ...)`, or lowers `coverage.thresholds.lines` from 90 to 70.",
826 how_to_fix: "Decide if the weaker test or threshold is intended. If it is, suppress the finding with `// fallow-ignore-next-line weakened-tests` (or `fallow-ignore-file` for a file-level kind), or set the rule to `off` for the path in `overrides`.",
827 },
828 "fallow/added-suppression" => RuleGuide {
829 example: "A change adds `// @ts-expect-error` above a call instead of a correct type.",
830 how_to_fix: "Decide if the suppression is necessary. If it is, keep it and suppress the finding with `// fallow-ignore-next-line added-suppression`, or turn the rule off for the path.",
831 },
832 "fallow/test-only-branch" => RuleGuide {
833 example: "A change adds `if (process.env.NODE_ENV === 'test') return cached;` to `src/pricing.ts`.",
834 how_to_fix: "Prefer a seam that tests can inject, such as a parameter or a module mock. If the branch is intended, suppress it with `// fallow-ignore-next-line test-only-branch`.",
835 },
836 "fallow/diverged-clone-sibling" => RuleGuide {
837 example: "`src/a/total.ts` and `src/b/total.ts` held the same function. The change fixes a bug in the first copy only.",
838 how_to_fix: "Check the unchanged copies in `related`. Apply the same change there, or extract a shared function. If the copies must differ, suppress with `// fallow-ignore-next-line diverged-clone-sibling`.",
839 },
840 "fallow/added-dependency" => RuleGuide {
841 example: "A change adds `\"left-pad\": \"^1.3.0\"` to `dependencies`.",
842 how_to_fix: "Check that the package exists, is maintained, and is not already covered by a dependency of the project. Suppress through `overrides` because `package.json` cannot hold a comment.",
843 },
844 _ => return None,
845 })
846}
847
848fn source_dead_code_rule_guide(id: &str) -> Option<RuleGuide> {
849 Some(match id {
850 "fallow/unused-file" => RuleGuide {
851 example: "src/old-widget.ts is not imported by any entry point, route, script, or config file.",
852 how_to_fix: "Delete the file if it is genuinely dead. If a framework or a tool loads it implicitly, add the file to `entry`, to `supportEntry` for a file that only tests or tooling load, or to `dynamicallyLoaded` for a file that the code loads at runtime by a computed path.",
853 },
854 "fallow/unused-export" => RuleGuide {
855 example: "export const formatPrice = ... exists in src/money.ts, but no module imports formatPrice.",
856 how_to_fix: "Remove the export or make it file-local. If it is public API, import it from an entry point or add an intentional suppression with context. To treat exported Effect schemas as type contracts, set effect.schemaExportsAsTypes: fallow then reports them as unused types.",
857 },
858 "fallow/unused-type" => RuleGuide {
859 example: "export interface LegacyProps is exported, but no module imports the type.",
860 how_to_fix: "Remove the type export, inline it, or keep it behind an explicit API entry point when consumers rely on it. With effect.schemaExportsAsTypes, this rule also reports unused Effect schema exports.",
861 },
862 "fallow/private-type-leak" => RuleGuide {
863 example: "export function makeUser(): InternalUser exposes InternalUser even though InternalUser is not exported.",
864 how_to_fix: "Export the referenced type, change the public signature to an exported type, or keep the helper private.",
865 },
866 "fallow/deprecated-export-in-use" => RuleGuide {
867 example: "/** @deprecated Use formatMoney. */ export function formatPrice() is still imported by src/cart.ts and src/checkout.ts.",
868 how_to_fix: "Move each consumer to the replacement the message names, then remove the export. For the full consumer list, run `fallow dead-code --trace <file>:<export>`. Enable the rule with `deprecated-exports-in-use: \"warn\"` in `rules`, or pass `--deprecated-exports-in-use` for one run.",
869 },
870 "fallow/unused-dependency"
871 | "fallow/unused-dev-dependency"
872 | "fallow/unused-optional-dependency" => RuleGuide {
873 example: "package.json lists left-pad, but no source, script, config, or plugin-recognized file imports it.",
874 how_to_fix: "Remove the dependency after checking runtime/plugin usage. If another workspace uses it, move the dependency to that workspace.",
875 },
876 "fallow/type-only-dependency" => RuleGuide {
877 example: "zod is in dependencies but only appears in import type declarations.",
878 how_to_fix: "Move the package to devDependencies unless runtime code imports it as a value.",
879 },
880 "fallow/test-only-dependency" => RuleGuide {
881 example: "vitest is listed in dependencies, but only test files import it.",
882 how_to_fix: "Move the package to devDependencies unless production code imports it at runtime.",
883 },
884 "fallow/dev-dependency-in-production" => RuleGuide {
885 example: "yaml is in devDependencies, but src/config.ts imports { parse } from 'yaml' and runs it at runtime.",
886 how_to_fix: "Move the package to dependencies when the deployment installs them, so a production-only install keeps it. Leave it in devDependencies if the build inlines it into the output, if the only production imports are `import type`, or if another manifest section (dependencies / peer / optional) already provides it.",
887 },
888 _ => return None,
889 })
890}
891
892fn member_rule_guide(id: &str) -> Option<RuleGuide> {
893 Some(match id {
894 "fallow/unused-enum-member" => RuleGuide {
895 example: "Status.Legacy remains in an exported enum, but no code reads that member.",
896 how_to_fix: "Remove the member after checking serialized/API compatibility, or suppress it with a reason when external data still uses it.",
897 },
898 "fallow/unused-class-member" => RuleGuide {
899 example: "class Parser has a public parseLegacy method that is never called in the project.",
900 how_to_fix: "Remove or privatize the member. For reflection/framework lifecycle hooks, configure or suppress the intentional entry point.",
901 },
902 "fallow/unused-store-member" => RuleGuide {
903 example: "useCartStore declares a discountTotal getter that no component, composable, or other store ever reads.",
904 how_to_fix: "Remove the unused state property, getter, or action. If it is consumed reflectively (a Pinia plugin, $onAction, or dynamic dispatch), suppress the line with // fallow-ignore-next-line unused-store-member.",
905 },
906 "fallow/unused-protected-class-member" => RuleGuide {
907 example: "class Shape declares protected unusedHelper(), and neither Shape nor a subclass calls this.unusedHelper() or super.unusedHelper().",
908 how_to_fix: "Remove the member, or make it private when only the class reads it. If a subclass outside the project reads it, suppress the line with // fallow-ignore-next-line unused-protected-class-member.",
909 },
910 "fallow/namespace-escape" => RuleGuide {
911 example: "src/index.ts has import * as formats from \"./formats\" and spreads formats into an object, so formatDate and formatPrice are not checked.",
912 how_to_fix: "Read the members by name (formats.formatDate) or import them by name, so fallow can check the other exports. When the whole object is the intent, add // fallow-ignore-next-line namespace-escape above the import.",
913 },
914 "fallow/test-only-export" => RuleGuide {
915 example: "src/price.ts exports legacyFormat. Only src/price.test.ts imports it, and no production file calls it.",
916 how_to_fix: "When the export is dead code that its tests keep alive, remove the export and those tests. When it is a seam for tests only, test the behavior through the public functions of the module and make the item internal. When the export is deliberate, add // fallow-ignore-next-line test-only-export above it. See also unused-export.",
917 },
918 "fallow/unused-namespace-member" => RuleGuide {
919 example: "src/lib/legacy.ts exports namespace Legacy with a member unusedInner that no file reads as Legacy.unusedInner.",
920 how_to_fix: "Remove the unused member, or remove its export keyword when only the namespace body uses it. For generated code, turn the rule off for those files in overrides. Suppress an intentional member with // fallow-ignore-next-line unused-namespace-member.",
921 },
922 "fallow/unprovided-inject" => RuleGuide {
923 example: "A component calls inject(ThemeKey) (Vue) or getContext(ThemeKey) (Svelte) with an imported symbol key, but no provide(ThemeKey) / setContext(ThemeKey) exists anywhere in the project.",
924 how_to_fix: "Add a matching provide() / setContext() for the key, or remove the dead inject() / getContext(). If a provider lives outside the analyzed graph (an app-level provide registered elsewhere, a plugin, a host app), suppress the line with // fallow-ignore-next-line unprovided-inject.",
925 },
926 "fallow/unrendered-component" => RuleGuide {
927 example: "components/Orphan.vue is re-exported from a barrel (export { default as Orphan } from './Orphan.vue') but no template, registration, h() call, or dynamic import ever renders it.",
928 how_to_fix: "Render the component where it belongs, or delete it and remove the dead barrel re-export. If it is rendered reflectively (a dynamic <component :is> from a non-literal value), suppress the line with // fallow-ignore-next-line unrendered-component.",
929 },
930 "fallow/constant-parameter" => RuleGuide {
931 example: "format(value, compact, locale?) is called 14 times in the project, each time as format(n, true). compact is always true, so the branch for false cannot run, and no call passes locale.",
932 how_to_fix: "Review the calls and the intent of the parameter. Remove the parameter and move the value into the function, or keep it when the flexibility is deliberate. Add a fallow-ignore-next-line constant-parameter comment above the parameter or the function to keep it. This candidate has no automatic fix.",
933 },
934 "fallow/absent-component-prop" => RuleGuide {
935 example: "Card declares highlight?: boolean with a false default, reads highlight in its render body, and every inspected reachable caller renders <Card /> without highlight.",
936 how_to_fix: "Review inspected callers, defaults and API intent. Keep intentional stable props, update the component manually, or add a declaration-line fallow-ignore-next-line absent-component-prop comment. This candidate has no automatic fix.",
937 },
938 "fallow/unused-component-prop" => RuleGuide {
939 example: "Widget.vue declares defineProps<{ size: string }>(), or a React Widget({ size }) destructures `size`, but `size` is referenced nowhere in the component (Vue: its script or template; React: its function body or JSX).",
940 how_to_fix: "Remove the unused prop, or reference it in the component (Vue: the script / template; React: the function body or JSX). If the prop is part of a deliberately-stable public component API, suppress the line with // fallow-ignore-next-line unused-component-prop.",
941 },
942 "fallow/unused-component-emit" => RuleGuide {
943 example: "Widget.vue declares defineEmits<{ close: [] }>() but `emit('close')` is called nowhere in the component's script.",
944 how_to_fix: "Remove the unused emit, or emit it in the script. If the emit is part of a deliberately-stable public component API, suppress the line with // fallow-ignore-next-line unused-component-emit.",
945 },
946 "fallow/unused-component-input" => RuleGuide {
947 example: "user-card.component.ts declares @Input() size: string (or size = input<string>()) but `size` is read nowhere in the template or the class body.",
948 how_to_fix: "Remove the unused input, or read it in the template or class body. If the input is part of a deliberately-stable public component API, suppress the line with // fallow-ignore-next-line unused-component-input.",
949 },
950 "fallow/unused-component-output" => RuleGuide {
951 example: "user-card.component.ts declares @Output() close = new EventEmitter<void>() (or close = output<void>()) but `this.close.emit(...)` is called nowhere in the class.",
952 how_to_fix: "Remove the unused output, or emit it from the class. If the output is part of a deliberately-stable public component API, suppress the line with // fallow-ignore-next-line unused-component-output.",
953 },
954 "fallow/unused-svelte-event" => RuleGuide {
955 example: "Child.svelte calls const dispatch = createEventDispatcher(); dispatch('dead'), but no parent listens for it (no <Child on:dead> anywhere in the project).",
956 how_to_fix: "Remove the dispatched event, or listen for it on the component (<Child on:dead={...}> or forward it via <Child on:dead>). If the event is dispatched reflectively (a dynamic name) or is part of a deliberately-stable public component API, suppress the line with // fallow-ignore-next-line unused-svelte-event.",
957 },
958 "fallow/unused-effect-layer" => RuleGuide {
959 example: "services.ts defines const CacheLive = Cache.layer.pipe(Layer.provide(Db.layer)) and export const OrphanLive = Layer.mergeAll(CacheLive), but nothing provides OrphanLive.",
960 how_to_fix: "Remove the unused consumer layers first, then this layer, or compose the layer into a layer that reaches a runtime. If code outside the analyzed project composes it, suppress the line with // fallow-ignore-next-line unused-effect-layer.",
961 },
962 "fallow/unused-tagged-error" => RuleGuide {
963 example: "errors.ts declares class Expired extends Data.TaggedError(\"Expired\"), signatures list it in the error channel and a handler calls catchTag(\"Expired\"), but no code constructs Expired or fails with it.",
964 how_to_fix: "Fail with the error where the condition occurs, or remove the class, its type references and its catchTag handlers. If consumers outside the project construct or decode it, suppress the line with // fallow-ignore-next-line unused-tagged-error.",
965 },
966 "fallow/unproduced-catch-tag" => RuleGuide {
967 example: "main.ts calls Effect.catchTag(\"Expired\", ...), the only class with tag Expired is never constructed, and the unused-tagged-error finding for it is suppressed.",
968 how_to_fix: "Remove the handler, or fail with the error where the condition occurs. If a package or code outside the project produces the tag, suppress the line with // fallow-ignore-next-line unproduced-catch-tag.",
969 },
970 "fallow/unused-server-action" => RuleGuide {
971 example: "app/actions.ts has \"use server\" and exports submitForm, but no component imports it, binds it via action={submitForm}, or uses it in <form action={submitForm}>.",
972 how_to_fix: "Wire the action to a consumer (an import-and-call, an action={fn} binding, or a <form action={fn}>), or remove it. If it is invoked reflectively (an action registry dispatching by id, or a non-JS caller), suppress the line with // fallow-ignore-next-line unused-server-action.",
973 },
974 "fallow/unused-load-data-key" => RuleGuide {
975 example: "src/routes/blog/+page.ts returns { posts, draftCount } but +page.svelte only reads data.posts and no component reads page.data.draftCount.",
976 how_to_fix: "Delete the unused key from the load() return (and skip its fetch), or wire a consumer (read data.<key> in +page.svelte, or page.data.<key> in a shared component). If the load fetch has a side effect you must keep, suppress the line with // fallow-ignore-next-line unused-load-data-key.",
977 },
978 "fallow/prop-drilling" => RuleGuide {
979 example: "Page receives `user` and renders <Layout user={user}/>; Layout only re-passes it to <Sidebar user={user}/>; Sidebar only re-passes it to <Profile user={user}/>, which finally reads user.name. The prop is drilled through Layout and Sidebar untouched.",
980 how_to_fix: "Collapse the chain: colocate the consumer with the data, lift the value into a React context/provider at a mid-chain hop and consume it there, or compose the component (pass the rendered child as children) so the intermediates no longer thread the prop. Enable the rule with rules.prop-drilling = \"warn\" (it defaults to off). To accept one chain, suppress the source prop with // fallow-ignore-next-line prop-drilling.",
981 },
982 "fallow/thin-wrapper" => RuleGuide {
983 example: "const ButtonWrapper = (props) => <Button {...props}/>; the wrapper has no own markup, hooks, or logic, so it only re-points at Button.",
984 how_to_fix: "Inline the wrapper at its call sites (use <Button .../> directly) or delete it. Keep it only if it is a deliberate seam (a planned divergence point, a public-API re-brand): an exported wrapper already abstains. Enable the rule with rules.thin-wrapper = \"warn\" (it defaults to off). To accept one wrapper, suppress it with // fallow-ignore-next-line thin-wrapper above the component definition.",
985 },
986 "fallow/duplicate-prop-shape" => RuleGuide {
987 example: "FieldText, FieldNumber, and FieldSelect (across three files) each declare exactly { name, label, value, error, hint, onChange }. The four significant prop names (label, value, error, hint) are identical, so they form one duplicate-prop-shape group.",
988 how_to_fix: "Extract one shared Props type (e.g. type FieldProps = { name; label; value; onChange; error }) that every member reuses, or a base component the variants compose. Keep them separate only if a per-variant prop divergence is planned. Enable the rule with rules.duplicate-prop-shape = \"warn\" (it defaults to off). To accept one member, suppress it with // fallow-ignore-next-line duplicate-prop-shape above the component definition; the suppressed member still appears in its siblings' sharing_components because the group is real regardless of suppression.",
989 },
990 _ => return None,
991 })
992}
993
994fn import_rule_guide(id: &str) -> Option<RuleGuide> {
995 Some(match id {
996 "fallow/unresolved-import" => RuleGuide {
997 example: "src/app.ts imports ./routes/admin, but no matching file exists after extension and index resolution.",
998 how_to_fix: "Fix the specifier, restore the missing file, install the package, or align tsconfig path aliases with the runtime resolver.",
999 },
1000 "fallow/unlisted-dependency" => RuleGuide {
1001 example: "Root src/app.ts imports @acme/shared, an npm workspace package. The root package.json lists workspaces but does not list @acme/shared as a dependency, so the import is unlisted even when npm links it into node_modules.",
1002 how_to_fix: "Declare the imported package in the owning package.json, including the root manifest for root code. Use dependencies for runtime needs or devDependencies for tooling/tests, with a version accepted by your package manager. Self-references need no declaration. For deliberately ambient packages, use ignoreDependencies as an explicit opt-out.",
1003 },
1004 "fallow/duplicate-export-alias" => RuleGuide {
1005 example: "src/worker.ts has export const handler = createHandler() and export default handler, so one binding has the names handler and default.",
1006 how_to_fix: "Keep one export name and update the importers of the other names. If the names are an intentional public API, add them to ignoreExports, or suppress the line with // fallow-ignore-next-line duplicate-export-alias.",
1007 },
1008 "fallow/unlisted-binary" => RuleGuide {
1009 example: "The package.json script `pack` runs `gnome-extensions pack ext`, and src/capture.ts calls `spawnSync(\"hyprctl\", [\"version\"])`. No installed package provides either binary.",
1010 how_to_fix: "Add the package that provides the binary to devDependencies. When the operating system or the CI image provides it, add the name to ignoreBinaries.",
1011 },
1012 "fallow/duplicate-export" => RuleGuide {
1013 example: "Button is exported from both src/ui/button.ts and src/components/button.ts.",
1014 how_to_fix: "Rename or consolidate the exports so consumers have one intentional import target.",
1015 },
1016 _ => return None,
1017 })
1018}
1019
1020fn architecture_rule_guide(id: &str) -> Option<RuleGuide> {
1021 Some(match id {
1022 "fallow/circular-dependency" => RuleGuide {
1023 example: "src/cart.ts imports src/order.ts, and src/order.ts imports src/cart.ts.",
1024 how_to_fix: "Extract shared code to a third module, invert the dependency, or split initialization-time side effects from type-only contracts.",
1025 },
1026 "fallow/boundary-violation" => RuleGuide {
1027 example: "features/billing imports app/admin even though the configured boundary only allows imports from shared and entities.",
1028 how_to_fix: "Move the shared contract to an allowed zone, invert the dependency, or update the boundary config only if the architecture rule was wrong.",
1029 },
1030 "fallow/boundary-coverage" => RuleGuide {
1031 example: "src/generated/client.ts is reachable but does not match any boundaries.zones[].patterns entry.",
1032 how_to_fix: "Add the file to the intended zone pattern, move it under a zoned directory, or add a generated-file glob to boundaries.coverage.allowUnmatched.",
1033 },
1034 "fallow/boundary-call-violation" => RuleGuide {
1035 example: "src/domain/policy.ts calls execSync from node:child_process while boundaries.calls.forbidden bans child_process.* from the domain zone.",
1036 how_to_fix: "Move the call into a zone that may perform the effect, route it through an allowed abstraction, or narrow the forbidden pattern if the rule was wrong. To suppress, use the boundary family token: `// fallow-ignore-next-line boundary-violation` governs import, coverage, and call findings alike (the rule-id-shaped `boundary-call-violation` is accepted as an alias).",
1037 },
1038 "fallow/policy-violation" => RuleGuide {
1039 example: "src/app.ts imports moment while a rule pack bans the moment specifier with the message 'Use date-fns.'",
1040 how_to_fix: "Follow the rule's message to replace banned usage or remove a banned export. For a GDP proof producer, move proof factory creation into an allowed file, or correct the rule's allowedFiles and optional proofKinds if the ownership policy was wrong. For a banned-import rule with allowNames, import a listed name by name. To waive one rule, use `// fallow-ignore-next-line policy-violation:<pack>/<rule-id>` or the file-level form. Use bare `policy-violation` only when you intend to suppress every rule-pack finding at that scope.",
1041 },
1042 "fallow/stale-suppression" => RuleGuide {
1043 example: "`// fallow-ignore-next-line unused-export` stays above an export that another module imports, so no unused-export finding remains for the comment to suppress.",
1044 how_to_fix: "Remove the suppression. If a different issue is still intentional, replace it with a current, specific suppression.",
1045 },
1046 id if crate::explain_guides::is_structure_rule(id) => {
1047 return crate::explain_guides::structure_rule_guide(id);
1048 }
1049 "fallow/missing-suppression-reason" => RuleGuide {
1050 example: "`// fallow-ignore-next-line unused-export` appears without a reason after the token, while `requireSuppressionReason` is on.",
1051 how_to_fix: "Add a concise reason after the suppression token, or remove the suppression if the issue is no longer intentional.",
1052 },
1053 _ => return None,
1054 })
1055}
1056
1057fn catalog_rule_guide(id: &str) -> Option<RuleGuide> {
1058 Some(match id {
1059 "fallow/unused-catalog-entry" => RuleGuide {
1060 example: "The catalog source declares `catalog: { is-even: ^1.0.0 }`, but no workspace package.json declares `\"is-even\": \"catalog:\"`.",
1061 how_to_fix: "Delete the entry from the catalog source file. If any consumer uses a hardcoded version (surfaced in `hardcoded_consumers`), switch that consumer to `catalog:` first to keep versions aligned.",
1062 },
1063 "fallow/empty-catalog-group" => RuleGuide {
1064 example: "The catalog source declares `catalogs: { react17: {} }` after the last react17 entry was removed.",
1065 how_to_fix: "Delete the empty named group from the catalog source file. Comments between the deleted header and the next sibling can stay in place for manual review.",
1066 },
1067 "fallow/unresolved-catalog-reference" => RuleGuide {
1068 example: "packages/app/package.json declares `\"old-react\": \"catalog:react17\"`, but `catalogs.react17` in the catalog source does not declare `old-react`. The package manager install will fail.",
1069 how_to_fix: "If `available_in_catalogs` is non-empty, change the reference to one of those catalogs (e.g. `catalog:react18`). Otherwise add the package to the named catalog in the catalog source, or remove the catalog reference and pin a hardcoded version. For staged migrations where the catalog edit lands separately, add the (package, catalog, consumer) triple to `ignoreCatalogReferences` in your fallow config.",
1070 },
1071 "fallow/unused-dependency-override" => RuleGuide {
1072 example: "The root package.json declares `overrides: { axios: ^1.6.0 }`, but no workspace package.json declares `axios` and the active lockfile does not resolve it.",
1073 how_to_fix: "Delete the entry from its reported declaration source. If the finding is caused by a stale or missing readable lockfile, refresh the active lockfile and rerun fallow. If the override is intentionally retained, add it to `ignoreDependencyOverrides` in your fallow config.",
1074 },
1075 "fallow/misconfigured-dependency-override" => RuleGuide {
1076 example: "The root package.json declares `overrides: { \"axios\": \"\" }`. An empty override value is invalid and the active package manager will reject or ignore it.",
1077 how_to_fix: "Fix the key or value to match the active package manager's grammar. For pnpm this includes bare or scoped package names, version selectors, parent matchers, and the supported `-`, `$ref`, and `npm:alias` values. For npm or Bun, preserve the supported nested object shape. Remove experimental entries that should not remain.",
1078 },
1079 _ => return None,
1080 })
1081}
1082
1083const UNTESTED_FIX: &str = "Add or wire a test that imports the runtime path, or update entry-point/test discovery if the existing test is invisible to fallow.";
1085
1086const COMPLEXITY_FIX: &str = "For function findings, extract named helpers, split independent branches, flatten guard clauses, and add tests around the behavior before refactoring. For `<template>` findings, flatten nested control flow and move branch selection out of the markup: Angular `@if`/`@for`/`@switch`/`@defer` and legacy `*ngIf`/`*ngFor` into computed signals on the component class, Vue `v-if`/`v-else-if`/`v-for` into computed properties, Svelte `{#if}`/`{:else if}`/`{#each}`/`{#await}`/`{#key}` into derived state, Astro control flow into props resolved in the frontmatter. In Svelte, moving a repeated or deeply nested block into a top-level `{#snippet}` gives it its own `<snippet:NAME>` unit with nesting rebased to zero, so the in-file extraction moves the score; splitting a large template into child components lowers the score in every dialect. For `<component>` rollup findings, attack the larger half first; the per-half breakdown lives in `component_rollup`. To report these findings without a failed run, set the `complexity-cyclomatic` or `complexity-cognitive` rule to `warn`.";
1088
1089fn health_runtime_rule_guide(id: &str) -> Option<RuleGuide> {
1090 Some(match id {
1091 "fallow/high-cyclomatic-complexity" => RuleGuide {
1092 example: "`function route(req)` has a `switch` with 14 `case` labels and two `if` checks. Its cyclomatic complexity is 17, while `health.maxCyclomatic` is 15.",
1093 how_to_fix: COMPLEXITY_FIX,
1094 },
1095 "fallow/high-cognitive-complexity" => RuleGuide {
1096 example: "`applyDiscount` puts an `if` inside a `for` inside another `if`, with a `continue` and a `&&` chain in the inner block. Each nesting level adds to the score, which reaches 21 while `health.maxCognitive` is 15.",
1097 how_to_fix: COMPLEXITY_FIX,
1098 },
1099 "fallow/high-complexity" => RuleGuide {
1100 example: "`parseRow` has a cyclomatic complexity of 24 and a cognitive complexity of 31, so the function exceeds both thresholds: it has many paths, and the paths are deeply nested.",
1101 how_to_fix: COMPLEXITY_FIX,
1102 },
1103 "fallow/high-crap-score" => RuleGuide {
1104 example: "A complex function has little or no matching Istanbul coverage, so its CRAP score crosses the configured gate. Synthetic template-family units (the `<template>` units on Angular, Vue, Svelte and Astro markup, and Svelte `<snippet:NAME>` units) are not scored on this dimension: a template carries no direct coverage of its own, so fallow gates templates on the cyclomatic and cognitive dimensions instead.",
1105 how_to_fix: "Add focused tests for the risky branches first, then simplify the function if the score remains high. Template findings never carry this rule, so a `maxCrap` override scoped to a template unit buys nothing and can be removed. To report these findings without a failed run, set the `complexity-crap` rule to `warn`.",
1106 },
1107 "fallow/long-file" => RuleGuide {
1108 example: "A module grew to 900 physical lines while `health.maxFileLines` is 500. Blank lines and comment lines count; a final newline does not add a line.",
1109 how_to_fix: "Move cohesive groups of exports into their own modules, and remove unused code. In `fallow audit`, a long file that did not grow stays inherited, so you can enable the threshold on an existing project and stop further growth. To report these findings without a failed run, set the `complexity-file-lines` rule to `warn`. To raise the ceiling for generated files, use `thresholdOverrides[].maxFileLines`.",
1110 },
1111 "fallow/refactoring-target" => RuleGuide {
1112 example: "A file combines high complexity density, churn, fan-in, and dead-code signals.",
1113 how_to_fix: "Start with the listed evidence: remove dead exports, extract complex functions, then reduce fan-out or cycles in small steps.",
1114 },
1115 "fallow/shallow-directory" => RuleGuide {
1116 example: "`src/utils` holds 10 functions in 2 files. `src/main.ts` and `src/report.ts` use 8 of them through the barrel, and `src/utils` keeps 2 helpers inside.",
1117 how_to_fix: "Group the items by the concern of their callers, and move each group into a module with a small interface, or next to its only caller. When the width is on purpose, for example a published helper set, add the directory to `health.shallowDirectories.ignore`.",
1118 },
1119 "fallow/untested-file" => RuleGuide {
1120 example: "`src/routes/checkout.ts` imports `src/billing/invoice.ts`, but no test file imports either module, directly or through other modules.",
1121 how_to_fix: UNTESTED_FIX,
1122 },
1123 "fallow/untested-export" => RuleGuide {
1124 example: "`src/cart.ts` calls `roundCents` from `src/money.ts`. `test/money.test.ts` imports only `formatPrice` from that file, so no test reaches `roundCents`.",
1125 how_to_fix: UNTESTED_FIX,
1126 },
1127 id if id.starts_with("fallow/runtime-") || id.starts_with("fallow/css-") => {
1128 return crate::explain_guides::health_rule_guide(id);
1129 }
1130 id if id.starts_with("fallow/coverage-intelligence-") => {
1131 return crate::explain_guides::health_rule_guide(id);
1132 }
1133 _ => return None,
1134 })
1135}
1136
1137fn duplication_rule_guide(id: &str) -> Option<RuleGuide> {
1138 Some(match id {
1139 "fallow/code-duplication" => RuleGuide {
1140 example: "Two files contain the same normalized token sequence across a multi-line block.",
1141 how_to_fix: "Extract the shared logic when the duplicated behavior should evolve together. Leave it duplicated when the similarity is accidental and likely to diverge. To keep one intended copy out of the report, suppress it with `// fallow-ignore-next-line code-duplication`. To make a new copy fail `fallow audit`, set the `introduced-clone-group` rule to `error`.",
1142 },
1143 _ => return None,
1144 })
1145}
1146
1147fn security_rule_guide(id: &str) -> Option<RuleGuide> {
1148 Some(match id {
1149 "security/tainted-sink" => RuleGuide {
1150 example: "A non-literal request field reaches a catalogue sink such as security/sql-injection or security/dangerous-html. The finding is a candidate, not proof of exploitability.",
1151 how_to_fix: "Trace the source, sink, sanitization, and runtime context. Fix confirmed issues with parameterization, escaping, validation, or safer APIs, and suppress only reviewed false positives with context.",
1152 },
1153 "security/client-server-leak" => RuleGuide {
1154 example: "A module marked `use client` imports code that reads a non-public `process.env` or `import.meta.env` value through a static path.",
1155 how_to_fix: "Keep non-public env reads on the server side, move the value behind an API boundary, or rename only intentionally public values to the framework's public prefix. For a `server-only-import` candidate, the fix depends on the sink. For a React Router `.server` module, move the call into `loader`, `action`, `middleware` or `headers`, or move the code that the client needs out of the `.server` module. For other server-only code in Next.js, keep the import out of the `use client` cone; a module that only `next/dynamic(..., { ssr: false })` loads is a false positive.",
1156 },
1157 "security/hardcoded-secret" => RuleGuide {
1158 example: "A provider-prefixed token-shaped literal is assigned to a secret-shaped variable, and the hardcoded-secret category is explicitly included.",
1159 how_to_fix: "Rotate real credentials, move them to a secret manager or environment variable, and keep test-only literals clearly fake so they do not resemble provider tokens.",
1160 },
1161 id if id.starts_with("security/") => RuleGuide {
1162 example: crate::explain_rationale::security_category_example(id).unwrap_or(
1163 "A `fallow security` candidate uses this catalogue category as its SARIF rule id, for example security/sql-injection for a matched SQL sink.",
1164 ),
1165 how_to_fix: "Review the candidate trace before acting. Confirm attacker control, missing sanitization, and reachable runtime context, then fix with the category-appropriate safer API or add a reviewed suppression.",
1166 },
1167 _ => return None,
1168 })
1169}
1170
1171fn mutation_rule_guide(id: &str) -> Option<RuleGuide> {
1172 Some(match id {
1173 "fallow/mutation-survived" => RuleGuide {
1174 example: "The tests call `isAdult(30)` and `isAdult(10)` only. Changing `>=` to `>` in `isAdult` makes no test fail, because no test checks the age `18`.",
1175 how_to_fix: "Add or change a test so that it fails on this change. To see the code, run `fallow mutation inspect` with the mutant ID that the finding names.",
1176 },
1177 _ => return None,
1178 })
1179}
1180
1181fn fallback_rule_guide() -> RuleGuide {
1182 RuleGuide {
1183 example: "Run the relevant command with --format json --quiet --explain to inspect this rule in context.",
1184 how_to_fix: "Use the issue action hints, source location, and docs URL to decide whether to remove, move, configure, or suppress the finding.",
1185 }
1186}
1187
1188pub fn explain_issue_type(
1195 issue_type: &str,
1196) -> Result<fallow_output::ExplainOutput, crate::ProgrammaticError> {
1197 explain_with_labels(issue_type, |rule| {
1198 (rule_explain_name(rule), rule_explain_summary(rule))
1199 })
1200}
1201
1202pub fn explain_issue_type_for_display(
1208 issue_type: &str,
1209) -> Result<fallow_output::ExplainOutput, crate::ProgrammaticError> {
1210 explain_with_labels(issue_type, |rule| (rule.name, rule.short))
1211}
1212
1213fn explain_with_labels(
1214 issue_type: &str,
1215 labels: impl FnOnce(&RuleDef) -> (&'static str, &'static str),
1216) -> Result<fallow_output::ExplainOutput, crate::ProgrammaticError> {
1217 if matches!(issue_type, "shared-state" | "fallow/shared-state") {
1218 return Ok(crate::shared_state_explain::explain());
1219 }
1220 let Some(rule) = rule_by_token(issue_type) else {
1221 return Err(unknown_explain_error(issue_type));
1222 };
1223 let guide = rule_guide(rule);
1224 let (example_files, example_base_files) = crate::explain_examples::visible_example_files(rule);
1225 let (name, summary) = labels(rule);
1226 Ok(fallow_output::ExplainOutput {
1227 id: rule.id.to_string(),
1228 name: name.to_string(),
1229 summary: summary.to_string(),
1230 rationale: rule_rationale(rule).to_string(),
1231 example: guide.example.to_string(),
1232 example_files,
1233 example_base_files,
1234 how_to_fix: guide.how_to_fix.to_string(),
1235 docs: rule_docs_url(rule),
1236 })
1237}
1238
1239pub fn serialize_explain_programmatic_json(
1246 issue_type: &str,
1247 analysis_run_id: Option<&str>,
1248) -> Result<serde_json::Value, crate::ProgrammaticError> {
1249 let output = explain_issue_type(issue_type)?;
1250 fallow_output::serialize_explain_json_output(output, analysis_run_id).map_err(|error| {
1251 crate::ProgrammaticError::new(format!("JSON serialization error: {error}"), 2)
1252 .with_code("json_serialization")
1253 })
1254}
1255
1256#[must_use]
1259pub fn unknown_explain_error(issue_type: &str) -> crate::ProgrammaticError {
1260 if let Some(nearest) = nearest_explain_token(issue_type) {
1261 return crate::ProgrammaticError::new(
1262 format!("unknown issue type '{issue_type}'. Did you mean '{nearest}'?"),
1263 2,
1264 )
1265 .with_code("unknown_issue_type")
1266 .with_help(format!("fallow explain {nearest}"));
1267 }
1268 let message = if looks_security_explain_token(issue_type) {
1269 format!(
1270 "unknown issue type '{issue_type}'. Try values like tainted-sink, client-server-leak, hardcoded-secret, sql-injection, or security/sql-injection"
1271 )
1272 } else {
1273 format!(
1274 "unknown issue type '{issue_type}'. Try values like unused files, unused-export, high complexity, or code duplication"
1275 )
1276 };
1277 crate::ProgrammaticError::new(message, 2).with_code("unknown_issue_type")
1278}
1279
1280fn nearest_explain_token(issue_type: &str) -> Option<&'static str> {
1285 let normalized = issue_type
1286 .trim()
1287 .strip_prefix("fallow/")
1288 .unwrap_or_else(|| issue_type.trim())
1289 .trim_start_matches("--")
1290 .replace('_', "-");
1291 let candidates: Vec<&'static str> = all_rules()
1292 .flat_map(|rule| [bare_rule_id(rule), rule.id])
1293 .collect();
1294 fallow_config::levenshtein::closest_match(&normalized, candidates)
1295}
1296
1297fn looks_security_explain_token(issue_type: &str) -> bool {
1298 let normalized = issue_type.trim().to_ascii_lowercase().replace('_', "-");
1299 normalized.contains("security")
1300 || normalized.contains("secret")
1301 || normalized.contains("sink")
1302 || normalized.contains("cwe")
1303 || normalized.contains("client-server")
1304 || normalized.contains("injection")
1305}
1306
1307pub const HEALTH_RULES: &[RuleDef] = &[
1309 RuleDef {
1310 id: "fallow/high-cyclomatic-complexity",
1311 category: "Health",
1312 name: "High Cyclomatic Complexity",
1313 short: "Function has high cyclomatic complexity",
1314 full: "McCabe cyclomatic complexity exceeds the configured threshold. Cyclomatic complexity counts the number of independent paths through a function (1 + decision points: if/else, switch cases, loops, ternary, logical operators). High values indicate functions that are hard to test exhaustively. fallow also emits this rule on synthetic `<template>` findings across every supported template dialect (Angular .html templates and inline `@Component({ template: ... })` literals, Vue SFC `<template>` blocks, Svelte markup, Astro markup), counting each dialect's control-flow blocks (Angular `@if`/`@else if`/`@for`/`@case`/`@defer (when ...)` and legacy `*ngIf`/`*ngFor`; Vue `v-if`/`v-else-if`/`v-for`; Svelte `{#if}`/`{:else if}`/`{#each}`/`{#await}`/`{#key}`; the Astro equivalents) plus ternary and logical operators inside bound attributes and interpolations; on each top-level Svelte `{#snippet name(...)}` block, emitted as its own `<snippet:NAME>` unit; and on synthetic `<component>` rollup findings whose `cyclomatic` is the worst class method's score plus the template's. Ranking and `--targets` use the rollup total; JSON exposes the per-half breakdown under `component_rollup`.",
1315 docs_path: "rules/high-cyclomatic-complexity",
1316 },
1317 RuleDef {
1318 id: "fallow/high-cognitive-complexity",
1319 category: "Health",
1320 name: "High Cognitive Complexity",
1321 short: "Function has high cognitive complexity",
1322 full: "SonarSource cognitive complexity exceeds the configured threshold. Unlike cyclomatic complexity, cognitive complexity penalizes nesting depth and non-linear control flow (breaks, continues, early returns). It measures how hard a function is to understand when reading sequentially. fallow also emits this rule on synthetic `<template>` findings across every supported template dialect (Angular .html templates and inline `@Component({ template: ... })` literals, Vue SFC `<template>` blocks, Svelte markup, Astro markup), where nesting penalties accumulate on stacked control-flow blocks: Angular `@if`/`@for`/`@switch`, Vue `v-if`/`v-for`, Svelte `{#if}`/`{#each}`/`{#await}`; on each top-level Svelte `{#snippet name(...)}` block, emitted as its own `<snippet:NAME>` unit with nesting rebased to zero so in-file snippet extraction lowers the parent template's score; and on synthetic `<component>` rollup findings whose `cognitive` is the worst class method's score plus the template's. Ranking and `--targets` use the rollup total; JSON exposes the per-half breakdown under `component_rollup`.",
1323 docs_path: "rules/high-cognitive-complexity",
1324 },
1325 RuleDef {
1326 id: "fallow/high-complexity",
1327 category: "Health",
1328 name: "High Complexity (Both)",
1329 short: "Function exceeds both complexity thresholds",
1330 full: "Function exceeds both cyclomatic and cognitive complexity thresholds. This is the strongest signal that a function needs refactoring, it has many paths and is hard to understand. The same rule fires on synthetic `<template>` findings in every supported template dialect (Angular .html templates and inline `@Component({ template: ... })` literals, Vue SFC `<template>` blocks, Svelte markup, Astro markup) when both metrics exceed their thresholds, and on synthetic `<component>` rollup findings whose totals are the worst class method's score plus the template's. Ranking and `--targets` use the rollup totals; JSON exposes the per-half breakdown under `component_rollup`.",
1331 docs_path: "rules/high-complexity",
1332 },
1333 RuleDef {
1334 id: "fallow/high-crap-score",
1335 category: "Health",
1336 name: "High CRAP Score",
1337 short: "Function has a high CRAP score (complexity combined with low coverage)",
1338 full: "The function's CRAP (Change Risk Anti-Patterns) score meets or exceeds the configured threshold. CRAP combines cyclomatic complexity with test coverage using the Savoia and Evans (2007) formula: `CC^2 * (1 - coverage/100)^3 + CC`. High CRAP indicates changes to this function carry high risk because it is complex and poorly tested. Pair with `--coverage` for accurate per-function scoring; without it fallow estimates coverage from the module graph. This rule fires on functions only: synthetic template-family units (`<template>`, Svelte `<snippet:NAME>`) are excluded from the CRAP dimension, because a template is exercised only through its component and carries no coverage the formula could measure. Templates gate on the cyclomatic and cognitive dimensions instead.",
1339 docs_path: "rules/high-crap-score",
1340 },
1341 RuleDef {
1342 id: "fallow/long-file",
1343 category: "Health",
1344 name: "Long File",
1345 short: "File has more lines than the file-length threshold",
1346 full: "The file has more physical lines than `health.maxFileLines` (or `--max-file-lines`, or a `thresholdOverrides[].maxFileLines` entry for the file). Every line counts, also blank lines and comment lines; a final newline does not add a line. The threshold is off (`0`) by default. The finding is a complexity finding with `exceeded: \"file_lines\"`, the name `<file>`, the line count in `line_count`, and the ceiling in `max_file_lines`. The `complexity-file-lines` rule sets its gate severity. In `fallow audit`, a long file that did not grow by at least 5 lines stays inherited, and one that grew is worsened.",
1347 docs_path: "rules/long-file",
1348 },
1349 RuleDef {
1350 id: "fallow/refactoring-target",
1351 category: "Health",
1352 name: "Refactoring Target",
1353 short: "File identified as a high-priority refactoring candidate",
1354 full: "File identified as a refactoring candidate based on a weighted combination of complexity density, churn velocity, dead code ratio, fan-in (blast radius), and fan-out (coupling). Categories: urgent churn+complexity, break circular dependency, split high-impact file, remove dead code, extract complex functions, reduce coupling.",
1355 docs_path: "rules/refactoring-target",
1356 },
1357 RuleDef {
1358 id: "fallow/shallow-directory",
1359 category: "Health",
1360 name: "Shallow Directory",
1361 short: "Directory shows as many interface items as it hides",
1362 full: "Files outside the directory use at least as many of its interface items as it keeps inside, and it shows at least `health.shallowDirectories.minInterface` items (default 8). An interface item is a module-scope function or an exported class with a method; types, constants, enums, UI components and exports that a package entry publishes are no items. Only runtime imports from files that are not tests or stories count. A catalog (about one item per file), a family of functions with one parameter list, and items with about one outside user are not reported. The section is opt-in with `fallow health --shallow-directories`, advisory, and has no health score weight.",
1363 docs_path: "rules/shallow-directory",
1364 },
1365 RuleDef {
1366 id: "fallow/css-token-drift",
1367 category: "Health",
1368 name: "CSS Token Drift",
1369 short: "CSS or CSS-in-JS hardcoded styling value bypasses the design token system",
1370 full: "A styling value appears to bypass the project's design token system, for example a Tailwind arbitrary value in markup. The finding is advisory by default and does not affect the audit verdict unless rules.css-token-drift is set to error. Verify the value and replace it with an existing scale token when appropriate.",
1371 docs_path: "rules/css-token-drift",
1372 },
1373 RuleDef {
1374 id: "fallow/css-duplicate-block",
1375 category: "Health",
1376 name: "CSS Duplicate Block",
1377 short: "CSS or CSS-in-JS declaration block is duplicated across rules",
1378 full: "A style rule declaration block is repeated across selectors, suggesting copy-pasted styling that can often be consolidated. The finding is advisory by default and does not affect the audit verdict unless rules.css-duplicate-block is set to error.",
1379 docs_path: "rules/css-duplicate-block",
1380 },
1381 RuleDef {
1382 id: "fallow/css-selector-complexity",
1383 category: "Health",
1384 name: "CSS Selector Complexity",
1385 short: "CSS selector, nesting, or important usage is structurally complex",
1386 full: "A CSS or CSS-in-JS rule crosses the structural floor for selector specificity, selector complexity, nesting depth, or important usage. The finding is advisory by default and does not affect the audit verdict unless rules.css-selector-complexity is set to error.",
1387 docs_path: "rules/css-selector-complexity",
1388 },
1389 RuleDef {
1390 id: "fallow/css-dead-surface",
1391 category: "Health",
1392 name: "CSS Dead Surface",
1393 short: "CSS or CSS-in-JS surface appears unused",
1394 full: "A styling surface appears unused in the analyzed project, such as a scoped SFC class with no component-local use. The finding is advisory by default and does not affect the audit verdict unless rules.css-dead-surface is set to error. Verify dynamic consumers before deleting.",
1395 docs_path: "rules/css-dead-surface",
1396 },
1397 RuleDef {
1398 id: "fallow/css-broken-reference",
1399 category: "Health",
1400 name: "CSS Broken Reference",
1401 short: "CSS or CSS-in-JS reference resolves to no stylesheet definition",
1402 full: "A styling reference appears unresolved, such as a class token or keyframes name that has no stylesheet definition in the analyzed project. The finding is advisory by default and does not affect the audit verdict unless rules.css-broken-reference is set to error. Verify external or CSS-in-JS definitions before fixing.",
1403 docs_path: "rules/css-broken-reference",
1404 },
1405 RuleDef {
1406 id: "fallow/untested-file",
1407 category: "Health",
1408 name: "Untested File",
1409 short: "Runtime-reachable file has no test dependency path",
1410 full: "A file is reachable from runtime entry points but not from any discovered test entry point. This indicates production code that no test imports, directly or transitively, according to the static module graph.",
1411 docs_path: "rules/untested-file",
1412 },
1413 RuleDef {
1414 id: "fallow/untested-export",
1415 category: "Health",
1416 name: "Untested Export",
1417 short: "Runtime-reachable export has no test dependency path",
1418 full: "A value export is reachable from runtime entry points but no test-reachable module references it. This is a static test dependency gap rather than line coverage, and highlights exports exercised only through production entry paths.",
1419 docs_path: "rules/untested-export",
1420 },
1421 RuleDef {
1422 id: "fallow/runtime-safe-to-delete",
1423 category: "Health",
1424 name: "Production Safe To Delete",
1425 short: "Statically unused and never invoked in production",
1426 full: "The function is both statically unreachable in the module graph and was never invoked during the observed runtime coverage window. This is the highest-confidence delete signal fallow emits.",
1427 docs_path: "rules/runtime-safe-to-delete",
1428 },
1429 RuleDef {
1430 id: "fallow/runtime-review-required",
1431 category: "Health",
1432 name: "Production Review Required",
1433 short: "Statically used but never invoked in production",
1434 full: "The function is reachable in the module graph (or exercised by tests / untracked call sites) but was not invoked during the observed runtime coverage window. Needs a human look: may be seasonal, error-path only, or legitimately unused.",
1435 docs_path: "rules/runtime-review-required",
1436 },
1437 RuleDef {
1438 id: "fallow/runtime-low-traffic",
1439 category: "Health",
1440 name: "Production Low Traffic",
1441 short: "Function was invoked below the low-traffic threshold",
1442 full: "The function was invoked in production but below the configured `--low-traffic-threshold` fraction of total trace count (spec default 0.1%). Effectively dead for the current period.",
1443 docs_path: "rules/runtime-low-traffic",
1444 },
1445 RuleDef {
1446 id: "fallow/runtime-coverage-unavailable",
1447 category: "Health",
1448 name: "Runtime Coverage Unavailable",
1449 short: "Runtime coverage could not be resolved for this function",
1450 full: "The function could not be matched to a V8-tracked coverage entry. Common causes: the function lives in a worker thread (separate V8 isolate), it is lazy-parsed and never reached the JIT tier, or its source map did not resolve to the expected source path. This is advisory, not a dead-code signal.",
1451 docs_path: "rules/runtime-coverage-unavailable",
1452 },
1453 RuleDef {
1454 id: "fallow/runtime-coverage",
1455 category: "Health",
1456 name: "Runtime Coverage",
1457 short: "Runtime coverage gave no verdict for this function",
1458 full: "A runtime coverage finding whose verdict no other `runtime-*` rule covers. This is the `unknown` verdict: the runtime data did not lead to a verdict for the function, for example when a newer version of the runtime coverage add-on gives a verdict that this fallow version does not know. Functions with the `active` verdict are not reported.",
1459 docs_path: "rules/runtime-coverage",
1460 },
1461 RuleDef {
1462 id: "fallow/coverage-intelligence-risky-change",
1463 category: "Health",
1464 name: "Coverage Intelligence Risky Change",
1465 short: "Changed hot path combines high CRAP and low test coverage",
1466 full: "Coverage intelligence combined change scope, runtime hot-path evidence, low test coverage, and high CRAP into a risky-change finding. Add focused tests or split the change before merging.",
1467 docs_path: "rules/coverage-intelligence-risky-change",
1468 },
1469 RuleDef {
1470 id: "fallow/coverage-intelligence-delete",
1471 category: "Health",
1472 name: "Coverage Intelligence Delete",
1473 short: "Static and runtime evidence indicate code can be deleted",
1474 full: "Coverage intelligence combined static unused status, runtime cold evidence, and lack of test reachability into a high-confidence delete recommendation.",
1475 docs_path: "rules/coverage-intelligence-delete",
1476 },
1477 RuleDef {
1478 id: "fallow/coverage-intelligence-review",
1479 category: "Health",
1480 name: "Coverage Intelligence Review",
1481 short: "Cold reachable uncovered code needs owner review",
1482 full: "Coverage intelligence found code that is statically reachable but cold in runtime evidence, uncovered by tests, and ownership-risky. Route it to an owner before changing or deleting it.",
1483 docs_path: "rules/coverage-intelligence-review",
1484 },
1485 RuleDef {
1486 id: "fallow/coverage-intelligence-refactor",
1487 category: "Health",
1488 name: "Coverage Intelligence Refactor",
1489 short: "Hot covered code has high CRAP and should be refactored carefully",
1490 full: "Coverage intelligence found hot production code that is covered by tests but still has high CRAP. Refactor carefully while preserving behavior.",
1491 docs_path: "rules/coverage-intelligence-refactor",
1492 },
1493];
1494
1495pub const DUPES_RULES: &[RuleDef] = &[RuleDef {
1497 id: "fallow/code-duplication",
1498 category: "Duplication",
1499 name: "Code Duplication",
1500 short: "Duplicated code block",
1501 full: "A block of code that appears in multiple locations with identical or near-identical token sequences. Clone detection compares normalized token sequences. The `duplicates.mode` setting selects the normalization: `strict` and `mild` keep identifiers and literal values, `weak` ignores string values, and `semantic` ignores identifiers, string values and numeric values. The `duplicates.normalization` settings override each of these mode defaults. Duplicated line counts and percentages include every instance, including the first. Overlapping line ranges in the same file count once. Redundant token counts exclude one retained copy per clone group. In `fallow audit`, the `introduced-clone-group` rule sets how a clone group takes part in the verdict: `warn` (the default) gives `warn`, `error` fails the audit, and `off` removes the group from the verdict. Under `--gate new-only`, only a group that the change introduced counts. Under `--gate all`, every clone group in the changed files counts. With `overrides`, the most severe result over the instance files applies. The `duplicates.threshold` gate is independent of the rule.",
1502 docs_path: "rules/code-duplication",
1503}];
1504
1505pub const AUDIT_RULES: &[RuleDef] = &[
1507 RuleDef {
1508 id: "fallow/weakened-tests",
1509 category: "Audit",
1510 name: "Weakened Tests",
1511 short: "The change weakens tests or a coverage threshold",
1512 full: "`fallow audit` compares the base and head text of each changed file. The `kind` field tells how the change weakened the tests: `skip-only` (a new `.skip`, `.only`, `xit` or `fit` marker), `removed-tests` (fewer test cases in a file, while the total of all changed test files also dropped), `assertion-drop` (fewer `expect`, `assert` or `should` calls in a test file with no test case removed), `coverage-threshold` (a coverage or quality threshold that is less strict), `rule-severity` (a rule severity in the Fallow config that is less strict, such as `error` to `off`, a removed rule whose default is weaker, or a new `overrides` entry that turns a rule off for some paths), or `ignore-pattern` (a new or broader entry in a config key that removes files or findings from the analysis or makes code count as used, or a removed `!` exception of `ignorePatterns` or `ignoreFindings`). The keys are `ignorePatterns`, `ignoreFindings`, `production.ignore`, `health.ignore`, `duplicates.ignore`, `duplicates.ignoredClones`, `entry`, `supportEntry`, `dynamicallyLoaded`, `publicPackages`, `usedClassMembers`, `ignoreDependencies`, `ignoreBinaries`, `ignoreUnresolvedImports`, `ignoreExports`, `ignoreCatalogReferences`, `ignoreDependencyOverrides` and `boundaries.coverage.allowUnmatched`. The evidence names the key. A new entry that a base entry or a built-in default already covers does not report. The config check follows each relative `extends` file, so a change in an extended file or in the `extends` list reports too. A value that an `npm:` package or an `https://` URL can set does not compare, because the audit cannot read it at the base. A `rule-severity` or `ignore-pattern` finding takes the stricter of the base and head `weakened-tests` severity, so a change that turns off `weakened-tests` still reports. A suppression comment in the head config does not hide it, and it has no suppression action. A drop does not report when the lost test lines name code that the change removed, such as a deleted function or a deleted fixture directory: the tests went with that code. A name of a deleted file that a changed file still holds, a name that a deleted file only imports, a directory that still exists, and a reserved word such as `import` do not count. An assertion drop reports only when assertions are at least half of the code lines that the file lost, so a test rewrite that moves setup checks into a helper does not report. The finding is a fact about the change, not a proof that coverage dropped. Defaults to `warn`.",
1513 docs_path: "rules/weakened-tests",
1514 },
1515 RuleDef {
1516 id: "fallow/added-suppression",
1517 category: "Audit",
1518 name: "Added Suppressions",
1519 short: "The change adds a suppression comment",
1520 full: "`fallow audit` reports a comment line that the change adds with a lint, type-check, coverage or Fallow suppression: `eslint-disable`, `oxlint-disable`, `biome-ignore`, `deno-lint-ignore`, `@ts-ignore`, `@ts-expect-error`, `@ts-nocheck`, `istanbul ignore`, `c8 ignore`, `v8 ignore`, `fallow-override-threshold-next-line` or `fallow-ignore`. A moved comment is not added. A `fallow-ignore` comment that names only diff-risk rules does not count. Files below a fixture or generated directory (`fixture`, `fixtures`, `__fixtures__`, `__snapshots__`, `generated`, `__generated__`) do not report, because a tool writes them or a test reads them as data. Defaults to `warn`.",
1521 docs_path: "rules/added-suppression",
1522 },
1523 RuleDef {
1524 id: "fallow/test-only-branch",
1525 category: "Audit",
1526 name: "Test-Only Branches",
1527 short: "The change adds a test-environment branch to source code",
1528 full: "`fallow audit` reports a line that the change adds to a non-test source file and that checks the test environment: `process.env.NODE_ENV` compared with `'test'`, `process.env.VITEST` or `process.env.JEST_WORKER_ID`. Such a branch lets the tests take a path that production does not take. A Vitest in-source test block (`if (import.meta.vitest)`) is test code and is not reported. Tool config files are skipped. A check that only keeps `console` output quiet in tests (`if (process.env.NODE_ENV !== 'test') console.warn(...)`), and a check that picks an env file (`'.env.test'`), do not report. Defaults to `warn`.",
1529 docs_path: "rules/test-only-branch",
1530 },
1531 RuleDef {
1532 id: "fallow/diverged-clone-sibling",
1533 category: "Audit",
1534 name: "Diverged Clone Siblings",
1535 short: "The change edits one copy of duplicated code but not its siblings",
1536 full: "`fallow audit` reports a base clone group where the change edited exactly one copy, the edit broke the clone, and every other copy kept its text. The siblings can need the same change. A cosmetic edit that keeps the clone, a removed copy, a change that edits every copy, and an edit to a test or story copy do not report. Needs the base snapshot of `--gate new-only`. Opt-in: defaults to `off`, because copies often differ on purpose, for example an input and an output type, or a legacy copy. Set it to `warn` or `error` to review every diverged copy.",
1537 docs_path: "rules/diverged-clone-sibling",
1538 },
1539 RuleDef {
1540 id: "fallow/added-dependency",
1541 category: "Audit",
1542 name: "Added Dependencies",
1543 short: "The change adds a dependency",
1544 full: "`fallow audit` reports a dependency that the change adds to a `package.json`. A new dependency is often correct, so the rule defaults to `off`. Set it to `warn` or `error` to review every new package. An invented package name already fails as an unresolved import or an unlisted dependency.",
1545 docs_path: "rules/added-dependency",
1546 },
1547];
1548
1549pub const FLAGS_RULES: &[RuleDef] = &[
1551 RuleDef {
1552 id: "fallow/feature-flag",
1553 category: "Flags",
1554 name: "Feature Flags",
1555 short: "Detected feature flag pattern",
1556 full: "A feature flag pattern detected by `fallow flags`: environment-variable checks, flag SDK calls (LaunchDarkly, Unleash, and similar), or config-object lookups. Long-lived flags accumulate dead branches; review old flags for retirement and pair with dead-code analysis to find branches that can no longer execute.",
1557 docs_path: "rules/feature-flag",
1558 },
1559 RuleDef {
1560 id: "fallow/flag-retirement-candidate",
1561 category: "Flags",
1562 name: "Flag Retirement Candidate",
1563 short: "Feature flag is a retirement candidate",
1564 full: "A feature flag that `fallow flags --retirement` lists with at least one retirement reason: one read site, reads only in tests, a literal constant, identical or empty guard branches, guarded dead code, a definition that no code reads, or a vendor state from `--flag-state` (rolled out, archived, missing in the vendor export, or in the export only). The report is advisory. A person decides to remove the flag; Fallow does not remove code.",
1565 docs_path: "rules/flag-retirement-candidate",
1566 },
1567];
1568
1569pub const MUTATION_RULES: &[RuleDef] = &[RuleDef {
1571 id: "fallow/mutation-survived",
1572 category: "Tests",
1573 name: "Survived Mutants",
1574 short: "A small code change made no test fail",
1575 full: "`fallow mutation` makes one small change to the code, such as `>=` to `>`, and runs the tests that reach the changed line. A survived mutant is a change that made no test fail, so the tests do not check that behavior. The CI integrations report a survived mutant on a changed line as a warning finding (CodeClimate severity `minor`). The finding names the operator, the function and the mutant id, and never the source text. A mutant that no test reaches (`no_coverage`) is not a finding. No `rules.*` key gates the finding: the mutation score gate (`--min-score` or `mutation.minScore`) decides the exit code.",
1576 docs_path: "rules/mutation-survived",
1577}];
1578
1579macro_rules! security_catalogue_rule {
1580 ($id:literal, $name:literal, $cwe:literal) => {
1581 RuleDef {
1582 id: concat!("security/", $id),
1583 category: "Security",
1584 name: $name,
1585 short: concat!("Catalogue security candidate for CWE-", $cwe),
1586 full: concat!(
1587 $name,
1588 " is a data-driven `fallow security` tainted-sink catalogue category with CWE-",
1589 $cwe,
1590 " metadata. fallow reports it as an unverified candidate when a captured sink shape matches this category. Use it to understand or filter `security/",
1591 $id,
1592 "` findings, then inspect the trace, source, sink, sanitization, and application context before treating it as exploitable."
1593 ),
1594 docs_path: concat!("rules/", $id),
1595 }
1596 };
1597}
1598
1599pub const SECURITY_RULES: &[RuleDef] = &[
1602 RuleDef {
1603 id: "security/tainted-sink",
1604 category: "Security",
1605 name: "Tainted Sink Candidates",
1606 short: "Syntactic security sink candidates require verification",
1607 full: "The `tainted-sink` family covers data-driven `fallow security` catalogue categories. These findings are unverified candidates, not confirmed vulnerabilities. fallow can connect known source signals to captured sink shapes and add CWE metadata, but it does not prove attacker control, missing sanitization, exploitability, or business impact.",
1608 docs_path: "rules/tainted-sink",
1609 },
1610 RuleDef {
1611 id: "security/client-server-leak",
1612 category: "Security",
1613 name: "Client-server Secret Leak Candidates",
1614 short: "Client-bound code reaches a non-public env read",
1615 full: "`client-server-leak` reports a candidate when a `use client` module can transitively reach a static non-public `process.env` or `import.meta.env` read. Public-by-convention env prefixes are treated as public. The finding is advisory and still needs bundle, framework, and runtime verification before treating it as a real exposure.",
1616 docs_path: "rules/client-server-leak",
1617 },
1618 RuleDef {
1619 id: "security/hardcoded-secret",
1620 category: "Security",
1621 name: "Hardcoded Secret Candidates",
1622 short: "Provider-prefixed or contextual secret literals require verification",
1623 full: "`hardcoded-secret` reports opt-in candidates for provider-prefixed or contextual secret-shaped literals. The category is include-required and only runs when listed in `security.categories.include`. It avoids raw entropy alone, but every result still requires review, secret rotation decisions, and context before acting.",
1624 docs_path: "rules/hardcoded-secret",
1625 },
1626 security_catalogue_rule!("dangerous-html", "Dangerous HTML sink", "79"),
1627 security_catalogue_rule!(
1628 "template-escape-bypass",
1629 "Template escape bypass sink",
1630 "79"
1631 ),
1632 security_catalogue_rule!("command-injection", "OS command injection sink", "78"),
1633 security_catalogue_rule!("code-injection", "Code injection sink", "94"),
1634 security_catalogue_rule!("dynamic-regex", "Dynamic regular expression sink", "1333"),
1635 security_catalogue_rule!("redos-regex", "ReDoS regex sink", "1333"),
1636 security_catalogue_rule!(
1637 "resource-amplification",
1638 "Resource amplification sink",
1639 "400"
1640 ),
1641 security_catalogue_rule!("dynamic-module-load", "Dynamic module load sink", "95"),
1642 security_catalogue_rule!("sql-injection", "SQL injection sink", "89"),
1643 security_catalogue_rule!("ssrf", "Server-side request forgery sink", "918"),
1644 security_catalogue_rule!(
1645 "secret-to-network",
1646 "Secret reaches a network request",
1647 "201"
1648 ),
1649 security_catalogue_rule!("path-traversal", "Path traversal sink", "22"),
1650 security_catalogue_rule!(
1651 "header-injection",
1652 "HTTP response header injection sink",
1653 "113"
1654 ),
1655 security_catalogue_rule!("open-redirect", "Open redirect sink", "601"),
1656 security_catalogue_rule!(
1657 "postmessage-wildcard-origin",
1658 "Wildcard postMessage target origin",
1659 "346"
1660 ),
1661 security_catalogue_rule!("tls-validation-disabled", "TLS validation disabled", "295"),
1662 security_catalogue_rule!("cleartext-transport", "Cleartext transport URL", "319"),
1663 security_catalogue_rule!(
1664 "electron-unsafe-webpreferences",
1665 "Unsafe Electron BrowserWindow preferences",
1666 "1188"
1667 ),
1668 security_catalogue_rule!(
1669 "world-writable-permission",
1670 "World-writable chmod mode",
1671 "732"
1672 ),
1673 security_catalogue_rule!(
1674 "insecure-temp-file",
1675 "Predictable temporary file path",
1676 "377"
1677 ),
1678 security_catalogue_rule!(
1679 "mysql-multiple-statements",
1680 "MySQL multiple statements enabled",
1681 "89"
1682 ),
1683 security_catalogue_rule!("permissive-cors", "Permissive CORS policy", "942"),
1684 security_catalogue_rule!("insecure-cookie", "Insecure cookie options", "614"),
1685 security_catalogue_rule!("mass-assignment", "Mass assignment sink", "915"),
1686 security_catalogue_rule!("weak-crypto", "Runtime-selectable crypto algorithm", "327"),
1687 security_catalogue_rule!("insecure-randomness", "Insecure randomness sink", "338"),
1688 security_catalogue_rule!("jwt-alg-none", "JWT alg none", "347"),
1689 security_catalogue_rule!(
1690 "jwt-verify-missing-algorithms",
1691 "JWT verify missing algorithms allowlist",
1692 "347"
1693 ),
1694 security_catalogue_rule!("deprecated-cipher", "Deprecated cipher constructor", "327"),
1695 security_catalogue_rule!(
1696 "unsafe-buffer-alloc",
1697 "Unsafe Buffer allocation sink",
1698 "1188"
1699 ),
1700 security_catalogue_rule!(
1701 "unsafe-deserialization",
1702 "Unsafe deserialization sink",
1703 "502"
1704 ),
1705 security_catalogue_rule!(
1706 "angular-trusted-html",
1707 "Angular bypassSecurityTrust sink",
1708 "79"
1709 ),
1710 security_catalogue_rule!("nextjs-open-redirect", "Next.js open redirect sink", "601"),
1711 security_catalogue_rule!(
1712 "react-router-open-redirect",
1713 "React Router open redirect sink",
1714 "601"
1715 ),
1716 security_catalogue_rule!("dom-document-write", "DOM document.write sink", "79"),
1717 security_catalogue_rule!("jquery-html", "jQuery .html() sink", "79"),
1718 security_catalogue_rule!(
1719 "route-send-file",
1720 "Route file-send path traversal sink",
1721 "22"
1722 ),
1723 security_catalogue_rule!("webview-injection", "WebView injected-script sink", "94"),
1724 security_catalogue_rule!("prototype-pollution", "Prototype pollution sink", "1321"),
1725 security_catalogue_rule!("zip-slip", "Archive path-traversal (zip-slip) sink", "22"),
1726 security_catalogue_rule!("nosql-injection", "NoSQL injection sink", "943"),
1727 security_catalogue_rule!("ssti", "Server-side template injection sink", "1336"),
1728 security_catalogue_rule!("xxe", "XML external entity (XXE) sink", "611"),
1729 security_catalogue_rule!("secret-pii-log", "Secret or PII logged", "532"),
1730 security_catalogue_rule!("xpath-injection", "XPath injection sink", "643"),
1731 security_catalogue_rule!(
1732 "llm-call-injection",
1733 "Untrusted input reaches an LLM call",
1734 "1427"
1735 ),
1736];
1737
1738#[must_use]
1740pub fn security_meta() -> fallow_types::envelope::Meta {
1741 fallow_output::security_meta(SECURITY_RULES.iter().map(|rule| {
1742 fallow_output::SecurityRuleMeta {
1743 id: rule.id,
1744 name: rule.name,
1745 description: rule.full,
1746 docs_path: rule.docs_path,
1747 }
1748 }))
1749}
1750
1751#[must_use]
1753pub fn coverage_setup_meta() -> Value {
1754 fallow_output::coverage_setup_meta()
1755}
1756
1757#[must_use]
1759pub fn coverage_analyze_meta() -> Value {
1760 fallow_output::coverage_analyze_meta()
1761}
1762
1763#[cfg(test)]
1764#[expect(
1765 clippy::unwrap_used,
1766 reason = "registry tests intentionally index fixture JSON"
1767)]
1768#[path = "explain_tests.rs"]
1769mod tests;