Search packages, repositories and app categories

Package detailsv2.0.0

remove_from_coverage

A command-line tool to customize the contents of a coverage lcov.info file.

macOSWindowsLinux
30-day downloads
68K
Likes
37
Pub points
140

Install package

flutter pub add remove_from_coverage

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

A command-line tool designed to modify lcov.info coverage files by removing specified lines or files from the coverage report. It helps developers refine test coverage data by excluding certain code sections, such as generated or boilerplate code, ensuring more accurate and meaningful coverage metrics. The tool is particularly useful in CI/CD pipelines where clean, focused coverage reports are essential. It runs on macOS, Windows, and Linux, making it accessible across development environments.

Use cases

  • Refining test coverage reports
  • Excluding generated code from coverage
  • Improving CI/CD reporting accuracy
  • Customizing coverage data for analysis
  • Removing noise from coverage files

Key features

  • Command-line interface
  • Supports lcov.info file manipulation
  • Cross-platform compatibility
  • Easy integration with build scripts
  • Configurable exclusion rules

Suitable for

  • Test automation engineers
  • CI/CD pipeline developers
  • Code quality teams
  • Flutter developers managing coverage
  • Teams aiming for precise coverage metrics

Considerations

  • Requires manual configuration of exclusions
  • Not a runtime package
  • Limited to post-processing coverage files
  • No GUI interface
  • Dependent on correct lcov.info format

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

Remove from Coverage

Author: Jack Warren

Build Status Pub

Manipulate lcov.info coverage files to ignore files matching given patterns. This can be used to exclude generated files from coverage reports, and is language-agnostic.

Remove files with paths matching given PATTERNs from the lcov.info FILE
-f, --file=<FILE>         the target lcov.info file to manipulate
-r, --remove=<PATTERN>    a pattern of paths to exclude from coverage
-h, --help                show this help

The patterns are used to construct RegExp objects, so -r "\.g\.dart$" becomes RegExp('\.g\.dart$'). Multiple patterns may be provided by either providing -r multiple times or by using comma-separation, like -r '\.g\.dart$', 'main\.dart'. When evaluating a file's entry in the lcov.info, if its path matches any pattern it will be excluded. The paths are relative from the project's root.

If a lcov.info file is not provided via the -f flag, stdin input is run through the program's filter and is sent to stdout.

Example

Suppose you want to remove generated files ending in .g.dart from code coverage reports:

  • We'll target the lcov.info file in the coverage directory
  • We'll use \.g\.dart$ as the pattern

If pub global scripts are on your path, you can use the following:

remove_from_coverage -f coverage/lcov.info -r "\.g\.dart$"

Otherwise, you can use the following:

pub global run remove_from_coverage:remove_from_coverage -f coverage/lcov.info -r "\.g\.dart$"

An entire example project where remove_from_coverage is useful exists in the example directory of the package.

How it works

Code coverage reports are generated from an lcov.info file, which is generated by test coverage packages.

In some cases, it might make sense to have some files excluded from code coverage reports, like generated or experimental files. Some generators of lcov.info files might support excluding files, but remove_from_coverage provides another route: after a lcov.info file has been generated, it can be manipulated to remove data relating to ignored files.

This means that remove_from_coverage is agnostic to both how the lcov.info file is generated or how it is used. It may be used for non-Dart projects, and it has been tested on both Linux and Windows.

Categories

Dependencies

Dependency list 1 items

Source repository

Projects using this package