π» Bullshitdetector
Blazing-fast static analysis tool for detecting magic numbers, hardcoded values, and code smells in Rust (and other languages).
π Features
- β‘ Instant Scanning - Pure regex-based detection, no ML overhead
- π― Magic Number Detection - Finds hardcoded thresholds, timeouts, and constants
- π¬ Golden Ratio Math - Confidence scoring using Ο (phi) = 1.618
- π MΓΆbius Topology - Advanced code structure analysis
- π PAD Valence Model - Emotional analysis of code patterns
- π§ Zero Config - Works out of the box
π¦ Installation
As a CLI tool:
As a library:
[]
= "0.1"
π― Quick Start
Scan for magic numbers:
Scan for code smells:
As a library:
use ;
let code = r#"
if confidence > 0.85 { // β οΈ Magic number!
do_something();
}
"#;
let config = default;
let alerts = scan_code?;
for alert in alerts
π What It Detects
| Pattern | Example | Severity |
|---|---|---|
| Magic Numbers | if x > 0.85 |
π΄ Critical |
| Hardcoded Timeouts | Duration::from_secs(30) |
π High |
| Arc/RwLock Abuse | Arc<RwLock<HashMap<...>>> |
π‘ Medium |
| Unwrap Abuse | .unwrap() chains |
π‘ Medium |
| Sleep Abuse | std::thread::sleep in async |
π‘ Medium |
π Example Output
π΄ CRITICAL: Hardcoded Threshold
File: src/pipeline/stages.rs:231
Code: if knot > 0.4
Suggestion: Move to PipelineConfig::knot_threshold
π‘ MEDIUM: Magic Number Assignment
File: src/detection.rs:145
Code: let base_top_p = 0.35;
Suggestion: Extract to constant or config
π οΈ Configuration
Create a .bullshitdetector.toml:
[]
= 0.618 # Golden ratio inverse
= 500
= true
[]
= ["**/test/**", "**/tests/**"]
= ["rs", "py", "js"]
π How It Works
- Regex Pattern Matching - Lightning-fast detection of common patterns
- AST Analysis - (Optional) Tree-sitter based deep inspection
- Golden Ratio Scoring - Confidence scoring using Ο = 1.618034...
- MΓΆbius Transforms - Non-orientable topology for code structure
- PAD Valence - Pleasure-Arousal-Dominance emotional model
π§ Advanced Usage
Custom Patterns:
use ;
let mut config = default;
config.enable_tree_sitter = false; // Regex only for speed
config.confidence_threshold = 0.7; // Adjust sensitivity
let alerts = scan_code?;
Shell Script Integration:
#!/bin/bash
# Pre-commit hook
| &&
π API Documentation
Full documentation available at docs.rs/bullshitdetector
π€ Contributing
Contributions welcome! The detector is designed to be extended with new patterns.
Adding Custom Patterns:
- Add to
BullshitTypeenum insrc/lib.rs - Implement detection in
src/detect.rs - Add test cases
- Submit PR!
π License
MIT License - Copyright (c) 2025 Jason Van Pham (ruffian-l on GitHub) @ The Niodoo Collaborative
π Credits
- Golden Ratio Math - Based on Ο = (1 + β5) / 2
- MΓΆbius Topology - Non-orientable surface theory
- PAD Model - Pleasure-Arousal-Dominance emotional valence
π Links
Who you gonna call? π» BULLSHITBUSTERS!