dallow 0.4.0
dallow: ^0.4.0 copied to clipboard
Codebase intelligence for Dart and Flutter. Finds unreachable dead code, dependency drift, circular imports, duplicate blocks, and complexity hot spots.
Changelog #
0.4.0 - 2026-11-24 #
Breaking #
- Duplication's default minimum block is
50tokens, up from20. Pass--min-block-size 20to restore the old threshold. - Duplication skips test code (
test/,integration_test/,test_driver/) unless--include-testsorduplication.include-tests: trueis set. - The health score is measured against declared functions, so closures no longer dilute it: 4 points per percent of functions over the complexity limit, and 1 point per weighted finding per hundred functions. Scores are lower than in 0.3.0 for the same code.
- Library:
analyzeandanalyzeWorkspacerun every check by default, including complexity, as thedallow analyzecommand does.SarifReporterno longer implementsReporter;Reporter(ReportFormat.sarif)is unchanged. - A package whose own source cannot be resolved is refused with exit
78.--allow-unresolvedanalyses it anyway and reports each gap as anunresolved-sourcewarning (#23).
Added #
dallow.yamlconfiguration:excludeglobs,fail-on, per-kindrules,dependencies.ignore,circular.max-cycle-size,duplication.*andcomplexity.max-complexity.--config <file>names another file. A recursive run falls back from each package to the workspace root. Unknown keys, wrong types and invalid globs exit64.- Generated code (
*.g.dart,*.freezed.dart,*.gr.dart,*.mocks.dart,*.gen.dart, protobuf outputs, and files with a generated-code banner) is left out of the findings and the health score while still feeding the symbol graph.flutter gen-l10noutput is recognised froml10n.yamlor the tool's defaults.--include-generatedreports it. - The health message carries a letter grade (A–F) and the number of functions over the complexity limit.
dallow --versionprints the dallow andanalyzerversions.- Library:
analyzeandanalyzeWorkspacetakeconfig:,reportGenerated:andduplicationIncludesTests:, and accept a relative path.DallowConfig,RuleLevel,ConfigExceptionandSourceScopeare exported. doc/open-source-runs.mdreports results on five open-source projects, anddoc/fallow-parity.mdcompares dallow with fallow.
Fixed #
Dead code no longer reports:
- members of a generic class or extension reached through an instantiated type;
- fields read only through
++,+=or??=, and setters or[]=operators invoked only by assignment; - operators,
call()methods and getters read through an object pattern; - public members inherited by an exported type from an unexported supertype;
- symbols referenced only from an unnamed extension;
- constants used only as an annotation on a field or top-level variable;
- fields of a
dart:ffiStructorUnion; - getters whose setter is in use;
- symbols annotated
@pragma('vm:entry-point'); - the alternates of a conditional import or export, including extension members (#24).
Other fixes:
- Dependencies: imports are read from parsed directives, so an
importline inside a string literal is no longer reported as a missing dependency.build_configandsky_engineare not reported unused. - Duplication: directives are excluded, so files that share an import header no longer match each other (#15).
- Health score: a duplicated block weighs
tokens / minBlockSize(#25). --changed-sincereturned an empty change set when the package path contained a symbolic link.analyzecompletes on Dart 3.10 dot shorthands in constant contexts.
Performance #
- Duplication is about 40 times faster on large packages, with identical findings.
0.3.0 - 2026-06-28 #
- Dependencies: upgrade
analyzerfrom^7.0.0to^14.0.0. This migrates the symbol graph and dead-code check off the legacy element model onto analyzer's unifiedElement/FragmentAPI: source locations and the synthetic-property distinction now come from fragments (firstFragment,isOriginDeclaration), declaration nodes are resolved viadeclaredFragmentrather thandeclaredElement, andClassDeclaration/EnumDeclarationnames are read from theirnamePart. Behaviour is unchanged — all checks produce identical findings. No CLI or output changes.
0.2.1 - 2026-06-25 #
- Packaging: add an
example/(CLI usage walkthrough) and a.pubignorethat drops thetest/andtool/trees from the published archive — the test fixtures deliberately import undeclared packages to exercise the deps check, which pub flagged as packaging warnings. - Metadata: broaden the package description to name the duplication and
complexity checks, add pub.dev
topics, and declareissue_tracker.
0.2.0 - 2026-06-25 #
-
Complexity: added a resolved-AST cyclomatic-complexity check for functions, methods, constructors, and closures, plus a
complexitysubcommand and--max-complexitythreshold. Findings above the threshold are warnings; findings at least twice the threshold are errors. -
Health score:
analyze/complexitynow emit an info-level project-health finding with a deterministic 0–100 score derived from complexity excess and non-complexity finding density. -
PR gate: inline
dallow-ignoresuppression. A// dallow-ignorecomment on a finding's line — or the line directly above it — removes that finding before the gate, so it neither prints nor affects the exit code. Scope it to one check with// dallow-ignore: <check-kind>(a comma-separated list, plus an optional trailing reason). Comments are read from the analyzer's token stream rather than by scanning text, and suppression composes with--changed-sinceand--baseline(applied first, against the raw findings).--report-unused-ignoressurfaces stale directives that matched nothing as info-levelunused-ignorefindings. -
SARIF output:
--format sarifemits a SARIF 2.1.0 log for code-scanning platforms (e.g. GitHub Advanced Security). The singlerunadvertises one rule per check kind (tool.driver.rules, with ashortDescriptionand adefaultConfiguration.levelmapped from severity —error/warning/note), and oneresultper finding (ruleId= check kind, mappedlevel, message, and aphysicalLocationwith a relative POSIX URI +region.startLineonly when the finding has both a file and a line). Whole-package andpubspec.yaml-level findings (a file but no line) are emitted as valid results without aphysicalLocation, since GitHub code-scanning needsregion.startLineand would otherwise pin a region-less location to line 1. Wired through--formaton every subcommand. -
PR gate:
--changed-since <ref>filters findings to files changed since a git ref (merge-base<ref>...HEAD); whole-package andpubspec.yamlfindings are always kept, and a non-git tree or bad ref exits64with a clear message instead of crashing. -
PR gate:
--baseline <file>suppresses findings recorded in a JSON baseline, and--write-baseline <file>captures the current findings as one (exit0), so a team can adopt the gate on a dirty codebase and fail only on new findings. Baseline entries are matched by a line-independent fingerprint (kind + file + symbol + normalised message), so they survive line shifts. The filters compose and apply to every subcommand. -
Duplication: added a token-level duplicate-code check,
duplicationsubcommand,analyzewiring, and--min-block-sizethreshold. -
Dead code: now reports unused class members (methods, getters/setters, fields), not just top-level symbols, on the resolved element graph. A member is flagged when it is private (or belongs to a non-public-API
lib/srcclass) and unreachable from any entrypoint. Members reached through inheritance — an@override, an interface implementation, or a member overridden by a subtype — are kept (they may be dispatched dynamically), as are public members of public-API classes and fields initialised through athis.xconstructor parameter. Member findings carry a qualifiedEnclosingType.membersymbol. -
Monorepos: new
-r, --recursiveflag onanalyze(and every sub-command) discovers and analyses all member packages in one run, instead of the single-package default. Packages are found from amelos.yamlpackages:globs list (honouringignore:), a pub-workspaceworkspace:member list, or, failing both, every nestedpubspec.yaml; build/tooling/symlink dirs are skipped. Findings are attributed to their package (console/markdown prefix, JSONpackagefield) and--fail-onis evaluated across all packages. -
Dead code: register Dart 3
extension typedeclarations, so a dead one is flagged (labelled "extension type") instead of silently skipped. -
Circular imports:
--max-cycle-sizenow rejects values below the smallest possible cycle (2) with a usage error, instead of silently disabling the check. -
Docs: README exit-codes section now documents
64(usage) and69(no SDK) alongside0/1. -
Build:
tool/build.shaborts loudly if no platform binary was produced, rather than packaging a binary-less zip. -
Deps: federated plugin implementations (
<base>_web,<base>_android,<base>_platform_interface, …) are no longer flagged as unused when their base plugin is a declared dependency. -
Circular imports: long cycle membership is truncated in the message with an "(+N more)" suffix, and a new
--max-cycle-sizeflag skips cycles above a given size (e.g. a known barrel mega-cycle) while still catching small ones. -
Dead code: skip synthetic elements at registration, so an explicit getter's synthetic backing variable is no longer reported as a phantom dead symbol.
-
Dead code: seed each public library's export namespace as a reachability root, so
lib/src/symbols surfaced through a barrel re-export are no longer false-flagged. -
Dead code: track references made inside
typedefdeclarations; symbols used only through a typedef are no longer false-flagged. -
Dead code: derive the symbol-kind label from the resolved element type rather than
runtimeType.toString(). -
Deps: anchor the
package:scan toimport/exportdirective lines so mentions in comments or strings no longer count as usage. -
Circular imports: reworded to "Dependency cycle among N files" (the graph includes export edges; members are listed, not a traversal path).
-
Extracted the exit-code gate into
exitCodeForfor direct testing. -
Tests: re-export and typedef regressions, misplaced-dependency, reporters, and exit-code gating.
0.1.0 #
Initial release.
dead-code: reachability-based dead-code detection over the resolvedanalyzerelement graph.deps: dependency hygiene againstpubspec.yaml(unused, missing, and misplaced dependencies).circular: import-cycle detection via strongly-connected components.analyze: runs every check.console,json, andmarkdownoutput formats with--fail-onexit-code gating.