Issue #13672: Kill mutation for DetailAstImpl-3#13391
Issue #13672: Kill mutation for DetailAstImpl-3#13391romani merged 1 commit intocheckstyle:masterfrom
Conversation
|
Github, generate report |
|
Report generation failed on phase "make_report", |
|
Github, generate report |
30bdcbb to
100f78f
Compare
| public void addNextSibling(DetailAST ast) { | ||
| clearBranchTokenTypes(); | ||
| clearChildCountCache(parent); | ||
| if (ast != null) { |
There was a problem hiding this comment.
I see that both clearXXX methods are called in setNextSibling, so you remove them here as redundant. But I don't understand why you remove the null check if (ast != null), could you explain please?
There was a problem hiding this comment.
Ok so lets suppose if ast is null. then
in current code the process stop at if (ast != null).
But if not then my updated code is
final DetailAstImpl sibling = nextSibling;
final DetailAstImpl astImpl = (DetailAstImpl) ast;
if (sibling != null) {
astImpl.setNextSibling(sibling);
}
setNextSibling(astImpl);
ast is assigned to astImpl and it is used at the end of method setNextSibling(astImpl); (This is the only usage of last in whole method) know in setNextSibling(astImpl); (where atImpl is null and we are passing null to setNextImpl)
public void setNextSibling(DetailAST nextSibling) {
clearBranchTokenTypes();
clearChildCountCache(parent);
this.nextSibling = (DetailAstImpl) nextSibling;
if (nextSibling != null && parent != null) {
((DetailAstImpl) nextSibling).setParent(parent);
}
if (nextSibling != null) {
((DetailAstImpl) nextSibling).previousSibling = this;
}
}
here
will be assigned to nextSibiling (which is parameter of method).know to set the parent of this node and the previous sibling of the node in both the if condition it is assigned that nextSibiling != null so it will never be the node of the tree (for surety I have updated the test case to check the childcount of parent you can check testAddNextSibling2)and not affect code or generate any kind of null pointer exception.
There was a problem hiding this comment.
How about this logic:
if (sibling != null) {
astImpl.setNextSibling(sibling);
}
It is a potential NPE here when sibling is not null but astImpl is null. Is this a possible outcome?
There was a problem hiding this comment.
Yes, you are right. I am really sorry, I don't know how I have missed this.
This may lead to major breaks in future
I will update in next push
There was a problem hiding this comment.
done
if (ast != null)
logic retrieves
src/test/java/com/puppycrawl/tools/checkstyle/DetailAstImplTest.java
Outdated
Show resolved
Hide resolved
|
@Kevin222004 could you check failed pitest please? |
|
@rdiachenko Yes I am looking on it. |
|
spelling failure is known issue, nothing we can do for now, waiting for Sourceforge to respond |
romani
left a comment
There was a problem hiding this comment.
ok to merge.
the only mixed filling I have on growing pure unit tests. But be for AST classes it is ok.
There was a problem hiding this comment.
LGTM!
@Kevin222004 Please do regression testing with changes of both this and #13649
|
Rebased by GitHub to be ready to report generation |
|
@romani @Vyom-Yadav I have updated the description section with newly generated report which has no diff |
|
Please fix typo, see spelling failure in CI |
|
All green, merging ... |
Issue #13672: Kill mutation for DetailAstImpl-3
https://github.com/checkstyle/checkstyle/blob/master/src/main/java/com/puppycrawl/tools/checkstyle/DetailAstImpl.java
Mutations
checkstyle/config/pitest-suppressions/pitest-common-2-suppressions.xml
Lines 30 to 46 in 88486f7
Explaination
To add Next sibiling. The code is
checkstyle/src/main/java/com/puppycrawl/tools/checkstyle/DetailAstImpl.java
Lines 140 to 156 in 0dba32b
Line 150 and 153 is mutated
This explaination is almost similar to #13390 (comment)
lets suppose
if (sibling != null) {if this statment execute thenastImpl.setNextSibling(sibling);while calling setNextSibling the previous sibling will be set atcheckstyle/src/main/java/com/puppycrawl/tools/checkstyle/DetailAstImpl.java
Lines 473 to 475 in 0dba32b
For 100% surity we can remove
checkstyle/src/main/java/com/puppycrawl/tools/checkstyle/DetailAstImpl.java
Lines 466 to 476 in 0dba32b
if last statment from this code in which previous sibiling are set
checkstyle/src/main/java/com/puppycrawl/tools/checkstyle/DetailAstImpl.java
Lines 473 to 475 in 0dba32b
testing puropse that this happening or not we can remove
and know if you run my updated test case it will still run know run this test by removing the mutated code it will fail.
Regression
No Diff
https://kevin222004.github.io/reports/com3/2023-09-06-T-16-25-20/part3-report/index.html
https://kevin222004.github.io/reports/com3/2023-09-06-T-16-25-20/sevntu-check-regression_part_1-report/index.html
https://kevin222004.github.io/reports/com3/2023-09-06-T-16-25-20/checks-nonjavadoc-error-report/index.html
https://kevin222004.github.io/reports/com3/2023-09-06-T-16-25-20/sevntu-check-regression_part_2-report/index.html
https://kevin222004.github.io/reports/com3/2023-09-06-T-16-25-20/test-report/index.html
https://kevin222004.github.io/reports/com3/2023-09-06-T-16-25-20/checks-only-javadoc-error-report/index.html
https://kevin222004.github.io/reports/com3/2023-09-06-T-16-25-20/part1-report/index.html
https://kevin222004.github.io/reports/com3/2023-09-06-T-16-25-20/part5-report/index.html
https://kevin222004.github.io/reports/com3/2023-09-06-T-16-25-20/part6-report/index.html
https://kevin222004.github.io/reports/com3/2023-09-06-T-16-25-20/part4-report/index.html
https://kevin222004.github.io/reports/com3/2023-09-06-T-16-25-20/antlr-report/index.html
https://kevin222004.github.io/reports/com3/2023-09-06-T-16-25-20/part2-report/index.html
https://kevin222004.github.io/reports/com3/2023-09-06-T-16-30-48/part3-report/index.html
https://kevin222004.github.io/reports/com3/2023-09-06-T-16-30-48/sevntu-check-regression_part_1-report/index.html
https://kevin222004.github.io/reports/com3/2023-09-06-T-16-30-48/checks-nonjavadoc-error-report/index.html
https://kevin222004.github.io/reports/com3/2023-09-06-T-16-30-48/sevntu-check-regression_part_2-report/index.html
https://kevin222004.github.io/reports/com3/2023-09-06-T-16-30-48/test-report/index.html
https://kevin222004.github.io/reports/com3/2023-09-06-T-16-30-48/checks-only-javadoc-error-report/index.html
https://kevin222004.github.io/reports/com3/2023-09-06-T-16-30-48/part1-report/index.html
https://kevin222004.github.io/reports/com3/2023-09-06-T-16-30-48/part5-report/index.html
https://kevin222004.github.io/reports/com3/2023-09-06-T-16-30-48/part6-report/index.html
https://kevin222004.github.io/reports/com3/2023-09-06-T-16-30-48/part4-report/index.html
https://kevin222004.github.io/reports/com3/2023-09-06-T-16-30-48/antlr-report/index.html
https://kevin222004.github.io/reports/com3/2023-09-06-T-16-30-48/part2-report/index.html