| Question | Answer
| ------------| ---------------
| Infection version | 0.6.1
| Test Framework version | PHPUnit 6.4.4
| PHP version | 7.1.7
| Platform | MacOS
| Github Repo | -
For WordPress, callback methods hooked into the actions or filters need to be public.
The Function Signature mutator naturally tries to change the callback from public to protected, and flags it as a "not covered mutant".
Is there any way (to reduce known false positives) to specify that a method really should stay public, either by adding a line comment (e.g. // infection:disable FunctionSignature) or by adding an exclusion (file and line number? class and method name?) to infection.json.dist?
Perhaps an obvious workaround - make sure you have a unit test that calls the public method. When this mutates to protected, the test will no longer be reported as "not covered".
Hello,
Disable certain mutators
This is really my one of the most wanted feature. Let's start discussing a possible implementation.
The first thought was the same - add something like other tools add in PHP and JS world:
// tslint: disable-next-line
...
// infection:disable FunctionSignature
but now I don't like this idea because
I like the idea of PHPStan -https://github.com/phpstan/phpstan#ignore-error-messages-with-regular-expresions.
They use patterns/regular expressions on the config level to skip/ignore some issues during analyzing.
We can use this idea and implement something similar, for example:
// infection.json
{
"mutators": {
"ignore": {
"PublicVisibility": [
"Ignore\For\Particular\Class",
"Ignore\For\Another\Class::method",
// ...
"Ignore\For\**\*\Glob\Pattern\Or\Namespace"
]
}
}
}
Also, I think keeping the exact line number in the "ignore config" is a bad idea because line numbers change quite often
What I also like and want to have from PHPStan is the behaviour of notifying users when some of the ignored classes/methods for mutants are no longer exist (see https://github.com/phpstan/phpstan#ignore-error-messages-with-regular-expresions): for example if the Some\Class::method is ignored for a set of Mutation Operators and after some time is removed - Infection should notify developer that this method is no longer exist and the config should be updated
Most helpful comment
Hello,
This is really my one of the most wanted feature. Let's start discussing a possible implementation.
The first thought was the same - add something like other tools add in PHP and JS world:
but now I don't like this idea because
I like the idea of PHPStan -https://github.com/phpstan/phpstan#ignore-error-messages-with-regular-expresions.
They use patterns/regular expressions on the config level to skip/ignore some issues during analyzing.
We can use this idea and implement something similar, for example:
Ignore mutators for some class
Also, I think keeping the exact line number in the "ignore config" is a bad idea because line numbers change quite often
What I also like and want to have from PHPStan is the behaviour of notifying users when some of the ignored classes/methods for mutants are no longer exist (see https://github.com/phpstan/phpstan#ignore-error-messages-with-regular-expresions): for example if the
Some\Class::methodis ignored for a set of Mutation Operators and after some time is removed - Infection should notify developer that this method is no longer exist and the config should be updated