📊 轻量级代码库统计分析工具 | 支持多语言检测、代码行数统计、注释分析 | 开箱即用的开发效率分析利器
CodePulse 是一款轻量级的代码统计可视化工具,能够快速分析代码库的各项指标,包括文件数量、行数统计、编程语言分布等,为开发者提供清晰的项目概况。
核心价值:
- ⚡ 快速分析:几秒内完成整个代码库的统计分析
- 📊 多语言支持:支持超过30种主流编程语言的智能识别
- 📈 可视化输出:终端彩色输出与ASCII图表,清晰直观
- 📤 多格式导出:支持JSON、Markdown等多种报告格式
- 🎯 精确统计:区分代码行、注释行、空行,统计数据更准确
解决的用户痛点:
- 手动统计代码量耗时费力,效率低下
- 难以快速了解新接手项目的代码规模和技术栈分布
- 团队代码质量评估缺乏量化指标
- 需要生成代码统计报告时没有便捷工具
自研差异化亮点:
- 🌟 零依赖设计:仅依赖Python标准库,部署简单
- 🎨 彩色终端输出:高可读性的彩色表格和图表展示
- 📊 智能语言检测:自动识别编程语言,支持自定义扩展
- 💾 轻量高效:纯Python实现,无需额外运行时环境
灵感来源:
- 开发者日常需要快速了解代码库规模
- 项目交接时需要量化代码指标
- 代码审查和质量评估需要数据支撑
- 🚀 秒级分析:优化算法实现快速代码库扫描
- 💻 30+语言支持:Python、JavaScript、TypeScript、Java、Go、Rust等
- 📊 多维度统计:文件数、代码行、注释行、空行全面覆盖
- 🎯 智能分类:自动识别编程语言及文件类型
- 📈 可视化图表:终端ASCII图表,直观展示语言分布
- 📤 多格式导出:JSON、Markdown格式报告一键生成
- ⚙️ 灵活配置:YAML配置文件自定义扫描规则
- 🎨 彩色输出:高可读性的彩色终端界面
- Python 3.7+
- pip 包管理工具
# 克隆仓库
git clone https://github.com/gitstq/codepulse.git
cd codepulse
# 安装依赖
pip install -r requirements.txt
# 赋予执行权限
chmod +x codepulse.py# 分析当前目录
python codepulse.py --dir .
# 分析指定目录
python codepulse.py --dir /path/to/your/project
# 显示帮助信息
python codepulse.py --help# 分析当前目录
python codepulse.py
# 分析指定目录
python codepulse.py --dir ./src
# 分析并导出JSON报告
python codepulse.py --dir ./src --format json --output report.json
# 分析并导出Markdown报告
python codepulse.py --dir ./src --format markdown --output report.md# 排除多个目录
python codepulse.py --dir ./project --exclude node_modules --exclude dist --exclude build
# 使用配置文件设置排除规则
# 编辑 config.yaml 文件创建或编辑 config.yaml 文件:
# 扫描设置
scan:
# 排除的目录
exclude:
- node_modules
- .git
- __pycache__
- venv
- dist
- build
# 输出设置
output:
format: terminal
export_dir: reports
show_charts: true
top_files_count: 10场景一:快速了解项目规模
刚接手一个新项目,想要快速了解代码量和主要技术栈:
python codepulse.py --dir ./new-project场景二:生成代码统计报告
在项目文档中需要展示代码统计信息:
python codepulse.py --dir ./src --format markdown --output stats.md场景三:持续集成中使用
在CI/CD流程中自动生成代码统计:
# .github/workflows/stats.yml
name: Code Statistics
on: [push, pull_request]
jobs:
stats:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Install dependencies
run: pip install -r codepulse/requirements.txt
- name: Generate statistics
run: python codepulse/codepulse.py --dir . --format json --output stats.json
- name: Upload stats
uses: actions/upload-artifact@v3
with:
name: code-stats
path: stats.json- 轻量化优先:零外部依赖,仅使用Python标准库
- 性能导向:优化文件扫描算法,实现秒级分析
- 用户体验:彩色终端输出,信息层次分明
- 可扩展性:模块化设计,便于功能扩展
- Python:跨平台、语法简洁、生态丰富
- Click:简洁优雅的命令行界面
- Colorama:跨平台终端彩色输出
- YAML:配置文件简洁易读
- HTML报告生成:生成可交互的网页报告
- 历史趋势对比:支持多版本代码统计对比
- 增量分析:支持增量扫描,分析代码变化
- Web界面:提供图形化界面操作
- VS Code插件:集成到IDE中实时显示统计
- 团队统计面板:支持多仓库聚合统计
- 提交新的编程语言检测规则
- 改进统计精度和性能
- 提供更多报告模板
- 完善测试用例覆盖
- 翻译多语言文档
# 作为命令行工具安装
pip install -e .
# 或直接使用
python codepulse.py --dir ./your-project# Dockerfile
FROM python:3.9-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
CMD ["python", "codepulse.py", "--dir", "."]# 构建镜像
docker build -t codepulse .
# 运行容器
docker run --rm -v $(pwd):/app codepulse python codepulse.py --dir /app我们使用 Angular 提交规范:
feat:新增功能fix:修复问题docs:文档更新style:代码格式调整refactor:代码重构test:测试相关chore:构建/依赖更新
- Fork 本仓库
- 创建特性分支:
git checkout -b feature/your-feature-name - 提交代码:
git commit -m "feat: 添加新功能" - 推送分支:
git push origin feature/your-feature-name - 创建 Pull Request
- 🔍 确保问题可复现
- 📝 提供详细的复现步骤
- 💻 包含环境信息(操作系统、Python版本等)
- 🐛 附上错误日志和截图(如有)
本项目采用 MIT 开源协议,您可以自由使用、修改和分发本项目。
CodePulse 是一款輕量級的程式碼統計視覺化工具,能夠快速分析程式碼庫的各項指標,包括檔案數量、行數統計、程式設計語言分布等,為開發者提供清晰的專案概況。
核心價值:
- ⚡ 快速分析:幾秒內完成整個程式碼庫的統計分析
- 📊 多語言支援:支援超過30種主流程式設計語言的智慧識別
- 📈 視覺化輸出:終端彩色輸出與ASCII圖表,清晰直觀
- 📤 多格式匯出:支援JSON、Markdown等多種報告格式
- 🎯 精確統計:區分程式碼行、註解行、空行,統計數據更準確
解決的使用者痛點:
- 手動統計程式碼量耗時費力,效率低下
- 難以快速了解新接手專案的程式碼規模和技術棧分布
- 團隊程式碼品質評估缺乏量化指標
- 需要生成程式碼統計報告時沒有便捷工具
自研差異化亮點:
- 🌟 零依賴設計:僅依賴Python標準庫,部署簡單
- 🎨 彩色終端輸出:高可讀性的彩色表格和圖表展示
- 📊 智慧分類:自動識別程式設計語言,支援自定義擴展
- 💾 輕量高效:純Python實現,無需額外執行環境
靈感來源:
- 開發者日常需要快速了解程式碼庫規模
- 專案交接時需要量化程式碼指標
- 程式碼審查和品質評估需要數據支撐
- 🚀 秒級分析:優化演算法實現快速程式碼庫掃描
- 💻 30+語言支援:Python、JavaScript、TypeScript、Java、Go、Rust等
- 📊 多維度統計:檔案數、程式碼行、註解行、空行全面覆蓋
- 🎯 智慧分類:自動識別程式設計語言及檔案類型
- 📈 視覺化圖表:終端ASCII圖表,直觀展示語言分布
- 📤 多格式匯出:JSON、Markdown格式報告一鍵生成
- ⚙️ 靈活配置:YAML配置文件自定義掃描規則
- 🎨 彩色輸出:高可讀性的彩色終端介面
- Python 3.7+
- pip 套件管理工具
# 克隆倉庫
git clone https://github.com/gitstq/codepulse.git
cd codepulse
# 安裝依賴
pip install -r requirements.txt
# 賦予執行權限
chmod +x codepulse.py# 分析目前目錄
python codepulse.py --dir .
# 分析指定目錄
python codepulse.py --dir /path/to/your/project
# 顯示幫助資訊
python codepulse.py --help# 分析目前目錄
python codepulse.py
# 分析指定目錄
python codepulse.py --dir ./src
# 分析並匯出JSON報告
python codepulse.py --dir ./src --format json --output report.json
# 分析並匯出Markdown報告
python codepulse.py --dir ./src --format markdown --output report.md# 排除多個目錄
python codepulse.py --dir ./project --exclude node_modules --exclude dist --exclude build
# 使用配置文件設置排除規則
# 編輯 config.yaml 檔案場景一:快速了解專案規模
剛接手一個新專案,想要快速了解程式碼量和主要技術棧:
python codepulse.py --dir ./new-project場景二:生成程式碼統計報告
在專案文檔中需要展示程式碼統計資訊:
python codepulse.py --dir ./src --format markdown --output stats.md場景三:持續整合中使用
在CI/CD流程中自動生成程式碼統計:
# .github/workflows/stats.yml
name: Code Statistics
on: [push, pull_request]
jobs:
stats:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Install dependencies
run: pip install -r codepulse/requirements.txt
- name: Generate statistics
run: python codepulse/codepulse.py --dir . --format json --output stats.json- 輕量化優先:零外部依賴,僅使用Python標準庫
- 效能導向:優化檔案掃描演算法,實現秒級分析
- 使用者體驗:彩色終端輸出,資訊層次分明
- 可擴展性:模組化設計,便於功能擴展
- HTML報告生成:生成可互動的網頁報告
- 歷史趨勢對比:支援多版本程式碼統計對比
- 增量分析:支援增量掃描,分析程式碼變化
- Web介面:提供圖形化介面操作
- VS Code插件:整合到IDE中即時顯示統計
- 團隊統計面板:支援多倉庫聚合統計
# 構建映像
docker build -t codepulse .
# 執行容器
docker run --rm -v $(pwd):/app codepulse python codepulse.py --dir /app我們使用 Angular 提交規範:
feat:新增功能fix:修復問題docs:文檔更新refactor:程式碼重構test:測試相關
本專案採用 MIT 開源協議,您可以自由使用、修改和分發本專案。
CodePulse is a lightweight code statistics visualization tool that quickly analyzes code repositories, providing metrics like file counts, line statistics, and programming language distribution for developers.
Core Value:
- ⚡ Fast Analysis: Complete repository statistics in seconds
- 📊 Multi-language Support: Smart detection for 30+ programming languages
- 📈 Visual Output: Colorful terminal display with ASCII charts
- 📤 Multi-format Export: JSON, Markdown and other report formats
- 🎯 Accurate Statistics: Distinguishes code, comments, and blank lines
User Pain Points Solved:
- Manual code counting is time-consuming and inefficient
- Difficult to quickly understand new project's code scale
- Lack of quantitative indicators for code quality assessment
- No convenient tools for generating code statistics reports
Self-developed Highlights:
- 🌟 Zero Dependencies: Uses only Python standard library
- 🎨 Colorful Terminal Output: Highly readable colored tables and charts
- 📊 Smart Classification: Auto-detects programming languages
- 💾 Lightweight & Efficient: Pure Python implementation
Inspiration:
- Developers need to quickly understand code repository scale
- Project handover requires quantified code metrics
- Code review and quality assessment need data support
- 🚀 Second-level Analysis: Optimized algorithm for fast scanning
- 💻 30+ Language Support: Python, JavaScript, TypeScript, Java, Go, Rust, etc.
- 📊 Multi-dimensional Stats: Files, code lines, comments, blank lines
- 🎯 Smart Classification: Auto-identifies programming languages
- 📈 ASCII Charts: Visual language distribution charts
- 📤 Multi-format Export: JSON, Markdown report generation
- ⚙️ Flexible Config: YAML configuration for custom rules
- 🎨 Colorful Output: High-readability terminal interface
- Python 3.7+
- pip package manager
# Clone repository
git clone https://github.com/gitstq/codepulse.git
cd codepulse
# Install dependencies
pip install -r requirements.txt
# Make executable
chmod +x codepulse.py# Analyze current directory
python codepulse.py --dir .
# Analyze specific directory
python codepulse.py --dir /path/to/project
# Export JSON report
python codepulse.py --dir ./src --format json --output report.json
# Export Markdown report
python codepulse.py --dir ./src --format markdown --output report.md# Exclude multiple directories
python codepulse.py --dir ./project --exclude node_modules --exclude dist --exclude buildEdit config.yaml to customize scanning rules:
scan:
exclude:
- node_modules
- .git
- __pycache__
- venv
- dist
- build
output:
format: terminal
export_dir: reports
show_charts: true
top_files_count: 10- Lightweight First: Zero external dependencies
- Performance Oriented: Optimized file scanning algorithms
- User Experience: Colorful terminal output with clear hierarchy
- Extensibility: Modular design for easy feature expansion
- HTML Report Generation: Interactive web reports
- Historical Comparison: Multi-version code statistics comparison
- Incremental Analysis: Incremental scanning for code changes
- Web Interface: Graphical user interface
- VS Code Extension: IDE integration
- Team Dashboard: Multi-repository aggregated statistics
We follow Angular commit specification:
feat:New featurefix:Bug fixdocs:Documentation updaterefactor:Code refactoringtest:Test relatedchore:Build/dependency update
- Fork this repository
- Create feature branch:
git checkout -b feature/your-feature-name - Commit:
git commit -m "feat: Add new feature" - Push:
git push origin feature/your-feature-name - Create Pull Request
This project is licensed under the MIT License, you are free to use, modify, and distribute this project.