Skip to content

Commit 7862645

Browse files
committed
(feat) add new 'table-width' option
1 parent e349098 commit 7862645

11 files changed

+389
-290
lines changed

.php-cs-fixer.dist.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
$config = new PhpCsFixer\Config();
1717
$config
1818
->setRiskyAllowed(true)
19+
->setUnsupportedPhpVersionAllowed(true)
1920
->setRules([
2021
'@PER-CS' => true,
2122
'@PSR12' => true,

CHANGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,26 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

88

9+
## [Unreleased]
10+
11+
### Added
12+
13+
* (feat) CLI option for table width
14+
* Thanks to [LeoVie, discussion #311](https://github.com/ericsizemore/phpunit-coverage-check/discussions/311) for the idea.
15+
16+
### Changed
17+
18+
* The `composer.json` script `psalm:ci` now uses the `psalm` script instead of the (now removed) `psalm:security`.
19+
* Updated dev-dependencies, most notably requiring Psalm v7-beta.
20+
* Updated `Command\CoverageCheckCommand` to use `__invoke()` instead of `configure()` and `execute()`. This was introduced in [Symfony 7.3](https://symfony.com/blog/new-in-symfony-7-3-invokable-commands-and-input-attributes).
21+
* Note, it still extends `Symfony\Component\Console\Command\Command` for now.
22+
* Updated `README.md` for some minor enhancements, and to add information for the new `--table-width` option.
23+
24+
### Removed
25+
26+
* The `composer.json` script `psalm:security` has been removed.
27+
28+
929
## [3.0.0] - 2024-12-16
1030

1131
This release is mainly a bump to a PHP 8.3 requirement with some minor refactoring.

README.md

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414

1515
[PHPUnit Coverage Check](http://github.com/ericsizemore/phpunit-coverage-check/) - Check the code coverage using the clover report of PHPUnit.
1616

17-
This library will read the clover xml report from PHPUnit and calculate the coverage score.
18-
Based on the given threshold the application will exit OK if the coverage is higher than the threshold or exit with code 1 if the coverage is lower than the threshold.
17+
This library will read the clover XML report from PHPUnit and calculate the coverage score.
18+
Based on the given threshold, the application will exit OK if the coverage is higher than the threshold or exit with code 1 if the coverage is lower than the threshold.
1919

2020
This library can be used in multiple ways:
2121

@@ -27,7 +27,7 @@ See [GitHub Action](#github-action), [Installation](#installation) and [Usage](#
2727

2828
> [!IMPORTANT]
2929
> This project is not in any way an official ``PHPUnit`` project.
30-
> Meaning, that it is not associated with, or endorsed by, the ``PHPUnit`` project or its author ``Sebastian Bergmann``.
30+
> Meaning it is not associated with, or endorsed by, the ``PHPUnit`` project or its author ``Sebastian Bergmann``.
3131
3232
### GitHub Action
3333

@@ -86,10 +86,10 @@ If not already using Phive, you can read more about it [here](https://phar.io/),
8686

8787
## Usage
8888

89-
There are 2 parameters that must be passed to return the code coverage.
89+
There are two parameters that must be passed to return the code coverage.
9090

91-
1. The location of the clover xml file, that has been generated by PHPUnit.
92-
2. The coverage threshold that is acceptable or 'passing'. Min = 1, Max = 100
91+
1. The location of the clover XML file that PHPUnit has generated.
92+
2. The coverage threshold that is acceptable or 'passing.' Min = 1, Max = 100.
9393

9494
Generate the `clover.xml` file by using PHPUnit:
9595

@@ -105,7 +105,7 @@ You can also add the coverage report generation to your PHPUnit configuration fi
105105
</report>
106106
```
107107

108-
* For more information see the [PHPUnit Documentation](https://docs.phpunit.de/en/10.5/).
108+
* For more information, see the [PHPUnit Documentation](https://docs.phpunit.de/en/10.5/).
109109
* Information about the [configuration file](https://docs.phpunit.de/en/10.5/configuration.html) and [commandline options](https://docs.phpunit.de/en/10.5/textui.html#command-line-options).
110110

111111

@@ -199,6 +199,18 @@ $ php coverage-check tests/fixtures/clover.xml 90 -F
199199
----------------------------- -------------------------- ----------
200200
```
201201

202+
#### --table-width
203+
204+
The `--table-width` (or `-W`) option will only have an affect if used with the `--show-files` option. The only requirement for this particular option is that you must pass an integer
205+
value. For example:
206+
207+
```bash
208+
$ php coverage-check tests/fixtures/clover.xml 90 -F -W 120
209+
210+
# ...or
211+
$ php coverage-check tests/fixtures/clover.xml 90 --show-files --table-width 120
212+
```
213+
202214
## About
203215

204216
### Requirements
@@ -212,7 +224,8 @@ $ php coverage-check tests/fixtures/clover.xml 90 -F
212224

213225
This library is a fork of/based upon [rregeer/phpunit-coverage-check](https://github.com/richardregeer/phpunit-coverage-check/) by [Richard Regeer](https://github.com/richardregeer).
214226

215-
Most of this library has been rewritten from the ground up, to replace and improve a majority of the original library. The overall idea, and key pieces of the calculation, are thanks to the original library. Many thanks and much appreciation to Richard Regeer for his wonderful work.
227+
Most of this library has been rewritten from the ground up, to replace and improve the majority of the original library. The overall idea, and key pieces of the calculation, are thanks to the original library.
228+
Many thanks and much appreciation to Richard Regeer for his wonderful work.
216229

217230
- Author: [Eric Sizemore](https://github.com/ericsizemore)
218231
- Thanks to [Richard Regeer](https://github.com/richardregeer) for the original `phpunit-coverage-check` library this library is forked from.

bin/coverage-check

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,7 @@ use Esi\CoverageCheck\Application;
4949
use Esi\CoverageCheck\Command\CoverageCheckCommand;
5050
use Esi\CoverageCheck\CoverageCheck;
5151

52-
$command = new CoverageCheckCommand(new CoverageCheck());
53-
$commandName = $command->getName() ?? 'coverage:check';
54-
5552
$console = new Application();
56-
$console->add($command);
57-
$console->setDefaultCommand($commandName, true);
53+
$console->add(new CoverageCheckCommand(new CoverageCheck()));
54+
$console->setDefaultCommand(Application::COMMAND_NAME, true);
5855
$console->run();

composer.json

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,20 +57,20 @@
5757
"php": "^8.3",
5858
"ext-libxml": "*",
5959
"ext-simplexml": "*",
60-
"symfony/console": "^7.2"
60+
"symfony/console": "^7.3"
6161
},
6262
"require-dev": {
63-
"friendsofphp/php-cs-fixer": "^3.68",
63+
"friendsofphp/php-cs-fixer": "^3.83",
6464
"phpstan/extension-installer": "^1.4",
6565
"phpstan/phpstan": "^2.1",
6666
"phpstan/phpstan-deprecation-rules": "^2.0",
6767
"phpstan/phpstan-phpunit": "^2.0",
6868
"phpstan/phpstan-strict-rules": "^2.0",
69-
"phpunit/phpunit": "^11.5 || ^12.0",
70-
"psalm/plugin-phpunit": "^0.19.0",
69+
"phpunit/phpunit": "^12.2",
70+
"psalm/plugin-phpunit": "^0.19.5",
7171
"psalm/plugin-symfony": "^5.2.7",
72-
"rector/rector": "^2.0",
73-
"vimeo/psalm": "^6.5"
72+
"rector/rector": "^2.1",
73+
"vimeo/psalm": "^7.0.0-beta11"
7474
},
7575
"minimum-stability": "dev",
7676
"prefer-stable": true,
@@ -92,7 +92,7 @@
9292
"phpstan/extension-installer": true
9393
},
9494
"platform": {
95-
"php": "8.3.0"
95+
"php": "8.3.99"
9696
}
9797
},
9898
"extra": {
@@ -112,16 +112,15 @@
112112
"@psalm:shepherd"
113113
],
114114
"clear-build": "rm -rf ./build/*",
115-
"code-coverage": "@php bin/coverage-check build/logs/clover.xml 100",
115+
"code-coverage": "@php bin/coverage-check build/logs/clover.xml 100 --show-files --table-width 110",
116116
"phpcs:check": "@phpcs:fix --dry-run --diff",
117117
"phpcs:fix": "vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php",
118118
"phpstan": "vendor/bin/phpstan analyse -c phpstan.neon -vvv",
119119
"phpunit": "vendor/bin/phpunit",
120120
"phpunit:migrate": "@phpunit --migrate-configuration",
121121
"psalm": "vendor/bin/psalm -c psalm.xml --no-cache --show-info=true",
122122
"psalm:baseline": "@psalm --no-diff --set-baseline=psalm-baseline.xml",
123-
"psalm:ci": "@psalm:security --shepherd --report=results.sarif",
124-
"psalm:security": "@psalm --no-diff --taint-analysis",
123+
"psalm:ci": "@psalm --shepherd --report=results.sarif",
125124
"psalm:shepherd": "@psalm --no-diff --shepherd --stats",
126125
"refactor:check": "@refactor:fix --dry-run",
127126
"refactor:fix": "vendor/bin/rector process"

0 commit comments

Comments
 (0)