Skip to main content
Weighted Methods per Class (WMC) is one of the six classic CK (Chidamber & Kemerer) object-oriented metrics. It sums the cyclomatic complexity of every method declared in a class or interface.

What mehen emits

Definition

for each method m_i defined in class C. A class with five methods of cyclomatic complexity {1, 1, 4, 5, 8} has WMC = 19.

Why a sum, not an average

A class with one 50-CC method is different from a class with fifty 1-CC methods, even though the average is the same. WMC captures the total decision burden of a class, which correlates with how much of the class a maintainer must understand to make a change.

How to read it

There is no universal threshold; common conventions: Read WMC alongside NOM: a high WMC with low NOM signals a few very complex methods; a high WMC with high NOM signals a class doing too much.

Languages where WMC applies

WMC is meaningful for languages with explicit class/interface declarations: Java, Kotlin, TypeScript, Python (classes), Ruby, C++, C#. mehen reports wmc = 0 for files with no declarations of those kinds (e.g., a Go file or a procedural C file).

References

  • Chidamber, S. R. & Kemerer, C. F. (1994). A Metrics Suite for Object Oriented Design. IEEE Transactions on Software Engineering 20(6): 476–493. DOI · Author copy (MIT).
  • Basili, V. R., Briand, L. C. & Melo, W. L. (1996). A validation of object-oriented design metrics as quality indicators. IEEE TSE 22(10): 751–761. DOI.
  • Sonar: Metrics definitions.

See also