Class ClassFanOutComplexityCheck

  • All Implemented Interfaces:
    Configurable, Contextualizable

    public final class ClassFanOutComplexityCheck
    extends AbstractClassCouplingCheck

    Checks the number of other types a given class/record/interface/enum/annotation relies on. Also, the square of this has been shown to indicate the amount of maintenance required in functional programs (on a file basis) at least.

    This check processes files in the following way:

    1. Iterates over all tokens that might contain type reference.
    2. If a class was imported with direct import (i.e. import java.math.BigDecimal), or the class was referenced with the package name (i.e. java.math.BigDecimal value) and the package was added to the excludedPackages parameter, the class does not increase complexity.
    3. If a class name was added to the excludedClasses parameter, the class does not increase complexity.
    • Property excludeClassesRegexps - Specify user-configured regular expressions to ignore classes. Type is java.util.regex.Pattern[]. Default value is ^$.
    • Property excludedClasses - Specify user-configured class names to ignore. Type is java.lang.String[]. Default value is ArrayIndexOutOfBoundsException, ArrayList, Boolean, Byte, Character, Class, Collection, Deprecated, Deque, Double, DoubleStream, EnumSet, Exception, Float, FunctionalInterface, HashMap, HashSet, IllegalArgumentException, IllegalStateException, IndexOutOfBoundsException, IntStream, Integer, LinkedHashMap, LinkedHashSet, LinkedList, List, Long, LongStream, Map, NullPointerException, Object, Optional, OptionalDouble, OptionalInt, OptionalLong, Override, Queue, RuntimeException, SafeVarargs, SecurityException, Set, Short, SortedMap, SortedSet, Stream, String, StringBuffer, StringBuilder, SuppressWarnings, Throwable, TreeMap, TreeSet, UnsupportedOperationException, Void, boolean, byte, char, double, float, int, long, short, var, void.
    • Property excludedPackages - Specify user-configured packages to ignore. Type is java.lang.String[]. Default value is "".
    • Property max - Specify the maximum threshold allowed. Type is int. Default value is 20.

    Parent is

    Violation Message Keys:

    • classFanOutComplexity