get_complexity_metrics
Analyze Java code complexity metrics including cyclomatic complexity, cognitive complexity, and LOC to assess maintainability risk levels.
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 |
|---|---|---|---|
| filePath | Yes | Path to source file | |
| granularity | No | Level of detail: 'file', 'type', or 'method' (default: 'file') | |
| includeDetails | No | Include per-method breakdown (default: true) |