Issue #13095: kill mutation for VariableDeclarationUsageDistanceCheck 4#13120
Issue #13095: kill mutation for VariableDeclarationUsageDistanceCheck 4#13120rdiachenko merged 1 commit intocheckstyle:masterfrom
Conversation
|
Not Ready to merge Regression started at https://github.com/Kevin222004/Kevin222004.github.io/actions/runs/5140708944/jobs/9252421769?pr=14 |
|
@Kevin222004 , please remove mutation survival from config |
1 similar comment
|
@Kevin222004 , please remove mutation survival from config |
|
@romani ready for review |
|
@rdiachenko please review this as well |
this is stable side-effect of pitest demands. Previosly, all times we followed pitest. I am not sure when to stop this fanaticism, but I ok to keep do code change in favor of pitest. |
There was a problem hiding this comment.
ok to merge.
this code looks so familiar .....
@Vyom-Yadav , did we merge your update for this method ?
@romani even though, it is a stable side-effect, we are lucky there are no heavy operations in the loop. I'm more inclined to not follow pitest in such cases and put this case to a list of potentially bad side effects. @Kevin222004 could you resolve a conflict and regenerate report please? |
started |
|
@Kevin222004 , please create issue on side effects, to let you be able to modify it as we go. @rdiachenko , for now lets keep moving with following pitest, in this particular case it is nano optimization, so better to have NOT pitest survival, it will help later on in maintenance and defending no survival from other contributors. |
@romani No, would you like to merge it first? Edit: |
|
@Vyom-Yadav , your update/PR still not ready, there items to resolve. |
|
@Kevin222004 Instead of removing the condition try: while (result
&& !isUsedVariableDeclarationFound
&& currentSiblingAst != null) {
switch (currentSiblingAst.getType()) {
case TokenTypes.EXPR:
final DetailAST methodCallAst = currentSiblingAst.getFirstChild();
if (methodCallAst.getType() == TokenTypes.METHOD_CALL) {
final String instanceName =
getInstanceName(methodCallAst);
// method is called without instance
if (instanceName.isEmpty()) {
result = false;
}
// differs from previous instance
else if (!instanceName.equals(initInstanceName)) {
if (initInstanceName.isEmpty()) {
initInstanceName = instanceName;
}
else {
result = false;
}
}
}
else {
// is not method call
result = false;
}
break;
case TokenTypes.VARIABLE_DEF:
final String currentVariableName = currentSiblingAst
.findFirstToken(TokenTypes.IDENT).getText();
isUsedVariableDeclarationFound = variableName.equals(currentVariableName);
break;
default:
result = currentSiblingAst.getType() == TokenTypes.SEMI;
}
currentSiblingAst = currentSiblingAst.getPreviousSibling();
} My thinking is that instead of removing the condition, we can continue if the token is A single dangling |
|
We would be able to kill the mutation this way and have the condition to save time too. |
|
Github, generate report |
|
Github, generate report |
|
Report generation failed on phase "parse_body", |
|
@Kevin222004 , please resolve conflict meanwhile |
58efd9b to
169809f
Compare
romani
left a comment
There was a problem hiding this comment.
ok to merge.
Reason: https://github.com/checkstyle/checkstyle/pull/13120/files#r1234129636
|
@Kevin222004 , please resolve IDEA inspection. |
|
Github, generate report |
85faf71 to
cb2c2fd
Compare
|
Github, generate report |
|
@romani Please check failure are not related to change |
|
Github, generate report |
|
@Kevin222004 please rebase on master and make sure all checks are green. |
|
Rebased in GitHub |
Issue #13095: kill mutation for VariableDeclarationUsageDistanceCheck 4
Check
https://checkstyle.org/config_coding.html#VariableDeclarationUsageDistance
Mutation
checkstyle/config/pitest-suppressions/pitest-coding-1-suppressions.xml
Lines 102 to 109 in 81448ea
My thinking is that instead of removing the condition, we can continue if the token is SEMI and set the result to true. Now this won't have any problem as other branches can alter the result in the subsequent iterations and result is by default true.
A single dangling ; would be EMPTY_STAT and not SEMI. Please run regression on this method.
https://checkstyle-diff-reports.s3.us-east-2.amazonaws.com/2e4b5ad_2023084207/reports/diff/index.html
https://checkstyle-diff-reports.s3.us-east-2.amazonaws.com/2e4b5ad_2023213552/reports/diff/index.html
Diff Regression config: https://gist.githubusercontent.com/Kevin222004/12b3bfed9dcea32830f532159c5023c6/raw/1d2cf31a526f452572fc41bf922762ecc5c6b7d6/variable.xml
Diff Regression projects: https://gist.githubusercontent.com/Kevin222004/21e3934e85f802e2fbd48af06d122364/raw/604256badd733d8568064f371d55657c04b00dfd/test-projects-2.properties
Report label: New-Regression-1