PMD rule God Class - understanding the metrics

WMC stands for Weighted Methods Count or Weighted Method per Class. The WMC metric is defined as the sum of complexities of all methods declared in a class. This metric is a good indicator how much effort will be necessary to maintain and develop a particular class.

ATFD stands for Access to Foreign Data. This metric represents the number of external classes from which a given class accesses attributes, directly or via accessor-methods.

TCC stands for Tight Class Cohesion. TCC is the relative number of methods directly connected via accesses of attributes.

The code triggers a violation if WMC >= 47 and ATFD > 5 and TCC < 1/3.

You can read about the God class on page 55 in Object-Oriented Metrics in Practice (and you do not have to buy the book to just read 1 page). You can also read the PMD documentation.


  • WMC = Weighted Methods Count
  • ATFD = Access To Foreign Data
  • TCC = Tight Class Cohesion

Baselines seems to be defined as constant values. If you would like to know more, you can find the implementation here. (A little older code, but it is all in one place here.)

Tags:

Java

Pmd