code_quality_cli 1.0.1
code_quality_cli: ^1.0.1 copied to clipboard
Installable CLI that audits a Flutter/Dart project's assets, source code, and pubspec dependencies with a shared, colorized report format.
code_quality_cli #
A single, installable CLI that audits a Flutter/Dart project's assets,
source code, and pubspec dependencies — one discoverable command,
a shared colorized report format, and a --json mode CI can gate on.
Install #
Run in place, from this repo:
dart pub get
dart run bin/code_quality_cli.dart --help
Or activate it globally so code_quality_cli is on your PATH from any
project:
dart pub global activate --source path .
code_quality_cli --help
Usage #
code_quality_cli <command> [options]
| Command | What it checks |
|---|---|
assets |
Unused assets, broken (missing/unregistered) references, dynamic references |
code |
Unused files, comment-heavy files, commented-out dead code, largest files |
packages |
Unused/missing/unpinned dependencies, dev-dep-in-lib and lib-dep-in-test-only miscategorization |
all |
Runs all three and prints a combined scorecard |
Run with no arguments in an interactive terminal and it will prompt you for
which audit to run (and, for code/all, the comment-density limit) instead
of just printing usage.
Global options #
| Flag | Default | Meaning |
|---|---|---|
-p, --path=<dir> |
. |
Project root to audit |
--json |
off | Emit machine-readable JSON instead of the report |
--no-color |
(auto) | Disable ANSI colors (auto-disabled outside a terminal) |
--strict |
off | Exit non-zero on warnings too, not just errors |
-v, --verbose |
off | Show full lists instead of truncating to 10 items per section |
-h, --help |
Print usage |
code-only options #
| Flag | Default | Meaning |
|---|---|---|
--comment-limit=<percent> |
20 |
Flag files whose comment lines exceed this percent |
--top=<n> |
10 |
Largest-files leaderboard size |
Examples #
# Audit assets in the current project
code_quality_cli assets
# Audit another repo, failing CI on warnings too
code_quality_cli all --path ../other_app --strict
# Flag files >30% comments, machine-readable output
code_quality_cli code --comment-limit 30 --json
Exit codes #
| Code | Meaning |
|---|---|
0 |
No errors (warnings are fine unless --strict) |
1 |
At least one error-level finding (or any finding, under --strict) |
2 |
Tool failure — bad arguments, unreadable/missing project |
Programmatic use #
Each audit is a pure, injectable function (auditAssets, auditCode,
auditPackages) that only touches the filesystem under a given repoRoot,
independent of the CLI:
import 'package:code_quality_cli/code_quality_cli.dart';
final result = auditAssets(repoRoot: '/path/to/project');
print(result.unusedAssets);
Development #
dart pub get
dart analyze
dart test
test/fixtures/sample_project/ is a small, hand-built Dart project with
deliberate issues (a broken asset reference, an unused file, a missing
dependency, ...) that the test suite runs the real audits against — see
test/audits/*_test.dart and test/cli/*_test.dart.