Warning
This tool is always under active development and is just a mash up of various tiny static analysis features tools that have been useful to me over the years. Use at your own risk!
A fast, parallel code analysis tool that provides comprehensive codebase metrics and tracks changes over time. Built for speed with parallel processing and designed for developers who need quick insights into code complexity, file size, git history, and development patterns.
- Lightning fast - Parallel processing with Rayon for instant results
- Comprehensive metrics - Lines, complexity, density, size, indentation depth
- Git integration - Churn analysis, ownership tracking, commit patterns
- Smart filtering - Regex patterns, thresholds, noise reduction
- Real-time monitoring - Watch mode for continuous analysis
- Clean output - Colored visualization with plain text option
# Clone and build
git clone https://github.com/drbh/mad-useful.git
cd mad-useful
cargo build --release
# Or install directly
cargo install --path .# Analyze current directory
madu
# Analyze specific directory with top 10 results
madu --top 10 src/
# Find complexity hotspots
madu --hotspots --top 5 src/
# Monitor changes in real-time
madu --watch 5 src/$ ./target/release/madu --helpA fast, parallel code analysis tool for understanding codebase metrics and changes over time
Usage: madu [OPTIONS] [PATH]
Arguments:
[PATH] Directory or file to analyze [env: MADU_PATH=] [default: .]
Options:
--include <INCLUDE> [FILTER] File filter - include files by glob pattern [env: MADU_INCLUDE=]
--exclude <EXCLUDE> [FILTER] File filter - exclude files by glob pattern [env: MADU_EXCLUDE=]
--no-noise [FILTER] File filter - exclude common noise files (configs, locks, generated) [env: MADU_NO_NOISE=]
-c, --complexity [ANALYSIS] Calculate cyclomatic complexity - control flow complexity score [env: MADU_COMPLEXITY=]
--density [ANALYSIS] Code density calculation - operator/keyword density score [env: MADU_DENSITY=]
--indent [ANALYSIS] Nesting depth analysis - maximum indentation level [env: MADU_INDENT=]
--chars [ANALYSIS] Character counting - non-whitespace character count [env: MADU_CHARS=]
--size [ANALYSIS] File size measurement - bytes with human-readable units [env: MADU_SIZE=]
--duplicates [ANALYSIS] Code duplication detection - duplication percentage [env: MADU_DUPLICATES=]
--emoji [ANALYSIS] Content analysis - emoji count and statistics [env: MADU_EMOJI=]
--churn [ANALYSIS] Git commit frequency analysis - number of commits in time period [env: MADU_CHURN=]
--hotspots [ANALYSIS] Risk assessment - complexity × churn score for refactoring priority [env: MADU_HOTSPOTS=]
--blame [ANALYSIS] Git attribution - show primary author name per file [env: MADU_BLAME=]
--age [ANALYSIS] File staleness analysis - days since last modification [env: MADU_AGE=]
--ownership [ANALYSIS] Code ownership analysis - primary author commit percentage [env: MADU_OWNERSHIP=]
--isolation [ANALYSIS] Commit isolation analysis - single-file commit percentage [env: MADU_ISOLATION=]
--rhythm [ANALYSIS] Development rhythm analysis - commit frequency variation score [env: MADU_RHYTHM=]
--days <DAYS> [DISPLAY] Time scope - number of days for git analysis window [env: MADU_DAYS=] [default: 90]
--author <AUTHOR> [FILTER] Content filter - filter results by git author name [env: MADU_AUTHOR=]
--top <TOP> [FILTER] Limit - show only top N results [env: MADU_TOP=]
--skip <SKIP> [FILTER] Limit - skip first N results [env: MADU_SKIP=]
--min-value <MIN_VALUE> [FILTER] Threshold - minimum value filter [env: MADU_MIN_VALUE=]
--threshold <THRESHOLD> [FILTER] Threshold - percentage-based filter (1-100%) [env: MADU_THRESHOLD=]
-s, --summary [MODIFIER] Aggregation - group results by file extension [env: MADU_SUMMARY=]
--dirs [MODIFIER] Aggregation - group results by directory [env: MADU_DIRS=]
--depth <DEPTH> [MODIFIER] Aggregation - limit directory depth for --dirs [env: MADU_DEPTH=]
--watch <WATCH> [DISPLAY] Interactive - real-time monitoring mode, refresh every N seconds [env: MADU_WATCH=]
--no-color [DISPLAY] Formatting - disable colored output for scripts/CI [env: MADU_NO_COLOR=true]
--max-lines <MAX_LINES> [DISPLAY] Color scaling - custom threshold for color scaling reference [env: MADU_MAX_LINES=]
-h, --help Print help
-V, --version Print version
$ ./target/release/madu src 441 src/analysis.rs
223 src/args.rs
29 src/display.rs
175 src/file_utils.rs
261 src/git.rs
370 src/main.rs
504 src/watch.rs
2003 total
Shows line count for each file. Numbers are color-coded: red = large files, green = small files.
$ ./target/release/madu --summary src 2003 rs (7 files)
2003 total
Groups results by file extension. Useful for understanding codebase composition.
$ ./target/release/madu --top 5 src 504 src/watch.rs
441 src/analysis.rs
370 src/main.rs
261 src/git.rs
223 src/args.rs
1799 total
Limits output to top N results. Essential for focusing on the most significant files.
$ ./target/release/madu --min-value 100 src 504 src/watch.rs
441 src/analysis.rs
370 src/main.rs
261 src/git.rs
223 src/args.rs
175 src/file_utils.rs
1974 total
Filters out small files. Helps identify substantial code files that need attention.
$ ./target/release/madu --complexity --top 5 src 3424 src/watch.rs
2780 src/main.rs
2152 src/analysis.rs
827 src/git.rs
785 src/file_utils.rs
9968 total complexity
Important
Measures code complexity using control flow analysis. Higher values indicate more complex, harder-to-test code that may need refactoring.
$ ./target/release/madu --density --threshold 75 src 41 src/git.rs
36 src/watch.rs
77 total density score
Important
Calculates code density based on operators, keywords, and nesting. Higher scores indicate dense, potentially hard-to-read code.
$ ./target/release/madu --size --min-value 1024 src 17435 src/watch.rs (17.0K)
12273 src/main.rs (12.0K)
11625 src/analysis.rs (11.4K)
8627 src/git.rs (8.4K)
5512 src/args.rs (5.4K)
4011 src/file_utils.rs (3.9K)
59483 total bytes
Important
Shows file sizes with human-readable units (K, M, G). Useful for identifying bloated files over 1KB.
$ ./target/release/madu --chars --top 10 src 10786 src/watch.rs
7739 src/analysis.rs
7633 src/main.rs
4967 src/git.rs
3707 src/args.rs
2661 src/file_utils.rs
574 src/display.rs
38067 total chars
Important
Counts actual code characters, excluding whitespace. More accurate than line count for measuring code volume.
$ ./target/release/madu --indent --threshold 80 src 8 src/git.rs (8↓)
6 src/analysis.rs (6↓)
6 src/watch.rs (6↓)
20 max indent depth
Important
Measures deepest nesting level. High values may indicate overly complex functions needing refactoring.
$ ./target/release/madu --duplicates --min-value 10 src 68 src/main.rs (68%)
45 src/watch.rs (45%)
113 avg duplication %
Important
Detects duplicate code sections. Higher percentages indicate repeated code that could be refactored into functions.
$ ./target/release/madu --emoji --include '*.md' --include '*.txt' 0 total emojis
Important
Analyzes content for emoji usage. Useful for documentation and communication files.
$ ./target/release/madu --churn --days 30 --top 10 src 1 src/main.rs
1 total changes
Important
Shows commit frequency in recent timeframe. High churn files change often and may need architectural review.
$ ./target/release/madu --age --threshold 90 src 0 avg age (days)
Important
Days since last modification. Helps identify stale code and recent activity patterns. Shows only oldest 10% of files.
$ ./target/release/madu --rhythm --min-value 5 src 0 avg rhythm score
Important
Commit frequency variation score. High values indicate irregular development patterns that may need attention.
$ ./target/release/madu --ownership --threshold 70 src 100 src/main.rs (100%)
100 avg ownership %
Important
Percentage of commits by primary author. Shows files with >70% single-author ownership (potential knowledge silos).
$ ./target/release/madu --blame --author 'john' src 0 total
Important
Shows primary author name per file, filtered by specific author. Useful for code review assignments.
$ ./target/release/madu --isolation --min-value 50 src 0 avg isolation %
Important
Percentage of single-file commits. High isolation suggests focused, atomic changes. Shows files with >50% isolated commits.
$ ./target/release/madu --hotspots --top 5 src 2780 src/main.rs
2780 total hotspot score
Important
Combines complexity and change frequency. High scores identify files that are both complex and frequently modified - prime refactoring candidates.
$ ./target/release/madu --dirs src 2003 src
2003 total dirs
Rolls up metrics by directory. Useful for understanding module sizes and identifying large subsystems.
$ ./target/release/madu --dirs --depth 1 src 2003 src
2003 total dirs
Controls aggregation depth. Prevents deeply nested structures from cluttering results.
$ ./target/release/madu --include '*.rs' --include '*.js' --complexity src 3424 src/watch.rs
2780 src/main.rs
2152 src/analysis.rs
827 src/git.rs
785 src/file_utils.rs
92 src/args.rs
50 src/display.rs
10110 total complexity
Important
Include only specific file patterns. Essential for language-specific analysis.
$ ./target/release/madu --exclude '*.lock' --exclude '*.toml' --exclude '*.json' --size src 17435 src/watch.rs (17.0K)
12273 src/main.rs (12.0K)
11625 src/analysis.rs (11.4K)
8627 src/git.rs (8.4K)
5512 src/args.rs (5.4K)
4011 src/file_utils.rs (3.9K)
814 src/display.rs (814B)
60297 total bytes
Important
Filters out noise files using glob patterns. Essential for focusing on actual source code.
$ ./target/release/madu --no-noise --complexity --top 10 src 3424 src/watch.rs
2780 src/main.rs
2152 src/analysis.rs
827 src/git.rs
785 src/file_utils.rs
92 src/args.rs
50 src/display.rs
10110 total complexity
Important
Automatically excludes configs, locks, generated files. Quick way to focus on source code.
$ ./target/release/madu --threshold 50 --complexity src 3424 src/watch.rs
2780 src/main.rs
2152 src/analysis.rs
8356 total complexity
Important
Shows only files above percentage threshold of maximum value. Filters out small/unimportant files automatically.
$ ./target/release/madu --min-value 200 --chars src 10786 src/watch.rs
7739 src/analysis.rs
7633 src/main.rs
4967 src/git.rs
3707 src/args.rs
2661 src/file_utils.rs
574 src/display.rs
38067 total chars
Important
Shows only files above absolute threshold. Useful for finding substantial files.
$ ./target/release/madu --top 10 --skip 3 --size src 8627 src/git.rs (8.4K)
5512 src/args.rs (5.4K)
4011 src/file_utils.rs (3.9K)
814 src/display.rs (814B)
18964 total bytes
Important
Shows top 10 results after skipping first 3. Useful when top files are known outliers.
$ ./target/release/madu --author 'jane' --churn --days 7 src 0 total changes
Important
Filter results by git author name. Shows recent changes by specific team member.
Monitor complexity changes
$ ./target/release/madu --watch 10 --complexity --top 5 srcImportant
Real-time monitoring refreshing every 10 seconds. Watch complexity metrics during active development. Press Ctrl+C to stop.
Track file size growth
$ ./target/release/madu --watch 30 --size --threshold 80 --include '*.rs' srcImportant
Monitor file size changes every 30 seconds. Useful for catching file bloat during development.
Watch git activity
$ ./target/release/madu --watch 60 --churn --days 1 --top 10 srcImportant
Track recent commit activity every minute. Ideal for team leads monitoring daily development patterns.
Note
Watch mode examples above show the command structure. In practice, watch mode runs continuously and updates the display in real-time.