ciach
0.7.2, released 10 days ago by leancode.co
Dead code detector for Dart and Flutter that finds and removes unused declarations.
What it does
Analyzes Dart and Flutter source code to find unused classes, functions, methods, fields, and enum values. It can generate reports in various formats or automatically remove the dead code.
AI-written summary of version 0.7.2, based on the package's README and metadata. Report an inaccuracy
Use it when
- Cleaning up legacy codebases and removing obsolete classes or functions
- Integrating dead code detection into CI pipelines to prevent accumulation of unused code
Skip it when
- Working with heavy reflection or dynamic invocation patterns that cannot be statically resolved
- Relying fully on automated removal without manual review
Strengths
- Supports automatic removal of found dead code with interactive prompts or force options
- Understands framework entry points, generated files, and avoids many false positives
- Integrates into multiple CI formats like GitHub Actions, Azure, and SARIF
Weaknesses
- Static heuristic-based analysis can still yield false positives requiring manual code review
- May struggle to detect references used only through dynamic code or complex reflection
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 12
Install as a global tool or add as a dev dependency in pubspec.yaml and run dart run ciach.
import 'package:ciach/ciach.dart';
final result = await Ciach(
FinderOptions(rootPath: 'path/to/package', includePublic: false),
).run();
for (final decl in result.unused) {
print('${decl.filePath}:${decl.line} ${decl.qualifiedName}');
}Alternatives
Packages that do the same job and could replace ciach.
- analyzer
Performs static analysis of Dart code for tool integration and embedding.
87Compare - undead
Reachability and dead/unused declaration analysis for Dart and Flutter packages.
72Compare - dart_code_linter
A software analytics and static analysis tool for checking code metrics, lint rules, and unused code.
88Compare - cognitive_complexity
Algorithmic Cognitive Complexity calculation and Data-Flow analysis library and CLI tools.
74Compare
Works with
Packages commonly used together with ciach: ones it builds on, ones built on it, and its own family.
- yamlciach depends on itA Dart library for parsing YAML documents into Dart data structures.
- xmlciach depends on itFull-featured XML and XPath library for DOM parsing, SAX streaming, and fluent building.
- globciach depends on itA file and directory globbing library that supports Bash-style path matching and listing.
- package_configciach depends on itRead and write Dart package configuration files.
- argsciach depends on itLibrary for parsing raw command-line arguments into options and values using GNU and POSIX styles.
- loggingciach depends on itProvides configurable logging with levels and stream listeners for Dart apps.
- stream_channelciach depends on itAn abstraction for two-way communication channels based on the Dart Stream class.
- cli_utilciach depends on itUtilities to help build Dart command-line apps, find the SDK, and display progress.