Edit on GitHub

Code Smell Strategies

tsmetrics's strategy engine applies multi-metric rules to flag well-known object-oriented code smells. Each strategy combines several low-level metrics into a single yes/no detection with an explanation of which thresholds triggered.

Strategy Level Detection Criteria
God Class Class WMC > 47 AND TCC < 0.33 AND ATFD > 5
Brain Method Function SLOC > 65 AND CC > 5 AND max_nesting > 3
Feature Envy Function ATFD > 5 AND ATFD > local_accesses
Refused Bequest Class DIT > 0 AND override_ratio < 0.33

How strategies appear in output

In the table format, violations are printed below the per-function metrics in a Threshold Violations section.

When to use strategies

Strategies are always computed — you don't need to enable them. Focus your refactoring efforts on files where multiple strategies fire at once: a God Class that also contains Brain Methods is a prime candidate for decomposition.

All strategies

God Class

A class that knows too much and does too much. Detected by high WMC, low cohesion (TCC), and excessive foreign data access (ATFD).

Brain Method

A single function that has become the "brain" of a component — too long, too complex, and too deeply nested to understand.

Feature Envy

A method more interested in another class's data than its own. Detected when foreign data accesses outnumber local ones.

Refused Bequest

A subclass that inherits from a parent but overrides very little, suggesting the inheritance was the wrong design choice.