Skip to content

Check: Low Coupling

Madeline Kahn edited this page Mar 11, 2024 · 4 revisions
  • Name: "lowCoupling"
  • Default: Enabled

Configuration

Name Type Description
coupMaxInDegree int Specifies the maximum In-Degree for a class. -1 for no max. Defaults to -1
coupMaxOutDegree int Specifies the maximum Out-Degree for a class. -1 for no max. Defaults to -1
coupIgnorePackage String Specifies a package to ignore in a check (for example, ignore the presentation layer). Defaults to null
coupCycles boolean Specifies whether to check for cycles. Defaults to true
coupIgnoreSelfCycles boolean Specifies whether Classes that reference themselves will be reported (cycles like A --> A). Defaults to true

Description

Searches a graph of all of the classes. Degree is defined by how many different classes have an edge with a class. A class has an edge with another class if it extends, implements, has-a, or depends on the other class. A warning is raised for any class exceeding either the inDegree or outDegree max. Also searches for any cycles in the graph. Raises a warning for each cycle found. This is done by starting at a vertex, then following all edges and keeping track of the path. If a path contains a duplicate, then a cycle was found. Once this is done, if there are any remaining vertices that have not been looked at, it does the same at one of those vertices, until all have been iterated through. To make it a bit more efficient, a Priority Queue is used to sort the vertices by lowest in-Degree, so any sources are checked first.