anal 0.3.2
anal: ^0.3.2 copied to clipboard
A pluggable static analysis framework for Dart and Flutter projects with an extensible runner, rule registry, and CLI.
Changelog #
Unreleased #
Added #
- New default-on
unused_source_filerule. It flags Dart source files in the analyzed set that are never reached from any entry point via animport,export, orpartdirective. Entry points are files underbin/ortest/, files that declare a top-levelmain, andlib/<package>.dartplus any other file sitting directly underlib/(i.e. not nested insidelib/src/). Generated-file basenames such as*.g.dartand*.freezed.dartare skipped defensively even when the runner's default excludes are turned off. Diagnostics are emitted atSeverity.warning. The rule is registered by the built-in CLI and enabled automatically. Runningdart run analagainst a project that previously produced no diagnostics may now surface new warnings from this rule. - New
MultiFileAnalyzerRuleextension point for custom rules that need to reason across multiple files in a single invocation (for example to build an import graph or a cross-file symbol index). Multi-file rules are registered with the sameRuleRegistryasAnalyzerRuleimplementations and are dispatched once per run with the full set of resolved compilation units. ExistingAnalyzerRuleimplementations continue to be dispatched once per file and do not need any changes. - New
--no-default-excludesCLI flag that opts out of the built-in default exclude patterns. Pair it with explicit--excludeflags when you want full control over which paths are skipped. - New
AnalOptions.defaultExcludePathsconstant exposing the list of glob patterns excluded byAnalOptions.defaults(). Useful when composing customAnalOptionsinstances programmatically. - New default-on
unused_functionrule. It flags file-local function declarations that are never referenced, specifically private top-level functions in libraries that have nopartfiles and local function declarations inside another function or method body. Diagnostics are emitted atSeverity.warning. The rule is registered by the built-in CLI and enabled automatically. Runningdart run analagainst a project that previously produced no diagnostics may now surface new warnings from this rule. - New default-on
unused_classrule. It flags file-local declarations that are never referenced within the same compilation unit, coveringclass,mixin,enum, andextension typedeclarations whose names begin with_. The rule only runs against libraries that have nopartfiles and skips declarations annotated with@pragma('vm:entry-point'). Diagnostics are emitted atSeverity.warning. The rule is registered by the built-in CLI and enabled automatically. Runningdart run analagainst a project that previously produced no diagnostics may now surface new warnings from this rule. - Open-source project guidance, issue templates, pull request checklist, security policy, code of conduct, and Dependabot configuration.
- Coverage artifact upload to CI.
.pubignoreto keep automation and assistant-only files out of the published package archive..gitattributesfor predictable text file line endings.
Changed #
- Updated CI and release automation to target the repository default branch.
- Tightened package metadata for pub.dev discovery.
- Widened the analyzer dependency to
>=9.0.0 <13.0.0so projects usingfreezed >=3.2.5can addanalwithout a version-solver conflict.
Fixed #
- Fixed directory include discovery on Windows.
analis now installable alongsidefreezed ^3.2.5.dart run anal --versionnow prints the correct package version (0.2.0) instead of the stale hardcoded0.1.0.- Restored analyzer 9.0.0 compatibility for the
unused_classrule. The rule previously reached intoExtensionTypeDeclaration.primaryConstructor, which only exists in analyzer 10+, causing a build break for consumers pinned to analyzer 9.0.0 ('primaryConstructor' isn't defined for the type 'ExtensionTypeDeclaration'). The rule now uses the cross-versionExtensionTypeDeclaration.nameaccessor.
Changed #
- Default exclude patterns now include
*.g.dartand*.freezed.dart. Pass an emptyexcludePaths(or--no-default-excludeson the CLI) to opt out. --excludenow layers on top of the default excludes instead of replacing them. Patterns you pass are added to the built-in defaults; use--no-default-excludesif you need to suppress the defaults.
0.3.1 - 2026-05-27 #
0.3.0 - 2026-05-27 #
0.2.0 - 2026-05-27 #
⚠ BREAKING CHANGES #
- api: Calculator is removed from the public API.
Features #
- add Severity, SourceLocation, Diagnostic value types (0b965cd)
- api: re-export public surface from lib/anal.dart (4cef459)
- cli: add bin/anal.dart CLI entry point (ae0fa3b)
- frame basics (44c400e)
- options: add AnalOptions value class (2c0cb6c)
- reporter: add Reporter abstraction and ConsoleReporter (85e556d)
- rules: add AnalyzerRule contract, AnalysisContext, RuleRegistry (0e45827)
- rules: add unused_class rule (4adcd8e)
- rules: add unused_function rule (84e9528)
- rules: register unused_function rule in CLI (2ea76c1)
- runner: add AnalysisRunner orchestrator and smoke test (b721079)
0.1.0 #
- Added a pluggable static-analysis framework for Dart and Flutter projects:
AnalyzerRule: abstract plugin contract for custom rules.Diagnostic,Severity,SourceLocation: value types describing analysis findings.AnalysisContext: carrier passed into each rule invocation, exposing the resolved compilation unit.RuleRegistry: in-memory registration and lookup of rules, with duplicate-id rejection.AnalysisRunner: orchestrator that resolves target files, dispatches rules, and collects diagnostics.AnalOptions: value class describing include/exclude paths and enabled rule ids.Reporter/ConsoleReporter: pluggable diagnostic output, with a stdout implementation.- CLI executable
anal(dart run anal) with--help,--version,--rules, and--excludeflags.
BREAKING CHANGE #
- Removed the
Calculatorstub that shipped in0.0.1. Consumers that depended on it must remove the import; it was a generator placeholder and not part of any intended public API.
0.0.1 #
- Initial package scaffold.