get_complexity_metrics
Analyze a Java file to measure cyclomatic and cognitive complexity, LOC, and per-method risk. Identify high, medium, or low complexity methods before refactoring.
Instructions
Get cyclomatic complexity, cognitive complexity, LOC.
USAGE: get_complexity_metrics(filePath="path/to/File.java") OUTPUT: The file's line counts, a summary and risk assessment over its methods and, with includeDetails (default true), each method's metrics with the type declaring it
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.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"filePath": "<filePath>"
},
"name": "get_complexity_metrics"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filePath | Yes | Path to source file | |
| includeDetails | No | Include per-method breakdown (default: true) |