sourcery_analytics.metrics.method_length¶
Method length calculations.
The length of a method is a simple heuristic for assessing its complexity. In general, longer methods can be broken up into smaller ones to simplify the code.
Note that for obvious reasons, the method length is only defined for methods.
- sourcery_analytics.metrics.method_length.method_length(method: FunctionDef) int ¶
Calculates the method length as the number of statements in the method.
- Parameters
method – a node for a function definition
Examples
>>> method_length("def add(x, y): z = x + y; return z") 2