diff --git a/doc/Infection.md b/doc/Infection.md index a685d67..f27278a 100644 --- a/doc/Infection.md +++ b/doc/Infection.md @@ -34,13 +34,48 @@ this script collects the paths defined in your CODEOWNERS file for given codeown this script accepts a list of files and intersects them with the paths defined in your CODEOWNERS file for given codeowner. the intersected result is printed as comma separated list which can be used as a filter value for, for example, php infection. +> [!CAUTION] +> the `stdin2codeowner-filter.pl` script requires either an optimised or an authoritative classmap file so make sure to generate one of those in your configuration (see example below). + +### example config + +> gitlab-ci-yml +> ```yaml +> php-infection: +> stage: test +> rules: +> - +> needs: +> - phpunit-coverage +> variables: +> DEV_TEAM: '@team-awesome' +> EXCLUDE_PATHS: '/old,/legacy' +> MIN_COVERED_MSI: '98.00' +> MIN_MSI: '95.00' +> before_script: +> - composer dump-autoload --optimize --ignore-platform-reqs +> - git fetch --depth=1 origin $CI_MERGE_REQUEST_DIFF_BASE_SHA +> - export INFECTION_FILTER=$(git diff $CI_MERGE_REQUEST_DIFF_BASE_SHA..$CI_COMMIT_SHA --diff-filter=AMR --name-only -- '***.php' | .stdin2codeowner-filter.pl) +> script: +> - ./vendor/bin/infection -j$(nproc) --filter=$INFECTION_FILTER --min-msi=$MIN_MSI --min-covered-msi=$MIN_COVERED_MSI --coverage=./coverage --skip-initial-tests +> ``` + + +## stdin2classtype-filter + +this script accepts a list of files and intersects them with the paths defined in your CODEOWNERS file for given codeowner. +after which a given list of class types are excluded from that list. possible types are `class`, `interface`, `trait`, `enum`, `method_enum`. + ### assumptions -this script assumes the presence of the CODEOWNERS file in the root directory of you project. -though configurable in the `stdin2codeowner-filter.pl` file, for now no plans to make that configurable or accept it as input parameter. +this script assumes the presence of the `PHP_EXCLUDE_TYPES` environment variable and should contain a comma separated list of class types to exclude. > [!CAUTION] -> the `stdin2codeowner-filter.pl` script requires either an optimised or an authoritative classmap file so make sure to generate one of those in your configuration (see example below). +> the `stdin2classtype-filter.pl` script requires either an optimised or an authoritative classmap file so make sure to generate one of those in your configuration (see example below). +also the classes are expected to be conform PSR-4 standards (i.e. the filename matches the classname). + +> [!NOTE] +> enum class types are differentiated as `enum` and `method_enum` where the later is an enumeration containing methods (for which typically mutants _can_ be generated). ### example config @@ -58,10 +93,11 @@ though configurable in the `stdin2codeowner-filter.pl` file, for now no plans to > EXCLUDE_PATHS: '/old,/legacy' > MIN_COVERED_MSI: '98.00' > MIN_MSI: '95.00' +> PHP_EXCLUDE_TYPES: 'interface,enum' > before_script: > - composer dump-autoload --optimize --ignore-platform-reqs > - git fetch --depth=1 origin $CI_MERGE_REQUEST_DIFF_BASE_SHA -> - export INFECTION_FILTER=$(git diff $CI_MERGE_REQUEST_DIFF_BASE_SHA..$CI_COMMIT_SHA --diff-filter=AMR --name-only -- '***.php' | .stdin2codeowner-filter.pl) +> - export INFECTION_FILTER=$(git diff $CI_MERGE_REQUEST_DIFF_BASE_SHA..$CI_COMMIT_SHA --diff-filter=AMR --name-only -- '***.php' | .stdin2classtype-filter.pl) > script: > - ./vendor/bin/infection -j$(nproc) --filter=$INFECTION_FILTER --min-msi=$MIN_MSI --min-covered-msi=$MIN_COVERED_MSI --coverage=./coverage --skip-initial-tests > ``` @@ -91,3 +127,4 @@ this script assumes both `MIN_MSI` and `MIN_COVERED_MSI` are configured. > - set +e > - ./vendor/bin/infection | infection2escapee-warning.pl > ``` + diff --git a/lib/GPH.pm b/lib/GPH.pm index 598d8da..d6c7f1a 100644 --- a/lib/GPH.pm +++ b/lib/GPH.pm @@ -3,7 +3,7 @@ package GPH; use strict; use warnings FATAL => 'all'; -our $VERSION = '1.1.3'; +our $VERSION = '1.2.0'; 1; diff --git a/lib/GPH/PHPMD.pm b/lib/GPH/PHPMD.pm index 43b193f..60fbe0d 100644 --- a/lib/GPH/PHPMD.pm +++ b/lib/GPH/PHPMD.pm @@ -4,7 +4,7 @@ use strict; use warnings FATAL => 'all'; use XML::LibXML; -use GPH::XMLHelper; +use GPH::Util::XMLHelper; sub new { my ($class, %args) = @_; @@ -14,7 +14,7 @@ sub new { my $self = { owner => $args{owner}, cycloLevel => $args{cyclo_level}, - generator => GPH::XMLHelper->new(), + generator => GPH::Util::XMLHelper->new(), }; bless $self, $class; diff --git a/lib/GPH/Psalm.pm b/lib/GPH/Psalm.pm index dab9505..58d5f14 100644 --- a/lib/GPH/Psalm.pm +++ b/lib/GPH/Psalm.pm @@ -4,7 +4,7 @@ use strict; use warnings FATAL => 'all'; use XML::LibXML; -use GPH::XMLHelper; +use GPH::Util::XMLHelper; sub new { my ($class, %args) = @_; @@ -23,7 +23,7 @@ sub new { baseline_check => $args{baseline_check} || 'true', cache_dir => $args{cache_dir} || './psalm', plugins => $plugins, - generator => GPH::XMLHelper->new(), + generator => GPH::Util::XMLHelper->new(), }; bless $self, $class; diff --git a/lib/GPH/XMLHelper.pm b/lib/GPH/Util/XMLHelper.pm similarity index 98% rename from lib/GPH/XMLHelper.pm rename to lib/GPH/Util/XMLHelper.pm index 89a14db..f017e6f 100644 --- a/lib/GPH/XMLHelper.pm +++ b/lib/GPH/Util/XMLHelper.pm @@ -1,4 +1,4 @@ -package GPH::XMLHelper; +package GPH::Util::XMLHelper; use strict; use warnings FATAL => 'all'; diff --git a/t/unit/GPH/PHPMD.t b/t/unit/GPH/PHPMD.t index dda8760..92d4f6a 100644 --- a/t/unit/GPH/PHPMD.t +++ b/t/unit/GPH/PHPMD.t @@ -36,7 +36,7 @@ describe "class `$CLASS`" => sub { field owner => '@teams/alpha'; field cycloLevel => 3; field generator => object { - prop blessed => 'GPH::XMLHelper'; + prop blessed => 'GPH::Util::XMLHelper'; }; end; }, diff --git a/t/unit/GPH/Psalm.t b/t/unit/GPH/Psalm.t index 6f23783..6faed28 100644 --- a/t/unit/GPH/Psalm.t +++ b/t/unit/GPH/Psalm.t @@ -98,7 +98,7 @@ describe 'configuration options' => sub { field cache_dir => $expected_cache_dir; field plugins => $expected_plugins; field generator => object { - prop blessed => 'GPH::XMLHelper'; + prop blessed => 'GPH::Util::XMLHelper'; }; etc; }, diff --git a/t/unit/GPH/XMLHelper.t b/t/unit/GPH/Util/XMLHelper.t similarity index 97% rename from t/unit/GPH/XMLHelper.t rename to t/unit/GPH/Util/XMLHelper.t index 0c841d1..c4e5258 100644 --- a/t/unit/GPH/XMLHelper.t +++ b/t/unit/GPH/Util/XMLHelper.t @@ -1,10 +1,10 @@ #!/usr/bin/perl -package t::unit::GPH::XMLHelper; +package t::unit::GPH::Util::XMLHelper; use strict; use warnings; -use Test2::V0 -target => 'GPH::XMLHelper'; +use Test2::V0 -target => 'GPH::Util::XMLHelper'; use Test2::Tools::Spec; use Data::Dumper;