Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Coverage Guard Laravel Package

shipmonk/coverage-guard

Enforce code coverage in CI by targeting core functionality instead of percentages. Legacy-friendly and extensible, it lets you require coverage only for chosen methods and, with a patch, only for new code. Lightweight and easy to start.

View on GitHub
Deep Wiki
Context7
1.1.0

New features:

  • Executable line excluders: exclude lines you don't want to enforce coverage for (#67)
    • register via Config::addExecutableLineExcluder()
    • prepared IgnoreThrowNewExceptionLineExcluder allows excluding e.g. all throw new LogicException(...) lines
    • honored by both check and patch-coverage commands
    • excluded lines are rendered with gray background in check output
// coverage-guard.php
use ShipMonk\CoverageGuard\Config;
use ShipMonk\CoverageGuard\Excluder\IgnoreThrowNewExceptionLineExcluder;

$config = new Config();
$config->addExecutableLineExcluder(new IgnoreThrowNewExceptionLineExcluder([
    LogicException::class,
]));

return $config;

Fixes:

  • Methods with nothing to cover are no longer reported as uncovered; CodeBlock::getCoveragePercentage() returns 100% when there are no executable lines (#67)
    • Previously, it wrongly reported 0%
  • Make coverage path mapping insensitive to trailing slashes (#82)
1.0.2

Fixes:

  • export-ignore useless files for composer package (#76)
1.0.1

Fixes:

  • Internal error output to print file:line (#73)
  • Better support for light-theme terminals (#75)
1.0.0

Initial release

  • Enforce code coverage in your CI by targetting core methods (not by percentage)
  • Supports all PHPUnit coverage formats
  • Supports all PHPUnit versions
  • Fully customizable
  • PHP 8.1+

Example config:

// coverage-guard.php
use ShipMonk\CoverageGuard\Config;
use ShipMonk\CoverageGuard\Rule\EnforceCoverageForMethodsRule;

$config = new Config();
$config->addRule(new EnforceCoverageForMethodsRule(
    requiredCoveragePercentage: 50,
    minExecutableLines: 5, 
));

return $config;

Example run:

# Run tests, collect coverage, generate report:
XDEBUG_MODE=coverage vendor/bin/phpunit tests --coverage-filter src --coverage-clover clover.xml

# Verify coverage:
vendor/bin/coverage-guard check clover.xml
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
skyraptor/chatter
edlugz/sasapay
abbasudo/artisan-route
mirvan/ippanel
ignibyte/aic-framework
glavweb/data-schema-bundle
glavweb/datagrid-bundle
tacticmedia/scim-server
uni-method/frame
neika-ai/sdk
adachsoft/php-code-style
pharaonic/laravel-notification-dependencies
beautinow/translug
dev-brainiac/bot-cloaked
octoberrain/html
octoberrain/extension
octoberrain/exception
octoberrain/contracts
adachsoft/api-version-bundle
cgv/localized-resource