python code-analysis code-quality cli-tool open-source
A Python CLI tool that analyzes Python code quality and provides detailed complexity metrics. Perfect for developers who want to maintain clean, maintainable code.
- Line Analysis: Count total lines, code lines, blank lines, and comments
- Structure Analysis: Identify classes, functions, and imports
- Complexity Scoring: Calculate cyclomatic complexity approximation
- Quality Grading: Get A-D grades based on code complexity
- Smart Recommendations: Receive actionable suggestions for improvement
- Batch Analysis: Analyze entire directories at once
# Clone the repository
git clone https://github.com/YASWANTH1976/code-complexity-analyzer.git
cd code-complexity-analyzer
# No dependencies needed - uses Python standard library only!Analyze a single file:
python analyzer.py my_script.pyAnalyze an entire directory:
python analyzer.py ./my_project/βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β CODE COMPLEXITY ANALYZER v1.0 β
β Analyze Python Code Quality Metrics β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
============================================================
CODE COMPLEXITY ANALYSIS REPORT
============================================================
File: example.py
============================================================
π LINE METRICS:
Total Lines: 145
Code Lines: 98
Blank Lines: 32
Comment Lines: 15
ποΈ STRUCTURE METRICS:
Classes: 3
Functions: 12
Imports: 5
π COMPLEXITY ANALYSIS:
Complexity Score: 15
Quality Grade: B
Assessment: π Good - Moderate complexity
============================================================
RECOMMENDATIONS:
============================================================
β’ Code looks good! Keep up the quality standards.
============================================================
- 1-10 (Grade A): β Excellent - Low complexity
- 11-20 (Grade B): π Good - Moderate complexity
- 21-30 (Grade C):
β οΈ Fair - Consider refactoring - 31+ (Grade D): β High complexity - Needs refactoring
- Decision Points: If/else statements, loops, exception handlers
- Function Count: Total number of function definitions
- Class Structure: Object-oriented design patterns
- Documentation: Comment and docstring coverage
- Language: Python 3.6+
- Dependencies: None (uses only standard library)
- Key Libraries:
ast,pathlib,os
- Code Reviews: Quick quality assessment before commits
- Learning: Understand complexity in your practice projects
- Refactoring: Identify areas that need improvement
- Open Source: Maintain quality standards in contributions
Contributions are welcome! This is a learning project built as part of GSoC 2026 preparation.
- Add support for other languages
- Integrate with CI/CD pipelines
- Generate HTML reports
- Add test coverage metrics
- Create configuration file support
MIT License - feel free to use and modify!
Yaswanth
- GitHub: @YASWANTH1976
- Building open-source skills for GSoC 2026
β If you find this useful, please star the repository!