搜索插件、代码仓与 APP 分类

插件详情v2.0.0

remove_from_coverage

一个命令行工具,用于自定义覆盖率 lcov.info 文件的内容。

macOSWindowsLinux
近 30 天下载
6.8万
喜欢数
37
Pub 分数
140

安装插件

flutter pub add remove_from_coverage

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

一个命令行工具,旨在通过从覆盖率报告中移除指定的行或文件来修改 lcov.info 覆盖率文件。该工具帮助开发者通过排除某些代码部分(如生成的或样板代码)来优化测试覆盖率数据,从而确保更准确、更有意义的覆盖率度量。在 CI/CD 流水线中,该工具特别有用,因为需要清晰且聚焦的覆盖率报告。它可在 macOS、Windows 和 Linux 上运行,使开发环境中的使用更加便捷。

适合场景

  • 精炼测试覆盖率报告
  • 排除生成的代码覆盖率
  • 提高 CI/CD 报告的准确性
  • 自定义覆盖数据以进行分析
  • 从覆盖率文件中去除噪声

主要特点

  • 命令行界面
  • 支持 lcov.info 文件操作
  • 跨平台兼容性
  • 与构建脚本的轻松集成
  • 可配置的排除规则

适合对象

  • 测试自动化工程师
  • CI/CD 流水线开发者
  • 代码质量团队
  • Flutter 开发者管理覆盖率
  • 致力于精确覆盖率度量的团队

使用建议

  • 需要手动配置排除项
  • 不是运行时包
  • 仅限后处理覆盖文件
  • 无GUI界面
  • 依赖于正确的 lcov.info 格式

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

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.

所属分类

依赖

依赖清单 1 项

源码仓库

使用此插件的项目