get_complexity_metrics
Calculate cyclomatic and cognitive complexity and lines of code for Java source files, providing risk assessment.
Instructions
Get cyclomatic complexity, cognitive complexity, LOC.
USAGE: get_complexity_metrics(filePath="path/to/File.java") OUTPUT: Complexity metrics with risk assessment
Metrics:
Cyclomatic Complexity: Count of decision points (+1 for if/for/while/case/catch)
Cognitive Complexity: Penalizes nesting and breaks in linear flow
LOC: Physical and logical lines of code
Risk levels:
High: CC > 10
Medium: CC 6-10
Low: CC <= 5
Requires load_project to be called first.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| includeDetails | No | Include per-method breakdown (default: true) | |
| granularity | No | Level of detail: 'file', 'type', or 'method' (default: 'file') | |
| filePath | Yes | Path to source file |