Skip to content
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

ignoreSourceCodeByRegex option is ignored between // @codeCoverageIgnoreStart and // @codeCoverageIgnoreEnd #1561

Closed
VincentLanglet opened this issue Aug 27, 2021 · 7 comments · Fixed by #1585
Labels

Comments

@VincentLanglet
Copy link

VincentLanglet commented Aug 27, 2021

I have multiple mutation

33) /Users/vincentl/Perso/Twig-CS-Fixer/src/Token/Tokenizer.php:476    [M] Throw_

--- Original
+++ New
@@ @@
             $this->pushToken(Token::DQ_STRING_END_TYPE, $match[0], $bracket);
             $this->moveCursor($match[0]);
         } else {
-            // @codeCoverageIgnoreStart
-            throw new LogicException(sprintf('Unhandled character "%s" in lexDqString.', $this->code[$this->cursor]));
+            new LogicException(sprintf('Unhandled character "%s" in lexDqString.', $this->code[$this->cursor]));
             // @codeCoverageIgnoreEnd
         }
     }

Which I don't succeed to ignore

I tried

"mutators": {
        "@default": true,
        "global-ignoreSourceCodeByRegex": [
            "assert\\(.*",
            "throw new LogicException\\(.*"
        ]
    },

with no success,
I also tried to ignore

"\\/\\/ @codeCoverageIgnoreStart.*"

instead but nothing changed.

And I clearly don't understand what is wrong with my regex

@sanmai
Copy link
Member

sanmai commented Aug 28, 2021

Try this:

// @infection-ignore-all 
throw new LogicException()

Compare these two:

@VincentLanglet
Copy link
Author

Try this:

// @infection-ignore-all 
throw new LogicException()

Sure, but since since I throw multiple logic exception, I would prefer to use a global regex rule.

Compare

Adding a comment is breaking the ignore rule

@VincentLanglet
Copy link
Author

VincentLanglet commented Aug 29, 2021

I think it's a bug: https://infection-php.dev/r/l0r2

I think it's because the mutation has two lines diff.
It shouldn't remove the comment before.

@VincentLanglet VincentLanglet changed the title Provide a way to debug the ignoreSourceCodeByRegex option I found a mutation which cannot be ignored with the ignoreSourceCodeByRegex option Aug 29, 2021
@VincentLanglet
Copy link
Author

VincentLanglet commented Aug 29, 2021

It's seems related to // @codeCoverageIgnoreStart

https://infection-php.dev/r/r5w6
https://infection-php.dev/r/0yx2
https://infection-php.dev/r/4kdo

ignoreSourceCodeByRegex is ignored inside // @codeCoverageIgnoreStart

@VincentLanglet VincentLanglet changed the title I found a mutation which cannot be ignored with the ignoreSourceCodeByRegex option ignoreSourceCodeByRegex option is ignored between // @codeCoverageIgnoreStart and // @codeCoverageIgnoreEnd Aug 29, 2021
@sanmai
Copy link
Member

sanmai commented Aug 29, 2021

So it looks like ignoreSourceCodeByRegex is not respected for uncovered mutations.

@sanmai sanmai added the Bug label Aug 29, 2021
@VincentLanglet
Copy link
Author

So it looks like ignoreSourceCodeByRegex is not respected for uncovered mutations.

Any idea how to fix this/where I should look at to fix this ?
This bug is kinda annoying for the reporting

@maks-rafalko
Copy link
Member

maks-rafalko commented Oct 2, 2021

Thanks for reporting this issue, fixed and released as 0.25.3

Before: https://infection-php.dev/r/4kdo
After: https://infection-php.dev/r/vr21

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants