Skip to content

Commit

Permalink
Issue #11720: Kill surviving mutation in UnnecessaryParenthesesCheck …
Browse files Browse the repository at this point in the history
…related to lambdas
  • Loading branch information
Vyom-Yadav authored and baratali committed Jul 27, 2022
1 parent 7aa603d commit f9a7aee
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
9 changes: 0 additions & 9 deletions .ci/pitest-suppressions/pitest-coding-1-suppressions.xml
@@ -1,14 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<suppressedMutations>
<mutation unstable="false">
<sourceFile>UnnecessaryParenthesesCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.coding.UnnecessaryParenthesesCheck</mutatedClass>
<mutatedMethod>visitToken</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.RemoveConditionalMutator_EQUAL_IF</mutator>
<description>removed conditional - replaced equality check with true</description>
<lineContent>if (type == TokenTypes.LAMBDA &amp;&amp; isLambdaSingleParameterSurrounded(ast)) {</lineContent>
</mutation>

<mutation unstable="false">
<sourceFile>VariableDeclarationUsageDistanceCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.coding.VariableDeclarationUsageDistanceCheck</mutatedClass>
Expand Down
Expand Up @@ -476,13 +476,13 @@ public int[] getRequiredTokens() {
// -@cs[CyclomaticComplexity] All logs should be in visit token.
@Override
public void visitToken(DetailAST ast) {
final int type = ast.getType();
final DetailAST parent = ast.getParent();

if (type == TokenTypes.LAMBDA && isLambdaSingleParameterSurrounded(ast)) {
if (isLambdaSingleParameterSurrounded(ast)) {
log(ast, MSG_LAMBDA, ast.getText());
}
else if (parent.getType() != TokenTypes.ANNOTATION_MEMBER_VALUE_PAIR) {
final int type = ast.getType();
final boolean surrounded = isSurrounded(ast);
// An identifier surrounded by parentheses.
if (surrounded && type == TokenTypes.IDENT) {
Expand Down Expand Up @@ -623,11 +623,10 @@ private static boolean unnecessaryParenAroundOperators(DetailAST ast) {
}

/**
* Tests if the given lambda node has a single parameter, no defined type, and is surrounded
* by parentheses.
* Tests if the given node has a single parameter, no defined type, and is surrounded
* by parentheses. This condition can only be true for lambdas.
*
* @param ast a {@code DetailAST} whose type is
* {@code TokenTypes.LAMBDA}.
* @param ast a {@code DetailAST} node
* @return {@code true} if the lambda has a single parameter, no defined type, and is
* surrounded by parentheses.
*/
Expand Down

0 comments on commit f9a7aee

Please sign in to comment.