Skip to content

Commit

Permalink
Issue #11720: Kill surviving mutation in RequireThisCheck related to …
Browse files Browse the repository at this point in the history
…getting block-definition for the code
  • Loading branch information
Vyom-Yadav authored and nrmancuso committed Jul 3, 2022
1 parent 9bf2e1b commit a6b980f
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,4 @@
<description>removed conditional - replaced equality check with true</description>
<lineContent>if (variableDeclarationFrame.getType() == FrameType.CLASS_FRAME) {</lineContent>
</mutation>

<mutation unstable="false">
<sourceFile>RequireThisCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.coding.RequireThisCheck</mutatedClass>
<mutatedMethod>getCodeBlockDefinitionToken</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.RemoveConditionalMutator_EQUAL_IF</mutator>
<description>removed conditional - replaced equality check with true</description>
<lineContent>&amp;&amp; parent.getType() != TokenTypes.CTOR_DEF</lineContent>
</mutation>
</suppressedMutations>
1 change: 0 additions & 1 deletion .ci/pitest-survival-check-html.sh
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ pitest-coding-2)

pitest-coding-require-this-check)
declare -a ignoredItems=(
"RequireThisCheck.java.html:<td class='covered'><pre><span class='survived'> &#38;&#38; parent.getType() != TokenTypes.CTOR_DEF</span></pre></td></tr>"
"RequireThisCheck.java.html:<td class='covered'><pre><span class='survived'> if (variableDeclarationFrame.getType() == FrameType.CLASS_FRAME) {</span></pre></td></tr>"
);
checkPitestReport ignoredItems
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,6 @@ private static DetailAST getCodeBlockDefinitionToken(DetailAST ident) {
DetailAST parent = ident.getParent();
while (parent != null
&& parent.getType() != TokenTypes.METHOD_DEF
&& parent.getType() != TokenTypes.CTOR_DEF
&& parent.getType() != TokenTypes.STATIC_INIT) {
parent = parent.getParent();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,14 @@ public void testRecordsDefault() throws Exception {
expected);
}

@Test
public void testLocalClassesInsideLambdas() throws Exception {
final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
verifyWithInlineConfigParser(
getPath("InputRequireThisLocalClassesInsideLambdas.java"),
expected);
}

@Test
public void testUnusedMethod() throws Exception {
final DetailAstImpl ident = new DetailAstImpl();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
RequireThis
checkFields = (default)true
checkMethods = (default)true
validateOnlyOverlapping = false
*/

package com.puppycrawl.tools.checkstyle.checks.coding.requirethis;

import java.util.function.Consumer;

public interface InputRequireThisLocalClassesInsideLambdas {

private static void method(Consumer<String> consumer) {
consumer.accept("foo");
}

private static void testCtorNestedInLambdaWithViolation() {
method(s -> {
class InnerSubscriber implements InputRequireThisLocalClassesInsideLambdas {
int index;

public InnerSubscriber(int index) {
this.index = index; // ok
}
}
});
}
}

0 comments on commit a6b980f

Please sign in to comment.