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

Skip analysis when no executed lines with --git-diff-lines option #1688

Conversation

romm
Copy link
Contributor

@romm romm commented May 5, 2022

This PR:

  • Adds new feature
  • Covered by tests

When using the --git-diff-lines option, there are situations where a
file can be modified but will not yield any test change, for instance
when only a comment is modified in a PHP source file.

This commit prevents an error being thrown when this very situation
occurs; instead, the analysis is skipped.

@romm
Copy link
Contributor Author

romm commented May 5, 2022

@romm romm force-pushed the fix/skip-analysis-when-no-lines-executed-in-git-diff-lines-mode branch from 48e58b0 to 4774c54 Compare May 5, 2022 19:06
Copy link
Member

@maks-rafalko maks-rafalko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a minor suggestion, otherwise looks good 👍

{
public static function create(): self
{
return new self('No files in diff found, skipping mutation analysis.');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return new self('No files in diff found, skipping mutation analysis.');
return new self('No covered lines in in diff found, skipping mutation analysis.');

or something similar, because the current error message is from another exception :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I kept the message on purpose because I thought it made sense in this situation as well, but there is a slight difference indeed. Thanks for the review!

@maks-rafalko maks-rafalko added this to the next milestone May 6, 2022
When using the `--git-diff-lines` option, there are situations where a
file can be modified but will not yield any test change, for instance
when only a comment is modified in a PHP source file.

This commit prevents an error being thrown when this very situation
occurs; instead, the analysis is skipped.
@romm romm force-pushed the fix/skip-analysis-when-no-lines-executed-in-git-diff-lines-mode branch from 4774c54 to eadbd4e Compare May 6, 2022 07:07
@maks-rafalko maks-rafalko merged commit e5aa8de into infection:master May 6, 2022
@maks-rafalko
Copy link
Member

Thank you @romm

@romm romm deleted the fix/skip-analysis-when-no-lines-executed-in-git-diff-lines-mode branch May 6, 2022 08:38
@maks-rafalko
Copy link
Member

maks-rafalko commented May 6, 2022

@romm
Copy link
Contributor Author

romm commented May 6, 2022

That was fast! thank you!!

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 this pull request may close these issues.

None yet

2 participants