Class ClassDataAbstractionCouplingCheck

  • All Implemented Interfaces:
    Configurable, Contextualizable

    public final class ClassDataAbstractionCouplingCheck
    extends AbstractClassCouplingCheck
    Measures the number of distinct classes that are instantiated within the given class or record. This type of coupling is not caused by inheritance or the object-oriented paradigm. Generally speaking, any data type with other data types as members or local variable that is an instantiation (object) of another class has data abstraction coupling (DAC). The higher the DAC, the more complex the structure of the class.

    This check processes files in the following way:

    1. Iterates over the list of tokens (defined below) and counts all mentioned classes.
    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 7.

    Parent is com.puppycrawl.tools.checkstyle.TreeWalker

    Violation Message Keys:

    • classDataAbstractionCoupling
    Since:
    3.4