HowMany
A fast, intelligent code analysis tool for counting lines of code and analyzing project statistics.
Overview
HowMany is a command-line tool that analyzes codebases to provide comprehensive statistics about files, lines of code, complexity, and development time estimates. It automatically detects user-created code files while filtering out dependencies, build artifacts, and generated files.
Features
- Line Counting: Accurate counting of code lines, comments, documentation, and blank lines
- Language Detection: Supports 40+ programming languages and file types
- Complexity Analysis: Calculates cyclomatic complexity, function counts, and maintainability metrics
- Time Estimates: Provides development time estimates based on code volume
- Quality Metrics: Evaluates code health, documentation coverage, and maintainability
- Multiple Output Formats: Text, JSON, CSV, and HTML reports
- Interactive Mode: Terminal-based interface with charts and navigation
- Parallel Processing: Fast analysis using multi-threading
- Smart Filtering: Automatically excludes dependencies, build artifacts, and generated files
Installation
From crates.io (Recommended)
From Source
Using the Build Script
This will build the project and create a symlink in /usr/local/bin/howmany for system-wide access.
Usage
Basic Usage
# Analyze current directory (interactive mode by default)
# Analyze specific directory
# Non-interactive text output
# Show individual file statistics
# Verbose output with detailed breakdown
Output Formats
# Generate HTML report
# Export to JSON
# Export to CSV
# Plain text output
Filtering Options
# Analyze only specific file extensions
# Set maximum directory depth
# Include hidden files
# Add custom ignore patterns
# List files that would be analyzed
Sorting and Display
# Sort by different criteria
Supported Languages
HowMany automatically detects and analyzes these languages:
Programming Languages:
- Rust, Python, JavaScript, TypeScript, Java, C/C++, C#, Go, Swift, Kotlin
- Ruby, PHP, Scala, Clojure, Haskell, Erlang, Elixir, Julia, Dart, Lua
- Perl, R, MATLAB, Zig
Web Technologies:
- HTML, CSS, SCSS, Sass, Less, Vue, Svelte
Configuration & Markup:
- JSON, XML, YAML, TOML, Markdown, reStructuredText
Scripts:
- Shell scripts (bash, zsh, fish), PowerShell, Batch files
Output Examples
Text Output
=== Code Statistics ===
Total files: 45
Total lines: 12,847
Code lines: 9,234
Comment lines: 1,456
Documentation lines: 892
Blank lines: 1,265
Total size: 445,678 bytes (435.2 KB)
=== Complexity Analysis ===
Functions: 234
Average complexity: 3.2
Max nesting depth: 4
=== Time Estimates ===
Total development time: 2 days, 4 hours
Code writing time: 1 day, 8 hours
Documentation time: 4 hours
HTML Report Features
- Interactive charts and visualizations
- Language distribution analysis
- Complexity metrics with color coding
- Quality scores and recommendations
- Detailed file-by-file breakdown
- Responsive design for mobile viewing
Command Line Options
| Option | Short | Description |
|---|---|---|
--output |
-o |
Output format (text, json, csv, html) |
--files |
-f |
Show individual file statistics |
--verbose |
-v |
Show detailed breakdown by extension |
--no-interactive |
Disable interactive mode | |
--depth |
-d |
Maximum directory depth to traverse |
--ext |
-e |
Only count specific extensions (comma-separated) |
--hidden |
Include hidden files and directories | |
--sort |
-s |
Sort by: files, lines, code, comments, size |
--desc |
Sort in descending order | |
--ignore |
Additional ignore patterns (comma-separated) | |
--list |
-l |
List files that would be counted |
Interactive Mode
The default interactive mode provides:
- Overview Tab: Summary statistics with charts
- Languages Tab: Breakdown by programming language
- Export Tab: Export results to various formats
- Search: Find files by name, extension, or content
- Help: Built-in help system
Navigation
Tab/Shift+Tab: Switch between tabs1,2,3: Jump to specific tabs↑/↓orj/k: Navigate lists/ors: Toggle search modehorF1: Show helpqorEsc: Quit
Smart File Detection
HowMany automatically excludes:
- Dependencies: node_modules, target, pycache, site-packages
- Build Artifacts: *.o, *.class, *.pyc, build/, dist/
- Version Control: .git/, .svn/, .hg/
- IDE Files: .vscode/, .idea/, .DS_Store
- Temporary Files: *.tmp, *.log, cache/
Performance
- Parallel Processing: Uses all available CPU cores
- Smart Caching: Caches results for faster subsequent runs
- Memory Efficient: Processes files in chunks to minimize memory usage
- Fast Analysis: Typically analyzes 10,000+ files in under 5 seconds
Configuration
HowMany supports configuration files for custom settings:
Location: ~/.config/howmany/config.toml
[]
= "interactive"
= true
= true
[]
= true
= 100
[]
= ["*.tmp", "*.log", "node_modules/"]
Examples
Analyze a Rust Project
Generate HTML Report for Web Project
Quick JSON Export
Analyze Only Documentation
License
MIT License. See LICENSE for details.
Contributing
Contributions are welcome! Please feel free to submit pull requests or open issues.
Version
Current version: 0.3.1