The analyze_quality tool measures code quality through multiple dimensions: complexity scores, circular dependency detection, and unused code identification. It's essential for understanding code health and identifying areas that need attention.
Stellarion uses the ComplexityAnalyzer engine with tree-sitter AST parsing to calculate accurate complexity metrics. It respects .gitignore patterns and excludes common directories like node_modules, build artifacts, and the .stellarion data directory.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
type | string | No | complexity | Analysis type: complexity, circular_deps, or unused_code |
path | string | No | . | Directory or file to analyze |
threshold | number | No | 10 | Complexity threshold for filtering results |
metric | string | No | cyclomatic | Metric to use: cyclomatic, cognitive, or both |
groupBySeverity | boolean | No | true | Group results by severity level |
includeTests | boolean | No | false | Include test files in analysis |
limit | number | No | 50 | Maximum results to return |
summaryOnly | boolean | No | false | Return only statistics without detailed file lists |
mcp__stellarion__analyze_quality type:complexity path:src/ threshold:15 groupBySeverity:true
Measure cyclomatic and cognitive complexity of your code.
Natural Language:
Find all complex functions in my codebase
Direct MCP Call:
mcp__stellarion__analyze_quality type:complexity path:src/ threshold:15 metric:both
Returns: Functions exceeding the threshold, grouped by severity
Detect circular import chains that can cause issues.
Natural Language:
Are there any circular dependencies in this project?
Direct MCP Call:
mcp__stellarion__analyze_quality type:circular_deps path:src/
Returns: All circular dependency chains with severity classification
Find potentially unused functions, classes, and variables.
Natural Language:
What code in this project might be unused?
Direct MCP Call:
mcp__stellarion__analyze_quality type:unused_code path:src/ includeTests:false
Returns: Potentially unused elements grouped by type
Natural Language:
Show me all functions with cyclomatic complexity over 20
Direct MCP Call:
mcp__stellarion__analyze_quality type:complexity threshold:20 metric:cyclomatic groupBySeverity:true
Natural Language:
Which functions are hardest to understand (high cognitive complexity)?
Direct MCP Call:
mcp__stellarion__analyze_quality type:complexity threshold:15 metric:cognitive
Natural Language:
Analyze complexity in the services directory
Direct MCP Call:
mcp__stellarion__analyze_quality type:complexity path:src/services/ threshold:10
Natural Language:
Give me a high-level summary of code complexity, not detailed files
Direct MCP Call:
mcp__stellarion__analyze_quality type:complexity summaryOnly:true
Natural Language:
Find circular dependencies and show me the severity
Direct MCP Call:
mcp__stellarion__analyze_quality type:circular_deps minCycleLength:2
Natural Language:
What functions and classes might be unused?
Direct MCP Call:
mcp__stellarion__analyze_quality type:unused_code groupByType:true
Each function/file includes:
| Field | Description |
|---|---|
| Function name | Name of the function or method |
| File path | Location in the codebase |
| Line numbers | Start and end lines |
| Cyclomatic complexity | Number of independent paths through the code |
| Cognitive complexity | Measure of how hard the code is to understand |
| Maintainability index | Score from 0-100 (higher is better) |
| Severity | Critical, high, medium, or low |
| Field | Description |
|---|---|
| Files in cycle | List of files involved |
| Cycle length | Number of files in the chain |
| Severity | Based on cycle length and file importance |
| Field | Description |
|---|---|
| Element name | Function, class, or variable name |
| Element type | What kind of element it is |
| File location | Where it's defined |
| Confidence | How confident the detection is |
Measures the number of independent paths through the code. Each decision point (if, for, while, case, catch, etc.) increases the count.
| Score | Interpretation | Recommendation |
|---|---|---|
| 1-10 | Simple | Generally acceptable |
| 11-20 | Moderate | Consider simplification |
| 21-30 | Complex | Should be refactored |
| 31+ | Very complex | High priority for refactoring |
Measures how difficult code is to understand, accounting for nesting depth and break in linear flow.
| Score | Interpretation | Recommendation |
|---|---|---|
| 0-5 | Easy to understand | Excellent |
| 6-10 | Moderate effort | Acceptable |
| 11-15 | Hard to understand | Needs attention |
| 16+ | Very difficult | Refactor urgently |
A composite score from 0-100 based on complexity, lines of code, and Halstead metrics.
| Score | Interpretation |
|---|---|
| 65-100 | Highly maintainable |
| 35-64 | Moderately maintainable |
| 0-34 | Difficult to maintain |
| Level | Cyclomatic | Description | Action |
|---|---|---|---|
| Critical | > 30 | Extremely complex | Immediate refactoring needed |
| High | 20-30 | Very complex | Plan refactoring soon |
| Medium | 15-20 | Moderately complex | Monitor and consider improvements |
| Low | 10-15 | Acceptable complexity | No immediate action needed |
groupBySeverity: true: Makes it easy to prioritize fixessummaryOnly: true for quick health checks: Get the big picture without details