> ## Documentation Index
> Fetch the complete documentation index at: https://loadwise.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Maintainability checker

> loadwise maint: design advisories and the architecture rules a team declares.

`loadwise maint` finds code that would benefit from a design review and enforces the architectural decisions a team has already made. Run it on a project folder with `npx loadwise maint .`, or `npx loadwise maint . --json`. The default `--fail-on contract` exits 1 only for a declared folder, data-access or query contract violation; design advisories stay visible and exit 0 on their own. A non-JavaScript file a native parser cannot read and missing required parser binaries exit 2. Contextual findings include documented independent test oracles, before/after source snapshots with a live counterpart, marked generated code, certain flat data mappings and literal message lists, and a Nest module cycle whose internal eager edges are all explicit `forwardRef` callbacks (not available for graph input).

## What gets checked

* [`data-access-boundary`](https://loadwise.mintlify.site/rules/maintainability/data-access-boundary) (medium): A file outside the approved paths imports a configured database driver or ORM.
* [`deep-control-flow`](https://loadwise.mintlify.site/rules/maintainability/deep-control-flow) (low): Control structures are nested four levels deep.
* [`dependency-cycle`](https://loadwise.mintlify.site/rules/maintainability/dependency-cycle) (high): An eager chain of internal imports leads back to the module it started from.
* [`deprecated-node-api`](https://loadwise.mintlify.site/rules/maintainability/deprecated-node-api) (medium): A deprecated Node.js API is used: new Buffer(), url.parse() or fs.exists().
* [`double-type-assertion`](https://loadwise.mintlify.site/rules/maintainability/double-type-assertion) (low): A value is cast through unknown or any to a second type, bypassing the type checker.
* [`duplicate-implementation`](https://loadwise.mintlify.site/rules/maintainability/duplicate-implementation) (medium): Substantial functions share the same implementation.
* [`explicit-any`](https://loadwise.mintlify.site/rules/maintainability/explicit-any) (low): An explicit any type turns off type checking for a value.
* [`file-placement`](https://loadwise.mintlify.site/rules/maintainability/file-placement) (low): A file with a configured suffix sits outside its allowed folders.
* [`focused-test-committed`](https://loadwise.mintlify.site/rules/maintainability/focused-test-committed) (medium): A committed .only, only: true, fit or fdescribe can make the test runner skip other tests.
* [`folder-boundary`](https://loadwise.mintlify.site/rules/maintainability/folder-boundary) (medium): An import crosses a folder boundary the team declared.
* [`high-branch-complexity`](https://loadwise.mintlify.site/rules/maintainability/high-branch-complexity) (medium): A function reaches a branch complexity score of 15.
* [`large-class`](https://loadwise.mintlify.site/rules/maintainability/large-class) (low): A class has more than 30 methods, accessors, constructors or function-valued fields.
* [`large-module`](https://loadwise.mintlify.site/rules/maintainability/large-module) (low): A file has more than 600 lines of code.
* [`long-parameter-list`](https://loadwise.mintlify.site/rules/maintainability/long-parameter-list) (low): A function takes more than 5 positional parameters.
* [`python-interactive-debugger`](https://loadwise.mintlify.site/rules/maintainability/python-interactive-debugger) (medium): A Python call enters an interactive debugger in production source.
* [`query-mutates-state`](https://loadwise.mintlify.site/rules/maintainability/query-mutates-state) (medium): A method marked @maintainabilityQuery writes through this.
* [`stray-console`](https://loadwise.mintlify.site/rules/maintainability/stray-console) (low): A console call in production code bypasses the logger, so its output has no level or structure.
* [`ts-suppression-without-reason`](https://loadwise.mintlify.site/rules/maintainability/ts-suppression-without-reason) (low): A @ts-ignore, @ts-expect-error or @ts-nocheck directive has no explanation.
* [`tsconfig-strict-disabled`](https://loadwise.mintlify.site/rules/maintainability/tsconfig-strict-disabled) (medium): A tsconfig turns off strict type checking.
* [`unreferenced-file`](https://loadwise.mintlify.site/rules/maintainability/unreferenced-file) (low): A source file that nothing imports and that is not an entry point.
* [`unsafe-wide-type`](https://loadwise.mintlify.site/rules/maintainability/unsafe-wide-type) (low): A Function, Object or \{} type accepts almost any value, so the compiler checks little.
* [`unused-export`](https://loadwise.mintlify.site/rules/maintainability/unused-export) (low): An export that no scanned file imports.
* [`unused-import`](https://loadwise.mintlify.site/rules/maintainability/unused-import) (low): An imported name is never used in the file.
* [`unused-local-function`](https://loadwise.mintlify.site/rules/maintainability/unused-local-function) (low): A private function declaration has no references.
* [`unused-local-variable`](https://loadwise.mintlify.site/rules/maintainability/unused-local-variable) (low): A local variable is assigned but never read.

JS and TS use the TypeScript parser; the optional ast-grep executable supplies parsers for Python, Go, Java, C#, Rust, PHP, Ruby, Kotlin, C and C++ (a `.h` file uses the C grammar). Direct import extraction is provided for JS/TS: it resolves project-local modules and TypeScript paths and ignores type-only imports. Discovery uses tracked and nonignored untracked Git files where available and a directory walk elsewhere, skipping dependency directories and minified files; `build`, `dist`, `coverage`, `target` and `vendor` are skipped only at the scanned root or beside a project manifest such as `package.json`.

## Project rules

Save team decisions in the `maintainability` section of `loadwise.config.json` at the project root, or pass `--config path/to/policy.json`.

```json theme={null}
{
  "boundaries": [{ "from": "src/domain", "disallow": ["src/http"] }],
  "placement": [{ "suffix": "_adapter.py", "under": ["adapters", "integrations"] }],
  "dataAccess": { "modules": ["pg", "@prisma/client", "./src/generated"], "allowIn": ["src/data"] },
  "limits": { "largeModuleLines": 600, "largeClassMembers": 30, "longParameterCount": 5 },
  "exclude": ["third_party/legacy"]
}
```

`limits` sets the thresholds of `large-module`, `large-class` and `long-parameter-list` (positive integers; the values shown are the defaults). `dataAccess` restricts runtime imports of named packages, their subpaths, module aliases (`#models`, `@/db`) or project-local entry points (starting with `./`, matched by resolved file) to the paths in `allowIn`; both lists are required and nonempty, type-only imports are not reported, and findings are contract violations. Paths are project-relative, directory boundaries match complete segments, and the longest matching filename suffix wins.

## A module graph in any language

```json theme={null}
{
  "files": ["src/domain/order.ex", "src/http/handler.ex"],
  "edges": [
    { "from": "src/domain/order.ex", "to": "src/http/handler.ex", "line": 3, "column": 1 }
  ]
}
```

```sh theme={null}
npx loadwise maint . --graph modules.json --config policy.json
```

List each project-relative module once. Edges use one-based source coordinates; set `"kind": "deferred"` for an edge that loads lazily. Graph mode operates entirely on the supplied inventory and edges, for a graph from a compiler, build system or dependency extractor.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.