Skip to content

Commit

Permalink
Issue #11720: Kill surviving mutation in VariableDeclarationUsageDist…
Browse files Browse the repository at this point in the history
…anceCheck related to usage distance
  • Loading branch information
Vyom-Yadav authored and nrmancuso committed Jul 28, 2022
1 parent db05235 commit af99318
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 14 deletions.
9 changes: 0 additions & 9 deletions .ci/pitest-suppressions/pitest-coding-1-suppressions.xml
Expand Up @@ -108,15 +108,6 @@
<lineContent>switch (blockWithVariableUsage.getType()) {</lineContent>
</mutation>

<mutation unstable="false">
<sourceFile>VariableDeclarationUsageDistanceCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.coding.VariableDeclarationUsageDistanceCheck</mutatedClass>
<mutatedMethod>calculateDistanceInSingleScope</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.RemoveConditionalMutator_EQUAL_ELSE</mutator>
<description>removed conditional - replaced equality check with false</description>
<lineContent>if (!firstUsageFound) {</lineContent>
</mutation>

<mutation unstable="false">
<sourceFile>VariableDeclarationUsageDistanceCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.coding.VariableDeclarationUsageDistanceCheck</mutatedClass>
Expand Down
Expand Up @@ -522,6 +522,8 @@ else if (!instanceName.equals(initInstanceName)) {
* @param variableIdentAst
* Variable which distance is calculated for.
* @return entry which contains expression with variable usage and distance.
* If variable usage is not found, then the expression node is null,
* although the distance can be greater than zero.
*/
private static Entry<DetailAST, Integer> calculateDistanceInSingleScope(
DetailAST semicolonAst, DetailAST variableIdentAst) {
Expand All @@ -544,11 +546,6 @@ else if (currentAst.getType() != TokenTypes.VARIABLE_DEF) {
currentAst = currentAst.getNextSibling();
}

// If variable wasn't used after its declaration, distance is 0.
if (!firstUsageFound) {
dist = 0;
}

return new SimpleEntry<>(variableUsageAst, dist);
}

Expand Down

0 comments on commit af99318

Please sign in to comment.