This guide walks through a practical workflow for using Stellarion to measure and improve your code quality.
Start by getting an overview of your codebase health:
Analyze the code quality of this project.
Give me an overview of complexity and any issues.
This provides:
Focus on the most problematic code:
Show me the 10 most complex functions in this project.
Which files have the lowest maintainability scores?
Are there any circular dependencies?
Not all issues are equal. Prioritize based on:
Find refactoring opportunities and prioritize by severity.
Focus on code that's frequently modified.
Focus on critical paths:
Analyze the complexity of src/api/ and src/core/
Start with high-impact, low-effort items:
Find refactoring opportunities with low effort and high priority.
Before refactoring, understand the code:
What files depend on src/services/userService.ts?
What would be affected if I refactor this function?
Show me the implementation of the processOrder function.
Work on one issue at a time:
This function has complexity of 35.
Help me break it into smaller functions.
I see duplication between fileA.ts and fileB.ts.
Help me create a shared utility.
This function has deep nesting.
Help me flatten it using early returns.
After changes, verify the improvement:
What's the complexity of processOrder now?
Re-analyze the quality of src/services/
Generate reports to track improvement over time:
Generate a quality report and save it to docs/quality-report.md
Compare with previous reports:
How does this compare to last month's quality report?
| Metric | Target | Action |
|---|---|---|
| Cyclomatic complexity | < 15 | Refactor if higher |
| Cognitive complexity | < 10 | Simplify if higher |
| File size | < 300 lines | Split if larger |
| Function parameters | < 5 | Consider object parameter |
Document your quality standards and use Stellarion to enforce them:
Check if any functions exceed our complexity threshold of 15.
Analyze the complexity of the files I modified.
Flag anything over our threshold.
Include quality metrics in code reviews:
Analyze the quality of the code in this PR.