Skip to content

About

A powerful multi-language code analyzer with support for 30+ programming languages, featuring code statistics, dependency analysis, and interactive visualizations

Resources

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Code Analyzer

πŸ“‹ Table of Contents

✨ Features

πŸ” Code Analysis

  • Multi-language Support: Supports code analysis for 30+ programming languages
  • Detailed Statistics: Provides total lines, code lines, comment lines, and blank lines statistics
  • Language Distribution: Visual display of programming language proportions and distribution
  • File Structure: Detailed file list and directory structure analysis

πŸ“Š Data Visualization

  • Pie Charts: Language distribution visualization
  • Bar Charts: Code line statistics comparison
  • Interactive Charts: Dynamic chart display based on Chart.js

πŸ”— Dependency Analysis

  • Internal Dependencies: Analyze dependency relationships between internal project modules
  • External Dependencies: Identify third-party libraries and framework dependencies
  • Circular Dependency Detection: Automatically detect and report circular dependency issues
  • Dependency Graph: Visualize dependency relationship networks

πŸš€ User Experience

  • Smart Path Completion: Real-time path auto-completion functionality
  • Drag & Drop Support: Support for dragging folders for analysis
  • History Records: Automatically save recently analyzed projects
  • Quick Access: Quick access buttons for common directories
  • Project Type Recognition: Automatically identify project types (Node.js, Python, Java, etc.)

⚑ Performance Optimization

  • Multiprocessing: Support for multiprocess parallel analysis to improve processing speed
  • Smart Exclusion: Automatically exclude irrelevant directories like node_modules, .git
  • Progress Monitoring: Real-time display of analysis progress and processing status
  • Memory Optimization: Optimized memory usage for large projects

πŸ“€ Export Features

  • JSON Format: Export detailed analysis data
  • HTML Reports: Generate visual HTML reports
  • CSV Data: Export tabular data for further analysis

πŸ”§ System Requirements

  • Python: 3.7 or higher
  • Operating System: Windows 10+, macOS 10.14+, Linux (Ubuntu 18.04+)
  • Memory: 4GB+ recommended
  • Disk Space: At least 100MB available space

πŸ“¦ Installation

Method 1: Automatic Installation (Recommended)

  1. Clone the project
git clone https://github.com/your-username/code-analyzer.git
cd code-analyzer
  1. Run the startup script
python start.py

The startup script will automatically:

  • Check Python version
  • Install required dependencies
  • Create necessary directories
  • Start the web service

Method 2: Manual Installation

  1. Clone the project
git clone https://github.com/your-username/code-analyzer.git
cd code-analyzer
  1. Create virtual environment (optional but recommended)
python -m venv venv

# Windows
venv\Scripts\activate

# macOS/Linux
source venv/bin/activate
  1. Install dependencies
pip install -r requirements.txt
  1. Start the service
python app.py

πŸš€ Quick Start

  1. Start the service

    python start.py
  2. Open browser Visit http://localhost:5001

  3. Select project

    • Enter project path
    • Or use quick access buttons
    • Or drag folder to input box
  4. Start analysis Click "Start Analysis" button and wait for completion

  5. View results

    • View statistical overview
    • Browse visualization charts
    • Analyze dependencies
    • Export analysis reports

πŸ“– Usage Guide

Project Selection

Quick Access

  • πŸ–₯️ Desktop: Quick access to desktop directory
  • πŸ“„ Documents: Quick access to documents directory
  • ⬇️ Downloads: Quick access to downloads directory
  • πŸ“± Applications: Quick access to applications directory

Smart Input

  • Path Completion: Auto-complete suggestions when entering paths
  • Drag & Drop Support: Directly drag folders to input box
  • History Records: Automatically save recently analyzed projects

Project Recognition

The system automatically recognizes project types:

  • πŸ“¦ Node.js: Detects package.json
  • 🐍 Python: Detects requirements.txt
  • β˜• Java Maven: Detects pom.xml
  • 🐘 Java Gradle: Detects build.gradle
  • πŸ¦€ Rust: Detects Cargo.toml
  • 🐹 Go: Detects go.mod
  • πŸ’Ž Ruby: Detects Gemfile
  • πŸ”· C#: Detects .csproj
  • βš™οΈ C/C++: Detects CMakeLists.txt

Performance Settings

Multiprocessing

  • Enable Multiprocessing: Utilize multi-core CPU for accelerated analysis
  • Process Count Setting: Manual setting or automatic detection of optimal process count
  • Memory Management: Automatic memory usage optimization

Analysis Options

  • Exclude Directories: Automatically exclude node_modules, .git, __pycache__, etc.
  • File Filtering: Support filtering by file type and size
  • Encoding Detection: Automatic file encoding detection

Viewing Results

Statistical Overview

  • Total Files: Total number of files in the project
  • Total Lines: Sum of lines in all files
  • Code Lines: Pure code lines (excluding comments and blank lines)
  • Programming Languages: Number of detected programming languages

Visualization Charts

  • Language Distribution Pie Chart: Proportion of each language's code
  • Code Lines Bar Chart: Comparison of code lines by language
  • Interactive Features: Click legend to hide/show corresponding data

Dependency Analysis

  • Internal Dependencies: Reference relationships between project modules
  • External Dependencies: Usage of third-party libraries and frameworks
  • Circular Dependencies: Detect and highlight circular dependencies
  • Complexity Assessment: Evaluate project complexity based on dependencies

Export Features

Supports multiple format data exports:

  1. JSON Format: Complete analysis data, suitable for programmatic processing
  2. HTML Reports: Visual reports with charts
  3. CSV Data: Tabular format, suitable for Excel and other tools

πŸ”Œ API Documentation

Basic APIs

Analyze Project

POST /api/analyze
Content-Type: application/json

{
  "project_path": "/path/to/project",
  "use_multiprocessing": true,
  "max_workers": 4
}

Get Progress

GET /api/progress

Validate Path

POST /api/validate_path
Content-Type: application/json

{
  "path": "/path/to/validate"
}

Path Auto-completion

POST /api/autocomplete_path
Content-Type: application/json

{
  "path": "/partial/path"
}

Export APIs

Export Report

POST /api/export
Content-Type: application/json

{
  "format": "json|html|csv",
  "data": { /* analysis result data */ }
}

Download File

GET /api/download/<filename>

System APIs

Get System Info

GET /api/system_info

Get Recent Projects

GET /api/recent_projects

πŸ“ Project Structure

code-analyzer/
β”œβ”€β”€ app.py                 # Flask web application main file
β”œβ”€β”€ code_analyzer.py       # Core analysis engine
β”œβ”€β”€ start.py              # Startup script
β”œβ”€β”€ requirements.txt      # Python dependencies
β”œβ”€β”€ README.md            # Project documentation (Chinese)
β”œβ”€β”€ README_EN.md         # Project documentation (English)
β”œβ”€β”€ static/              # Static resources directory
β”‚   β”œβ”€β”€ css/
β”‚   β”‚   └── style.css    # Style file
β”‚   └── js/
β”‚       └── app.js       # Frontend JavaScript
β”œβ”€β”€ templates/           # HTML template directory
β”‚   └── index.html       # Main page template
└── exports/             # Export files directory

Core Module Description

app.py - Web Service

  • Flask application configuration and routing
  • API interface implementation
  • File upload and download handling
  • Error handling and logging

code_analyzer.py - Analysis Engine

  • Multi-language code analysis
  • File statistics and line counting
  • Dependency relationship analysis
  • Multiprocess parallel processing

start.py - Startup Script

  • Environment checking and dependency installation
  • Automated deployment process
  • System compatibility detection

Frontend Files

  • static/js/app.js: Frontend interaction logic
  • static/css/style.css: Interface style design
  • templates/index.html: Page structure template

πŸ›  Tech Stack

Backend Technologies

  • Python 3.7+: Main programming language
  • Flask 2.3.3: Web framework
  • Flask-CORS: Cross-origin request support
  • chardet: Character encoding detection
  • Pygments: Syntax highlighting support

Frontend Technologies

  • HTML5: Page structure
  • CSS3: Style design (responsive layout support)
  • JavaScript ES6+: Interaction logic
  • Chart.js: Data visualization
  • Font Awesome: Icon library

Core Algorithms

  • Multiprocess Parallel Processing: Using Python multiprocessing
  • AST Syntax Analysis: Based on Python ast module
  • Regular Expression Matching: Multi-language import/include detection
  • Graph Algorithms: Dependency relationships and cycle detection

βš™οΈ Configuration

Supported Programming Languages

The system supports analysis of the following programming languages:

Language File Extensions Feature Support
Python .py, .pyw, .pyx βœ… Dependency Analysis
JavaScript .js, .jsx, .mjs βœ… Dependency Analysis
TypeScript .ts, .tsx βœ… Dependency Analysis
Java .java βœ… Dependency Analysis
C++ .cpp, .cc, .cxx, .hpp βœ… Dependency Analysis
C .c, .h βœ… Dependency Analysis
C# .cs βœ… Dependency Analysis
Go .go βœ… Dependency Analysis
Rust .rs ⚠️ Basic Analysis
PHP .php, .phtml ⚠️ Basic Analysis
Ruby .rb ⚠️ Basic Analysis
Swift .swift ⚠️ Basic Analysis
Kotlin .kt, .kts ⚠️ Basic Analysis
HTML .html, .htm ⚠️ Basic Analysis
CSS .css, .scss, .sass ⚠️ Basic Analysis
Others More formats... ⚠️ Basic Analysis

Exclusion Rules

The following directories and files are excluded by default:

Directory Exclusions:

  • node_modules/ - Node.js dependencies
  • .git/ - Git version control
  • __pycache__/ - Python cache
  • venv/, env/ - Python virtual environments
  • build/, dist/ - Build outputs
  • .idea/, .vscode/ - IDE configurations
  • target/ - Java build output

File Exclusions:

  • .DS_Store - macOS system files
  • Thumbs.db - Windows thumbnails
  • *.lock - Lock files
  • .gitignore - Git ignore files

Performance Parameters

Performance can be adjusted with the following parameters:

# Multiprocessing settings
use_multiprocessing = True  # Whether to enable multiprocessing
max_workers = None          # Maximum number of processes (None for auto-detection)

# File size limits
max_file_size = 10 * 1024 * 1024  # 10MB

# Timeout settings
analysis_timeout = 300  # 5 minutes

❓ FAQ

Q: Analysis is very slow, what should I do?

A:

  1. Enable multiprocessing
  2. Exclude unnecessary large directories
  3. Check disk space and memory usage
  4. Consider batch analysis for large projects

Q: Some files are not being analyzed?

A:

  1. Check if file extensions are in the supported list
  2. Ensure files are not in excluded directories
  3. Check if file encoding is correct
  4. Verify file size doesn't exceed limits

Q: Dependency analysis is inaccurate?

A:

  1. Ensure project structure is complete
  2. Check import statement formats
  3. Some dynamic imports may not be detected
  4. Complex conditional imports may be ignored

Q: Memory usage is too high?

A:

  1. Reduce concurrent process count
  2. Exclude large files and directories
  3. Process large projects in batches
  4. Increase system memory

Q: How to add support for new programming languages?

A:

  1. Add file extensions to language_extensions
  2. Add import patterns to import_patterns (optional)
  3. Test and submit a Pull Request

🀝 Contributing

We welcome all forms of contributions!

How to Contribute

  1. Fork the project

    git clone https://github.com/your-username/code-analyzer.git
  2. Create feature branch

    git checkout -b feature/amazing-feature
  3. Commit changes

    git commit -m 'Add some amazing feature'
  4. Push branch

    git push origin feature/amazing-feature
  5. Create Pull Request

Contribution Types

  • πŸ› Bug Fixes: Report and fix issues
  • ✨ New Features: Add new analysis features
  • πŸ“ Documentation: Improve documentation and examples
  • 🎨 Interface: Optimize user interface and experience
  • ⚑ Performance: Improve analysis speed and efficiency
  • 🌐 Internationalization: Add multi-language support

Development Environment Setup

  1. Install development dependencies

    pip install -r requirements.txt
    pip install pytest black flake8  # Development tools
  2. Run tests

    pytest tests/
  3. Code formatting

    black .
    flake8 .

Code Standards

  • Follow PEP 8 Python code standards
  • Use meaningful variable and function names
  • Add appropriate comments and docstrings
  • Write unit tests covering new features
  • Maintain backward compatibility

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

Thanks to the following open source projects for their support:

πŸ“ž Contact Us


If this project helps you, please give us a ⭐ Star!

⬆ Back to Top

About

A powerful multi-language code analyzer with support for 30+ programming languages, featuring code statistics, dependency analysis, and interactive visualizations

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages