Codelint-MCP / src /resources /static /complexity_guide.md
OsamaAliMid's picture
Add CodeLint MCP Premium Edition application
ec37394
# Complexity Metrics Guide
## Cyclomatic Complexity
Measures the number of linearly independent paths through code.
### Rankings
- **A (1-5)**: Simple, easy to maintain
- **B (6-10)**: Moderate complexity
- **C (11-20)**: High complexity, consider refactoring
- **D (21-30)**: Very high, definitely refactor
- **F (31+)**: Extremely complex, needs immediate attention
## Maintainability Index
Score from 0-100 indicating how maintainable code is.
### Thresholds
- **85-100**: Highly maintainable ✅
- **65-84**: Moderately maintainable ⚠️
- **< 65**: Difficult to maintain ❌
## Reducing Complexity
### 1. Extract Methods
Break large functions into smaller, focused ones.
### 2. Eliminate Nested Logic
Replace nested if-else with early returns.
```python
# Bad: Nested
def process(data):
if data:
if data.valid:
if data.ready:
return data.process()
return None
# Good: Early returns
def process(data):
if not data:
return None
if not data.valid:
return None
if not data.ready:
return None
return data.process()
```
### 3. Use Design Patterns
Apply appropriate patterns to simplify logic.
### 4. Reduce Dependencies
Minimize coupling between modules.