flutter_live_coverage 1.2.0
flutter_live_coverage: ^1.2.0 copied to clipboard
Flutter runtime code coverage plugin supporting Release mode. Collects line-level coverage data with LCOV output and S3 upload support.
Changelog #
1.2.0 #
New instrumentation coverage (inline, line-number-preserving AST edits):
- Expression-bodied functions (
=>) are now tracked: rewritten to an equivalent block body ({ hit(); return (e); }, or statement form for syntactically-void functions and setters). Applies to typed functions/methods, getters, setters, factory constructors and lambdas; named declarations without a written return type are skipped (an override may inheritvoid, invisible without resolution) - Braceless control-flow bodies are now tracked: wrapped in braces with a hit call (
if (c) foo();->if (c) { hit(); foo(); }), preserving semantics exactly catch/onclauses are now tracked: the hit is injected as the first statement inside the catch block, so the clause is only marked covered when an exception is actually caught
Instrumentation correctness fixes:
- Fix braceless control-flow corruption: statements (
if/for/while/break/…) that are the braceless body of another control-flow statement are no longer instrumented — previously the inserted hit call became the loop/branch body, silently changing program behavior (including infinite loops) - Fix switch instrumentation:
case/defaultlabel lines are no longer recorded — previously this produced a syntax error (defaultas first member) or dead code afterbreakthat could never be marked covered - Fix catch instrumentation:
catchclause lines are no longer recorded — previously the hit landed inside the try block, marking the catch as covered when no exception was thrown - Fix BitSet boundary: hits on the last executable line were silently dropped when its line number was a multiple of 8
- Fix default include pattern:
lib/**/*.dartdoes not match files directly underlib/in package:glob (skippinglib/main.dart); the default is nowlib/**.dart - Fix part-file compilation: the library file of an instrumented part file now always receives the coverage import, even when it has no executable lines or is excluded from instrumentation
- Guard against double instrumentation: instrumented files are tagged with a marker comment and the CLI aborts if it finds already-instrumented input (re-instrumenting corrupted the source map)
- Fix file ID collisions: hash-based file IDs are now checked for collisions and deduplicated (a collision silently merged two files' coverage)
Other fixes and changes:
- Fix method channel name mismatch: Dart side used
code_coveragewhile Android/iOS/macOS registeredflutter_live_coverage(Linux/Windows updated to match) - Fix
CoverageExportResult.localFileDeletedreporting true when local file deletion actually failed - Fix S3 upload file name extraction on Windows paths
- Replace hand-rolled JSON encoder with
dart:convert - Faster instrumentation on large files (removed O(n²) AST scan)
dart_parser.dart/code_instrumenter.dartare no longer exported from the package barrel (CLI-internal; avoids compiling package:analyzer into apps)- Added instrumenter regression test suite
1.1.0 #
- Fix if-else chain instrumentation to avoid syntax errors
- When instrumenting
else ifchains, skip recording nested IfStatement lines to prevent inserting hit calls between}andelse if
1.0.0 #
- Initial release
- Runtime code coverage collection for Release mode
- Line-level coverage tracking using efficient BitSet storage
- LCOV format output compatible with genhtml, codecov, etc.
- Local file storage with automatic cleanup
- AWS S3 upload support with SigV4 authentication
- CLI instrumentation tool for source code transformation
- Auto-upload feature with configurable intervals
- Automatic local file cleanup after successful S3 upload