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

Kill survivng mutation in DefaultComesLastCheck.java #12889

Closed
ThatSneakyCoder opened this issue Mar 23, 2023 · 8 comments
Closed

Kill survivng mutation in DefaultComesLastCheck.java #12889

ThatSneakyCoder opened this issue Mar 23, 2023 · 8 comments

Comments

@ThatSneakyCoder
Copy link
Contributor

Kill mutation:

<mutation unstable="false">
<sourceFile>DefaultComesLastCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.coding.DefaultComesLastCheck</mutatedClass>
<mutatedMethod>findNextSibling</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.NonVoidMethodCallMutator</mutator>
<description>removed call to com/puppycrawl/tools/checkstyle/api/DetailAST::getNextSibling</description>
<lineContent>node = node.getNextSibling();</lineContent>
</mutation>

@ThatSneakyCoder
Copy link
Contributor Author

ThatSneakyCoder commented Mar 23, 2023

@romani
please approve

@ThatSneakyCoder
Copy link
Contributor Author

ThatSneakyCoder commented Mar 23, 2023

I'm on it.

This issue is open for other interested candidates to work on as I am busy with other important PRs.

@jxr98
Copy link
Contributor

jxr98 commented Apr 22, 2023

I will work on this issue.

@jxr98
Copy link
Contributor

jxr98 commented Apr 27, 2023

private static DetailAST findNextSibling(DetailAST ast, int tokenType) {
DetailAST token = null;
DetailAST node = ast.getNextSibling();
while (node != null) {
if (node.getType() == tokenType) {
token = node;
break;
}
node = node.getNextSibling();
}
return token;
}
}

The pitest will fail after timeout or out of memory if the code((Line 223) is changed to node = node;. I think this suppressed mutation cannot be removed because it is kind of the halting problem to add code to check if the loop is infinite or not. Additionally, can't kill this mutation without redundant code. I don't think it is worth to add one more condition to while only for one mutation test.

I guess this issue can be closed.

@romani
Copy link
Member

romani commented Apr 28, 2023

Pitest catching infinite loops and out of memory, this tool is well aware of damages it might do.
We need to kill mutation.

@nrmancuso
Copy link
Member

the code((Line 223) is changed to node = node;.

@jxr98 please explain how you concluded that this is what the code is mutated to. According to the documentation for this mutator, it should be mutated to node = null; however this is an unstable mutator so we could be getting different results. If the code is mutated to node = null, then it looks like all the tests we have only cause us to loop one time in the code snippet you shared. Try to find a case where we must loop more than once.

jxr98 added a commit to jxr98/checkstyle that referenced this issue Apr 29, 2023
jxr98 added a commit to jxr98/checkstyle that referenced this issue Apr 29, 2023
@jxr98
Copy link
Contributor

jxr98 commented Apr 29, 2023

I thought this mutator just removed getNextSibling. Thanks for pointing this out.

jxr98 added a commit to jxr98/checkstyle that referenced this issue Apr 30, 2023
jxr98 added a commit to jxr98/checkstyle that referenced this issue Apr 30, 2023
jxr98 added a commit to jxr98/checkstyle that referenced this issue May 1, 2023
jxr98 added a commit to jxr98/checkstyle that referenced this issue May 1, 2023
jxr98 added a commit to jxr98/checkstyle that referenced this issue May 3, 2023
jxr98 added a commit to jxr98/checkstyle that referenced this issue May 3, 2023
jxr98 added a commit to jxr98/checkstyle that referenced this issue May 3, 2023
jxr98 added a commit to jxr98/checkstyle that referenced this issue May 4, 2023
romani pushed a commit to jxr98/checkstyle that referenced this issue May 4, 2023
@rnveach
Copy link
Member

rnveach commented May 10, 2023

Fix was merged

@rnveach rnveach closed this as completed May 10, 2023
@github-actions github-actions bot added this to the 10.11.0 milestone May 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants