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
Implement always true
or always false
if
and elseif
conditions
#1865
Comments
In my todo list there was an idea to implement
need to think more about it with some examples, probably worth trying to implement and check what it brings |
true
or always false
if
and elseif
conditions
Yes, I also thought about I also thought about boolean conditions ( -$var = $a && $b;
+$var = false; |
Ok, I have to take those words back.. I thought that there is no empty node, but I found it in repo EDIT: but there is still problem when there is elseif statement. It will produce syntax error. |
let's try with changing condition to |
I'm afraid I'm going to upset you all. I think came up before, and the biggest argument against these mutations was that they are very easy to kill (or downright impossible), very obvious from the coverage report, and most of the time they are going to waste CPU cycles, skewing the metrics. Here are all mutations this example currently generates: https://infection-php.dev/r/3w26 If I had a branch like this in my code, it is probably because it was added as an optimization to avoid costly code paths. So if I have to kill the mutation proposed here, I'm supposed to remove an optimization because there's no way to test it. How can we argue this is a good thing? |
@sanmai you are right, I agree with you. Most of these mutation would not be useful but there will be a lot of it |
@manhunto did you do some analysis and have examples? |
No, It is just my assumption and when I thought about it may be true. I will do more research after two weeks because I'm on holidays now |
Hi, I have idea to implement new mutator. Let's look at an example.
And test for it
Link to playground: https://infection-php.dev/r/ylkd
In this example, if in getOffset() method is redundant and can be delated.
What do you think about implementing a new mutator which will change if and elseif conditions to false. (and could be another mutator that set it to true)
This mutator will do changes like below
If you think is worth implementing it, I can prepare PR with changes :)
The text was updated successfully, but these errors were encountered: