ClassFanOutComplexityCheck.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.metrics;
21
22
import com.puppycrawl.tools.checkstyle.api.TokenTypes;
23
24
/**
25
 * The number of other classes a given class relies on. Also the square
26
 * of this has been shown to indicate the amount of maintenance required
27
 * in functional programs (on a file basis) at least.
28
 *
29
 * @author <a href="mailto:simon@redhillconsulting.com.au">Simon Harris</a>
30
 * @author o_sukhodolsky
31
 */
32
public final class ClassFanOutComplexityCheck extends AbstractClassCouplingCheck {
33
34
    /**
35
     * A key is pointing to the warning message text in "messages.properties"
36
     * file.
37
     */
38
    public static final String MSG_KEY = "classFanOutComplexity";
39
40
    /** Default value of max value. */
41
    private static final int DEFAULT_MAX = 20;
42
43
    /** Creates new instance of this check. */
44
    public ClassFanOutComplexityCheck() {
45
        super(DEFAULT_MAX);
46
    }
47
48
    @Override
49
    public int[] getRequiredTokens() {
50 1 1. getRequiredTokens : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/metrics/ClassFanOutComplexityCheck::getRequiredTokens to ( if (x != null) null else throw new RuntimeException ) → KILLED
        return new int[] {
51
            TokenTypes.PACKAGE_DEF,
52
            TokenTypes.IMPORT,
53
            TokenTypes.CLASS_DEF,
54
            TokenTypes.INTERFACE_DEF,
55
            TokenTypes.ENUM_DEF,
56
            TokenTypes.TYPE,
57
            TokenTypes.LITERAL_NEW,
58
            TokenTypes.LITERAL_THROWS,
59
            TokenTypes.ANNOTATION_DEF,
60
        };
61
    }
62
63
    @Override
64
    public int[] getAcceptableTokens() {
65 1 1. getAcceptableTokens : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/metrics/ClassFanOutComplexityCheck::getAcceptableTokens to ( if (x != null) null else throw new RuntimeException ) → KILLED
        return new int[] {
66
            TokenTypes.PACKAGE_DEF,
67
            TokenTypes.IMPORT,
68
            TokenTypes.CLASS_DEF,
69
            TokenTypes.INTERFACE_DEF,
70
            TokenTypes.ENUM_DEF,
71
            TokenTypes.TYPE,
72
            TokenTypes.LITERAL_NEW,
73
            TokenTypes.LITERAL_THROWS,
74
            TokenTypes.ANNOTATION_DEF,
75
        };
76
    }
77
78
    // -@cs[SimpleAccessorNameNotation] Override methods from base class.
79
    // Issue: https://github.com/sevntu-checkstyle/sevntu.checkstyle/issues/166
80
    @Override
81
    protected String getLogMessageId() {
82 1 1. getLogMessageId : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/metrics/ClassFanOutComplexityCheck::getLogMessageId to ( if (x != null) null else throw new RuntimeException ) → KILLED
        return MSG_KEY;
83
    }
84
}

Mutations

50

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

65

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

82

1.1
Location : getLogMessageId
Killed by : com.puppycrawl.tools.checkstyle.checks.metrics.ClassFanOutComplexityCheckTest.testExcludedPackagesDirectPackages(com.puppycrawl.tools.checkstyle.checks.metrics.ClassFanOutComplexityCheckTest)
mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/metrics/ClassFanOutComplexityCheck::getLogMessageId to ( if (x != null) null else throw new RuntimeException ) → KILLED

Active mutators

Tests examined


Report generated by PIT 1.2.4