Skip to content

YASWANTH1976/code-complexity-analyzer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 

Repository files navigation

python code-analysis code-quality cli-tool open-source

πŸ“Š Code Complexity Analyzer

A Python CLI tool that analyzes Python code quality and provides detailed complexity metrics. Perfect for developers who want to maintain clean, maintainable code.

✨ Features

  • 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

πŸš€ Quick Start

Installation

# 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!

Usage

Analyze a single file:

python analyzer.py my_script.py

Analyze an entire directory:

python analyzer.py ./my_project/

πŸ“‹ Example Output

╔═══════════════════════════════════════════════════════════╗
β•‘        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.
============================================================

🎯 Metrics Explained

Complexity Score

  • 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

What It Analyzes

  • 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

πŸ› οΈ Technical Details

  • Language: Python 3.6+
  • Dependencies: None (uses only standard library)
  • Key Libraries: ast, pathlib, os

πŸ’‘ Use Cases

  • 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

🀝 Contributing

Contributions are welcome! This is a learning project built as part of GSoC 2026 preparation.

Ideas for Enhancement

  • Add support for other languages
  • Integrate with CI/CD pipelines
  • Generate HTML reports
  • Add test coverage metrics
  • Create configuration file support

πŸ“„ License

MIT License - feel free to use and modify!

πŸ‘€ Author

Yaswanth

  • GitHub: @YASWANTH1976
  • Building open-source skills for GSoC 2026

⭐ If you find this useful, please star the repository!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages