Expand description
§Sniffy
A blazingly fast, parallel source code analyzer for counting lines of code.
Sniffy provides accurate classification of source code lines into blank, comment, and code categories across 33+ programming languages. It also includes git history analysis capabilities for tracking code evolution over time.
§Features
- Accurate Line Classification: Distinguishes code, comments (single and multi-line), and blank lines
- 33+ Languages: JavaScript, TypeScript, Rust, Python, Go, Java, C/C++, and many more
- Parallel Processing: Utilizes all CPU cores for maximum performance
- Git History Analysis: Track code changes over time with daily/weekly aggregation
- Multiple Output Formats: Beautiful tables, JSON, or CSV
- Smart Filtering: Respects
.gitignoreand skips common build artifacts
§Quick Start
use sniffy::processor::FileProcessor;
use sniffy::stats::ProjectStats;
use sniffy::walker::DirectoryWalker;
use std::path::Path;
// Analyze a directory
let processor = FileProcessor::new();
let mut stats = ProjectStats::new();
let walker = DirectoryWalker::new(Path::new("."));
for file_path in walker.walk() {
if let Some((language, file_stats)) = processor.process_file(&file_path) {
stats.add_file_stats(&language, file_stats);
}
}
// Get totals
let (total_files, total_stats) = stats.total();
println!("Total files: {}", total_files);
println!("Lines of code: {}", total_stats.code);§Modules
classifier: Line classification engine for determining line typescli: Command-line interface definitions and argument parsingerror: Error types and handlinggit: Git repository analysis and history trackinglanguage: Language definitions and file extension detectionoutput: Output formatting (tables, JSON, CSV)processor: File processing and binary file detectionstats: Statistics data structures and aggregationwalker: Directory traversal with .gitignore support
§Examples
§Analyze a specific file
use sniffy::processor::FileProcessor;
use std::path::Path;
let processor = FileProcessor::new();
if let Some((language, stats)) = processor.process_file(Path::new("src/main.rs")) {
println!("Language: {}", language);
println!("Code lines: {}", stats.code);
println!("Comment lines: {}", stats.comment);
println!("Blank lines: {}", stats.blank);
}§Git history analysis
use sniffy::git::GitAnalyzer;
if let Ok(analyzer) = GitAnalyzer::new(".") {
if let Ok(history) = analyzer.analyze_history(None, None, false) {
println!("Total commits: {}", history.total_commits);
println!("Daily stats: {} days", history.daily.len());
}
}Modules§
- classifier
- Line classification engine.
- cli
- Command-line interface argument parsing.
- error
- Error types and handling.
- git
- Git repository analysis and history tracking.
- language
- Language definitions and detection.
- output
- Output formatting and display.
- processor
- File processing.
- stats
- Statistics data structures and aggregation.
- walker
- Directory walking and file discovery.