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 with no match should raise an Error #1604

Open
Slamdunk opened this issue Nov 18, 2021 · 4 comments · May be fixed by #1631
Open

ignoreSourceCodeByRegex with no match should raise an Error #1604

Slamdunk opened this issue Nov 18, 2021 · 4 comments · May be fixed by #1631

Comments

@Slamdunk
Copy link
Contributor

Slamdunk commented Nov 18, 2021

Hi, I've used quite few times ignoreSourceCodeByRegex (both global and per-mutator) and it may happen that, after a refactor, an ignore regex is not necessary anymore. But Infection doesn't tell me that, so I might forget the regex in place, and that could be very bad if, in a later commit, a new line-of-code matches the forgotten regex by accident.

Just like PHPStan fails when an ignore regex is set but has no match during the check, I'd like Infection too to have an exit code over zero for unmatched ignoreSourceCodeByRegex.

@maks-rafalko maks-rafalko added this to the next milestone Nov 18, 2021
maks-rafalko added a commit that referenced this issue Dec 28, 2021
…n't matched

Implements #1604

Will be useful to remove stale/non-matching `ignoreSourceCodeByRegex` settings inside `infection.json` and will help debugging them.
@maks-rafalko maks-rafalko self-assigned this Dec 28, 2021
@sanmai
Copy link
Member

sanmai commented Dec 29, 2021

Unmatched regexes should not lead to a non-zero exit status by default as there could be version-dependent mutants which do not always appear and trigger a regex, among other things. Showing a notice should be fine, though.

@orlandothoeny
Copy link

orlandothoeny commented Jan 13, 2023

Another possibility would be to make the behaviour configurable, for example as PHPStan is doing it: https://phpstan.org/user-guide/ignoring-errors#reporting-unused-ignores

@theofidry
Copy link
Member

Also when applying on a diff, this cannot work.

But yeah maybe a confit entry or a flag could help.

@sanmai
Copy link
Member

sanmai commented Jan 14, 2023

There are also @infection-ignore-all annotations. Read about them here.

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

Successfully merging a pull request may close this issue.

5 participants