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.Documentation Index
Fetch the complete documentation index at: https://mehen.ophi.dev/llms.txt
Use this file to discover all available pages before exploring further.
What mehen emits
| Key | Type | Description |
|---|---|---|
wmc | int | Sum of cyclomatic complexity across all methods in the file. |
wmc.classes | int | WMC summed over classes only. |
wmc.interfaces | int | WMC summed over interfaces only. |
Definition
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:WMC | Interpretation |
|---|---|
| 1–14 | Small/cohesive class. |
| 15–40 | Normal in Java/C# / TS classes. |
| 41+ | Likely god-class candidate. |
Languages where WMC applies
WMC is meaningful for languages with explicit class/interface declarations: Java, Kotlin, TypeScript, Python (classes), Ruby, C++, C#. mehen reportswmc = 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
- Cyclomatic complexity — the per-method input.
- NOM — number of methods.
- NPM — number of public methods.