kareki 0.4.2
kareki: ^0.4.2 copied to clipboard
A multi-package dead code detector for Dart and Flutter monorepos. Finds unused public APIs, files, and pub dependencies across Melos / pub workspaces.
Changelog #
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
0.4.2 #
Changed #
- Renamed the top-level
docs/directory todoc/to follow the pub package layout convention (singular). Internal links inREADME.md,README.ja.md, andexample/example.mdwere updated accordingly. No code or public API change. - Restructured
example/into a runnable minimum Dart package (example/pubspec.yaml,bin/,lib/,test/). Every file underlib/is wired so thatdart run kareki --root exampleproduces exactly one finding per rule — six in total — letting users see what each detector actually catches instead of reading a static sample.example/example.mdwas rewritten as a layout / per-rule walkthrough.
Added #
- CI step
Verify example/ exercises every rule(in.github/workflows/ci.yaml) backed bytool/verify_example.dart. Runs kareki againstexample/and asserts that every id inRuleId.allfires exactly once, so the example cannot silently drift out of sync with the detectors it is meant to demonstrate. Adding a new rule without updatingexample/now fails CI.
0.4.1 #
Added #
- New rule
unused_parameter_optional: flags optional parameters (named or positional optional) of a function, method, or constructor that are never passed by any call site in the workspace. This is the public / cross-package counterpart to Dart's built-inunused_element_parameter, which only inspects private optional parameters within a single library. Detection is based on simple-name call-site aggregation across every parsed file (generated files included as legitimate consumers). Inherits the same exemptions asunused_parameter—@override, abstract / external / native /UnimplementedErrorstub bodies, operators,this.x/super.x, the_/__placeholder convention, and any declaration kept alive by a configured keep-alive annotation. Suppress per file with// kareki: ignore_for_file=unused_parameter_optionalor globally viaignore.rules:inkareki-config.yaml.
0.4.0 #
Added #
- Japanese translations of the README and every page under
docs/(README.ja.md,docs/*.ja.md). Each English page now links to its Japanese counterpart and vice versa. (Retroactive entry for #5, which was merged without a changelog update.) - New rule
unused_parameter: flags parameters declared by a function, method, or named constructor that are never referenced in the body or initializers. Covers required and optional parameters, public and private — a strict superset of Dart's built-inunused_element_parameter(which only flags private optional parameters never passed at a call site). Skips@override, abstract / external / native callables, operators,this.x/super.x, the_/__placeholder convention, any declaration kept alive by a configured keep-alive annotation, and stub bodies whose only statement isthrow UnimplementedError(...)(federated pluginPlatformInterfacebase methods). Callback functions whose signature is constrained by a typedef (e.g. auto_routeCustomRouteBuilder/AutoRouteGroupconformers) are intentionally still flagged so the unused parameter is surfaced — rename to_to preserve typedef conformance while signaling intent. Suppress remaining cases via// kareki: ignore_for_file=unused_parameterorignore.rules: [unused_parameter]inkareki-config.yaml.
Changed #
- Top-level
README.mdhas been split into focused pages underdocs/(CLI reference, configuration, baseline, doctor, how-it-works). The root README now serves as a short overview with links into the detailed docs. (Retroactive entry for #5.)
0.3.0 #
Added #
- Baseline support — adopt kareki on an existing codebase without first
resolving every finding.
dart run kareki --baseline <path> --write-baselinesnapshots the current findings to a JSON file; subsequent runs that point at the same baseline (either via--baselineorbaseline:inkareki-config.yaml) suppress those findings from the output and the exit code, while any new finding still fails the run. The baseline file uses a<root>/placeholder for the workspace path embedded in eachstableId, so it is portable across machines and CI checkouts. Entries are sorted by(ruleId, stableId)for clean diffs. kareki doctornow reportsunused-baseline-entryfor any baseline entry whose(ruleId, stableId)no longer matches a current finding — the suppressed dead code has been deleted or relocated and the baseline is ready to be regenerated.
0.2.0 #
Added #
- New
kareki doctorsubcommand: validateskareki-config.yamlagainst the workspace and reports staleexclude.filesglobs,ignore.packages/ignore.dependenciesentries pointing at packages or deps that no longer exist, and// kareki: ignore_for_file=<rule>directives that suppress no actual finding. Only user-supplied entries are checked — built-in defaults are never flagged.textandjsonoutput formats are supported via--format.
Fixed #
// kareki: ignore_for_file=<rule>was silently no-op when the directive line was followed by a blank line and animportstatement (instead of another comment line). The regex used\sinside the rule capture, which let\nand subsequent source characters bleed into the captured value until a non-\w/\scharacter (typically the string quote in the nextimport 'package:...';) was reached; comma-split + trim then produced corrupted tokens that never matched any real rule id. The capture now stops at end-of-line.
0.1.1 #
Added #
- New rule
test_only_used: flags public declarations underlib/that are only reachable from test entry points (*_test.dart,test/,integration_test/). Detects the "code that exists only because its tests exist" anti-pattern that the standard reachability analysis misses because test files are themselves entry points. EntryPointSetnow exposesproductionRootNames/testRootNamesfor callers that need to distinguish production vs test consumption.ReachabilityBfs.computeaccepts an optionalfiltercallback so callers can constrain BFS traversal (used bytest_only_usedto keep production BFS from crossing into test source via shared simple names likemain).
0.1.0 #
Initial release.
- Rules:
unused_element,unused_file,unused_pub_dependency. - Multi-package workspaces via
melos.yaml/ pub workspaces. - Built-in presets:
freezed,json_serializable,riverpod,auto_route,go_router,drift,hive,meta. - Configuration via
kareki-config.yamlwith full override and custom preset support. - CLI:
dart run karekiwith--format,--packages,--rule,--strict. - Dart
>=3.10.0, analyzer^9.0.0.