remove_from_coverage 2.0.0 copy "remove_from_coverage: ^2.0.0" to clipboard
remove_from_coverage: ^2.0.0 copied to clipboard

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

Remove from Coverage #

Author: Jack Warren

Build Status Pub

Manipulate 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 FILE
-f, --file=<FILE>         the target 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, if its path matches any pattern it will be excluded. The paths are relative from the project's root.

If a 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 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/ -r '\.g\.dart$'

Otherwise, you can use the following:

pub global run remove_from_coverage:remove_from_coverage -f coverage/ -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 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 files might support excluding files, but remove_from_coverage provides another route: after a 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 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.

pub points


unverified uploader

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

Repository (GitHub)
View/report issues


API reference


BSD-3-Clause (LICENSE)




Packages that depend on remove_from_coverage