New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Infection reports mutations on impossible to cover parts: PHP Attributes #1910
Comments
If you execute it with |
Please see this workaround #1894 (comment) - you can disable mutation of attributes for now. |
Thanks for your answers. @maks-rafalko Thank you for the proposal to ignore via RegExp, but I'm using a forced global configuration file for PHP Infection across multiple projects to ensure they have the exact same standards quality, and I don't want to have some specific project ignorance here, I'm looking for a solution I can use globally. Nevertheless, that's good to know, and if I need that, I'll keep in mind! @theofidry Using I don't know if you guys want to get further on this, as the proposed solutions are only about ignoring PHP Attributes, but IMO, it makes perfect sense to mutate them and give it a try, as they have a direct impact on runtime. Is there any ideas or actions you got to make them declared as covered or something? or do you think it should be on PHP's CodeCoverage to stop ignoring them? Thanks a lot again and have a good day! |
We didn't think a lot through it and didn't discuss it yet, but I agree - it would be very nice to mutate attributes properly, with coverage supported. I had an idea to create symfony/doctrine related mutators to
Regarding where the issue is - on CodeCoverage or Infection side - I don't know, needs to be investigated. So any help would be appreciated :) If it won't be supported on CodeCoverage side, the only one way I see is to do the same as we do for parameters: as soon as the method is executed - its attributes are "executed" as well, so are treated as covered. And we can get this information from the phpunit's reports we are using. |
Symfony/Doctrine mutators are a good idea for a good usage of them, I definitly agree about it, but the mutations on PHP Attributes are more global than just them: in my example, I used a custom PHP Attribute, not a Symfony/Doctrine or whatever library's from. I'm not sure I'm valuable in front of Sebastian Bergmann to tell him that PHP Attributes must be covered 😅 but I really do think it should be on coverage side: like I said, PHP Attributes are impacting runtime behaviors, they're not just definitions. And I guess that as soon as coverage will tell you PHP Attributes are (or not) covered instead of being ignored, PHP Infection will automatically be ready to handle them. That's why I'm convinced it should be an enhancement on CodeCoverage's side. |
Hello people!
I don't know if that's already detected in another issue, but I'm having a trouble with mutants tagged "Not covered", on PHP Attributes definitions, even if I actually have PHP Unit tests about it.
You can have a example here: https://infection-php.dev/r/0544
I think that the problem is PHP CodeCoverage is not taking care about PHP Attributes, so PHP Infection considers this part not being covered. I don't know how this could be solved, but it's clearly an issue because all of these mutations should have been killed by the unit tests, therefore the MSI score is lowered for no valid reasons.
Thanks a lot!
The text was updated successfully, but these errors were encountered: