TypecastParenPadCheck.java

1
////////////////////////////////////////////////////////////////////////////////
2
// checkstyle: Checks Java source code for adherence to a set of rules.
3
// Copyright (C) 2001-2017 the original author or authors.
4
//
5
// This library is free software; you can redistribute it and/or
6
// modify it under the terms of the GNU Lesser General Public
7
// License as published by the Free Software Foundation; either
8
// version 2.1 of the License, or (at your option) any later version.
9
//
10
// This library is distributed in the hope that it will be useful,
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
// Lesser General Public License for more details.
14
//
15
// You should have received a copy of the GNU Lesser General Public
16
// License along with this library; if not, write to the Free Software
17
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
////////////////////////////////////////////////////////////////////////////////
19
20
package com.puppycrawl.tools.checkstyle.checks.whitespace;
21
22
import com.puppycrawl.tools.checkstyle.api.DetailAST;
23
import com.puppycrawl.tools.checkstyle.api.TokenTypes;
24
25
/**
26
 * <p>Checks the padding of parentheses for typecasts. That is whether a space
27
 * is required after a left parenthesis and before a right parenthesis, or such
28
 * spaces are forbidden.
29
 * </p>
30
 * <p>
31
 * The policy to verify is specified using the {@link PadOption} class and
32
 * defaults to {@link PadOption#NOSPACE}.
33
 * </p>
34
 * <p>
35
 * An example of how to configure the check is:
36
 * </p>
37
 * <pre>
38
 * &lt;module name="TypecastParenPad"/&gt;
39
 * </pre>
40
 * <p>
41
 * An example of how to configure the check to require spaces for the
42
 * parentheses of constructor, method, and super constructor invocations is:
43
 * </p>
44
 * <pre>
45
 * &lt;module name="TypecastParenPad"&gt;
46
 *     &lt;property name="option" value="space"/&gt;
47
 * &lt;/module&gt;
48
 * </pre>
49
 * @author Oliver Burn
50
 */
51
public class TypecastParenPadCheck extends AbstractParenPadCheck {
52
    @Override
53
    public int[] getRequiredTokens() {
54 1 1. getRequiredTokens : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/whitespace/TypecastParenPadCheck::getRequiredTokens to ( if (x != null) null else throw new RuntimeException ) → KILLED
        return new int[] {TokenTypes.RPAREN, TokenTypes.TYPECAST};
55
    }
56
57
    @Override
58
    public int[] getDefaultTokens() {
59 1 1. getDefaultTokens : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/whitespace/TypecastParenPadCheck::getDefaultTokens to ( if (x != null) null else throw new RuntimeException ) → KILLED
        return getRequiredTokens();
60
    }
61
62
    @Override
63
    public int[] getAcceptableTokens() {
64 1 1. getAcceptableTokens : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/whitespace/TypecastParenPadCheck::getAcceptableTokens to ( if (x != null) null else throw new RuntimeException ) → KILLED
        return new int[] {TokenTypes.RPAREN, TokenTypes.TYPECAST};
65
    }
66
67
    @Override
68
    public void visitToken(DetailAST ast) {
69
        // Strange logic in this method to guard against checking RPAREN tokens
70
        // that are not associated with a TYPECAST token.
71 1 1. visitToken : negated conditional → KILLED
        if (ast.getType() == TokenTypes.TYPECAST) {
72 1 1. visitToken : removed call to com/puppycrawl/tools/checkstyle/checks/whitespace/TypecastParenPadCheck::processLeft → KILLED
            processLeft(ast);
73
        }
74 1 1. visitToken : negated conditional → KILLED
        else if (ast.getParent().getType() == TokenTypes.TYPECAST
75 1 1. visitToken : negated conditional → KILLED
                 && ast.getParent().findFirstToken(TokenTypes.RPAREN) == ast) {
76 1 1. visitToken : removed call to com/puppycrawl/tools/checkstyle/checks/whitespace/TypecastParenPadCheck::processRight → KILLED
            processRight(ast);
77
        }
78
    }
79
}

Mutations

54

1.1
Location : getRequiredTokens
Killed by : com.puppycrawl.tools.checkstyle.checks.whitespace.TypecastParenPadCheckTest.test1322879(com.puppycrawl.tools.checkstyle.checks.whitespace.TypecastParenPadCheckTest)
mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/whitespace/TypecastParenPadCheck::getRequiredTokens to ( if (x != null) null else throw new RuntimeException ) → KILLED

59

1.1
Location : getDefaultTokens
Killed by : com.puppycrawl.tools.checkstyle.checks.whitespace.TypecastParenPadCheckTest.test1322879(com.puppycrawl.tools.checkstyle.checks.whitespace.TypecastParenPadCheckTest)
mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/whitespace/TypecastParenPadCheck::getDefaultTokens to ( if (x != null) null else throw new RuntimeException ) → KILLED

64

1.1
Location : getAcceptableTokens
Killed by : com.puppycrawl.tools.checkstyle.checks.whitespace.TypecastParenPadCheckTest.testGetAcceptableTokens(com.puppycrawl.tools.checkstyle.checks.whitespace.TypecastParenPadCheckTest)
mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/whitespace/TypecastParenPadCheck::getAcceptableTokens to ( if (x != null) null else throw new RuntimeException ) → KILLED

71

1.1
Location : visitToken
Killed by : com.puppycrawl.tools.checkstyle.checks.whitespace.TypecastParenPadCheckTest.test1322879(com.puppycrawl.tools.checkstyle.checks.whitespace.TypecastParenPadCheckTest)
negated conditional → KILLED

72

1.1
Location : visitToken
Killed by : com.puppycrawl.tools.checkstyle.checks.whitespace.TypecastParenPadCheckTest.testDefault(com.puppycrawl.tools.checkstyle.checks.whitespace.TypecastParenPadCheckTest)
removed call to com/puppycrawl/tools/checkstyle/checks/whitespace/TypecastParenPadCheck::processLeft → KILLED

74

1.1
Location : visitToken
Killed by : com.puppycrawl.tools.checkstyle.checks.whitespace.TypecastParenPadCheckTest.test1322879(com.puppycrawl.tools.checkstyle.checks.whitespace.TypecastParenPadCheckTest)
negated conditional → KILLED

75

1.1
Location : visitToken
Killed by : com.puppycrawl.tools.checkstyle.checks.whitespace.TypecastParenPadCheckTest.testDefault(com.puppycrawl.tools.checkstyle.checks.whitespace.TypecastParenPadCheckTest)
negated conditional → KILLED

76

1.1
Location : visitToken
Killed by : com.puppycrawl.tools.checkstyle.checks.whitespace.TypecastParenPadCheckTest.testDefault(com.puppycrawl.tools.checkstyle.checks.whitespace.TypecastParenPadCheckTest)
removed call to com/puppycrawl/tools/checkstyle/checks/whitespace/TypecastParenPadCheck::processRight → KILLED

Active mutators

Tests examined


Report generated by PIT 1.2.2