Crystal clear code insights
Lucent is a fast, extensible code metrics analyzer built in Rust. It helps you understand code quality, complexity, and maintainability across multiple programming languages.
- ๐ Fast - Rust-powered analysis for large codebases
- ๐ Multi-language - 21+ languages supported (Rust, Python, JS/TS, Go, Java, C/C++, C#, Ruby, PHP, Swift, Kotlin, Dart, Scala, Elixir, Haskell, Clojure, Lua, Shell, SQL)
- ๐ 70+ Metrics Catalog - Comprehensive roadmap from basic LOC to advanced SPACE metrics
- ๐ Beautiful Output - Rich colors, emojis, and ASCII charts in terminal, JSON, Markdown, and CSV exports
- ๐ Code Quality - Shannon entropy, code density, comment ratio & quality analysis, TODO/FIXME/HACK detection
- ๐ Code Smells - Automatic detection of long functions, long parameter lists, deep nesting, and magic numbers
- ๐ Maintainability Index - Microsoft MI formula with A-F letter grades for code maintainability assessment
- ๐ Visual Analytics - ASCII bar charts for complexity and nesting depth visualization
- ๐จ Multiple Outputs - Pretty terminal, JSON, Markdown, CSV, and interactive HTML reports with charts
- ๐ Interactive HTML Reports - Beautiful, self-contained reports with Chart.js visualizations, dark mode, and export capabilities
- โ๏ธ Configurable - Metric profiles and thresholds via
.lucent.toml - โก CI/CD Ready - GitHub Actions workflows for PR analysis, quality gates, and automated testing
Phase 1 Complete! โ - Core architecture implemented and working.
Current version: 0.1.0-alpha
- โ
File scanning with
.gitignoresupport - โ 21+ language detection
- โ Line counting (code, comments, blanks)
- โ Shannon entropy calculation
- โ Cyclomatic complexity
- โ Cognitive complexity (NEW!)
- โ Nesting depth detection
- โ Function counting & length metrics
- โ Comment quality analysis (NEW!)
- โ
Code smells detection (NEW!)
- Long functions (>50 lines)
- Long parameter lists (>5 params)
- Deep nesting (>4 levels)
- Magic numbers
- โ
Maintainability Index (NEW!)
- Microsoft MI formula (0-100 scale)
- Letter grades (A-F)
- Per-language and overall metrics
- โ TODO/FIXME/HACK detection
- โ Beautiful terminal output with colors & emojis
- โ ASCII complexity visualizations (NEW!)
- โ JSON export
- โ Markdown report generation (NEW!)
- โ CSV export (NEW!)
- โ
Interactive HTML Reports (NEW!)
- Chart.js visualizations
- Dark/light mode toggle
- Print/PDF export
- CSV export from browser
- Responsive design
- โ
Configuration System (NEW!)
.lucent.tomlfile support- Hierarchical config loading (project โ user โ defaults)
- Threshold customization for all metrics
- Ignore patterns (.lucentignore + .gitignore)
- Language-specific overrides
- Quality gates configuration
- โ
Snapshot & History Tracking (NEW!)
- Save snapshots with
lucent snapshot save - List all snapshots with
lucent snapshot list - Compare snapshots with trend analysis and quality score
- Git integration (commit hash, branch, author, dirty state)
- Automatic cleanup with retention policy
- JSON storage in
.lucent/history/
- Save snapshots with
- โ
Threshold Checking & Quality Gates (NEW!)
- Exit code enforcement for CI/CD pipelines
--max-complexity,--max-nesting,--min-maintainability--max-function-length,--max-code-smells,--max-todos--fail-on-warningflag to treat warnings as errors- Warning vs Error severity levels
- Per-language thresholds - Set different standards for each language
- โ
GitHub Actions workflows (NEW!)
- PR analysis with automated comments
- Quality gate enforcement
- Diff-mode for changed files only
- Multi-platform CI/CD pipeline
- โ
Git Hooks (NEW!)
lucent init --hooksto install pre-commit hooks- Automatic quality checks on staged files
- Prevent commits that fail quality gates
- Template-based hook generation
- โ
Quality Badges (NEW!)
lucent badgeto generate README badges- Shields.io URLs (zero infrastructure!)
- Markdown and SVG formats
- Show off your code quality
- โ
Plugin System (NEW!)
- Extensible architecture for custom analyzers
- Built-in regex plugin (default)
- Plugin API with priority-based selection
- Ready for tree-sitter integration
- See Plugin Developer Guide
- โ 65 tests passing (50 unit + 14 integration + 1 doc)
- Basic file traversal and language detection
- Lines of code counting (code, comments, blanks)
- Shannon entropy calculation
- Support for 13+ languages
- Beautiful terminal output
- TODO/FIXME/HACK tracking
- Cyclomatic complexity โ
- Nesting depth detection โ
- Function/method counting & length โ
- Comment quality analysis โ
- Git-based metrics (commit size, velocity, churn)
- GitHub Action for PR analysis (automated comments)
- Expanded language support (21+ languages) โ
- Cognitive complexity โ
- Code smell detection โ
- Long functions
- Long parameter lists
- Deep nesting
- Magic numbers
- Maintainability index โ
- Halstead metrics
- HTML reports โ
- Configuration system (
.lucent.toml) โ- Threshold customization
- Ignore patterns
- Language-specific overrides
- Quality gates configuration
- Snapshot & history tracking โ
- Save/load snapshots
- Compare snapshots
- Git integration
- Trend analysis
- Threshold checking & quality gates โ
- Exit code enforcement
- CLI threshold flags
- Warning vs Error severity
- Fail-on-warning mode
- SPACE metrics (DORA)
- Team Topologies indicators
- Plugin system (tree-sitter based)
- Interactive TUI mode
- Change coupling analysis
See ROADMAP.md for the complete catalog of 70+ metrics organized by phase, including:
- Traditional metrics (Cyclomatic, Cognitive, Halstead, Maintainability Index)
- Git-based metrics (Commit velocity, Code churn, Entropy delta, Hotspot analysis)
- SPACE metrics (Nicole Forsgren/DORA)
- Team Topologies indicators (Cognitive load, Module complexity)
- Security metrics (Secret patterns, Unsafe code detection)
- 6 metric profiles: minimal, standard, comprehensive, team_lead, security, performance
Tier 1: ๐ฆ Rust โข ๐ Python โข ๐ JavaScript โข ๐ TypeScript โข ๐น Go โข โ Java โข โ๏ธ C++ โข ๐ง C โข #๏ธโฃ C# โข ๐ Ruby โข ๐ PHP โข ๐ฆ Swift โข ๐ฏ Kotlin
Tier 2: ๐ฏ Dart โข ๐ด Scala โข ๐ง Elixir โข ฮป Haskell โข ๐ Clojure โข ๐ Lua โข ๐ Shell โข ๐๏ธ SQL
Tier 3: Zig, F#, Julia, OCaml, Nim, R, MATLAB, Perl, Objective-C
See LANGUAGES.md for details and ROADMAP.md for language expansion plans.
# Not yet published to crates.io
# For now, build from source:
git clone https://github.com/ibrahimcesar/lucent
cd lucent
cargo build --release
# Run from project directory
cargo run -- .
# Or install locally
cargo install --path .
lucent .# Initialize project (install git hooks)
lucent init
# Analyze current directory
lucent .
# Analyze specific path
lucent src/
# Output as JSON
lucent --format json
# Output as interactive HTML report
lucent --format html > report.html
# Output as Markdown
lucent --format markdown > report.md
# Output as CSV
lucent --format csv > metrics.csv
# Verbose output with per-file details
lucent --verbose --per-file
# Get help
lucent --helpInstall pre-commit hooks to run Lucent automatically before each commit:
# Install git pre-commit hook
lucent init --hooks
# Create configuration file
lucent init --config
# Your commits will now be checked for quality issues!The pre-commit hook will:
- โ Analyze all staged source files
- โ
Run quality gates based on your
.lucent.tomlconfiguration - โ
Block commits that fail quality checks (can bypass with
--no-verify)
Generate badges to show off your code quality in README:
# Generate markdown badge (default)
lucent badge
# Output: 
# Just the URL
lucent badge --type url
# Generate SVG file
lucent badge --type svg --output badge.svgBadge grades are based on Maintainability Index:
- A (90-100): Excellent maintainability
- B (80-89): Good maintainability
- C (70-79): Moderate maintainability
- D (60-69): Difficult to maintain
- F (0-59): Extremely difficult to maintain
# Quality gates (exit code 1 if thresholds violated)
lucent --max-complexity 10.0 --min-maintainability 70.0
# Combine multiple thresholds
lucent --max-complexity 15.0 --max-nesting 4.0 --max-todos 10
# Fail on warnings (treat warnings as errors)
lucent --max-function-length 50.0 --fail-on-warning
# Load thresholds from .lucent.toml configuration file
lucent # Auto-discovers .lucent.toml in current/parent directories
# Use custom config file
lucent --config-file path/to/my-config.toml
# CLI flags override config file settings
lucent --max-complexity 20.0 # Overrides value from .lucent.tomlCreate a .lucent.toml file in your project root to set default thresholds:
[thresholds]
max_cyclomatic_complexity = 15.0
max_nesting_depth = 4.0
min_maintainability_index = 65.0
max_function_length = 50
[quality_gates]
fail_on_complexity = true
fail_on_nesting = true
warn_only = false
# Per-language overrides
[languages.rust]
max_cyclomatic_complexity = 12.0
max_nesting_depth = 3.0See examples/lucent-thresholds.toml for a complete example.
### Example Output
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ ๐ Lucent Analysis Results โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ Summary Total Files: 9 Total Lines: 1342 Code Lines: 939 Comment Lines: 189 Avg Entropy: 4.68 Avg Complexity: 12.3 Avg Nesting: 4.2 Total Functions: 72 Avg Func Length: 14.1
๐ Code Markers TODOs: 3 FIXMEs: 1
๐ By Language
โญโโโโโโโโโโโฌโโโโโโโโฌโโโโโโโโฌโโโโโโโฌโโโโโโโโโโโฌโโโโโโโโโฌโโโโโโโโโโโโโฌโโโโโโโโโโฌโโโโโโโโโโฎ โ Language โ Files โ Lines โ Code โ Comments โ Blanks โ Complexity โ Nesting โ Entropy โ โโโโโโโโโโโโผโโโโโโโโผโโโโโโโโผโโโโโโโผโโโโโโโโโโโผโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโโโโโผโโโโโโโโโโค โ ๐ฆ Rust โ 9 โ 1342 โ 939 โ 189 โ 214 โ 12.3 โ 4.2 โ 4.68 โ โฐโโโโโโโโโโโดโโโโโโโโดโโโโโโโโดโโโโโโโดโโโโโโโโโโโดโโโโโโโโโฌโโโโโโโโโโโโโดโโโโโโโโโโดโโโโโโโโโโฏ
๐ก Insights
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
## ๐ค CI/CD Integration
Lucent comes with production-ready GitHub Actions workflows for automated code analysis.
### Quick Start
1. **Copy workflows to your repository**:
```bash
mkdir -p .github/workflows
cp .github/workflows/lucent-*.yml .github/workflows/
- Push and create a PR - Lucent will automatically analyze your code!
Analyzes entire codebase on every pull request:
- Posts detailed metrics as PR comment
- Enforces quality gate thresholds
- Generates markdown and JSON reports
Quality Gates (configurable):
- โ Fails if complexity > 20.0
- โ Fails if nesting depth > 5.0
โ ๏ธ Warns if comment quality < 30%
Analyzes only changed files for faster feedback:
- Focused analysis on your modifications
- Per-file metrics in PR comment
- Ideal for large codebases
Compares PR metrics with base branch:
- Tracks quality improvements/regressions
- Calculates metric deltas with percentages
- Provides quality score (0-100)
- Visual trend indicators (โ โก๏ธ โ)
- 90-day historical tracking
Comprehensive testing and building:
- Multi-platform (Linux, macOS, Windows)
- Automated testing and linting
- Code coverage reporting
- Release binary builds
## ๐ Lucent Code Analysis Report
### ๐ Summary
| Metric | Value |
|--------|-------|
| Total Files | 15 |
| Average Complexity | 8.2 |
| Quality Score | โ
PASS |
### ๐ Complexity Visualization
๐ฆ Rust 12.5 โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ Python 6.3 โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโEdit .github/workflows/lucent-pr-analysis.yml:
# Strict quality gates
COMPLEXITY_THRESHOLD=10.0
NESTING_THRESHOLD=3.0
COMMENT_QUALITY_THRESHOLD=0.5See .github/workflows/README.md for complete documentation.
-
๐ Maintainability Index Guide - NEW!
- Understand the MI formula and scoring
- Learn how to interpret A-F letter grades
- Fine-tune thresholds for your organization
- Practical strategies for improving your scores
- Real-world examples and case studies
-
- Deep dive into all metrics
- Shannon Entropy explained
- Complexity metrics guide
- Comment quality analysis
-
- Quality gate customization
- Threshold recommendations by project type
- CI/CD integration patterns
-
- Complete GitHub Actions documentation
- Workflow customization examples
- Quality gate configuration
Contributions are welcome! This project is in early stages, and we're building the foundation.
How to contribute:
- ๐ Report bugs or suggest features via Issues
- ๐ป Submit PRs for bug fixes or new features
- ๐ Improve documentation
- ๐ Create language plugins (once plugin system is ready)
MIT
Inspired by:
- tokei - Fast line counting
- scc - Complexity metrics
- tree-sitter - Universal parsing
- SonarQube - Comprehensive quality analysis
Status: ๐ง Pre-alpha - Core architecture in development
Star โญ this repo to follow development!