bullshitdetector

Crates.iobullshitdetector
lib.rsbullshitdetector
version0.1.0
created_at2025-11-17 23:28:34.589283+00
updated_at2025-11-17 23:28:34.589283+00
descriptionBlazing-fast pattern detector for magic numbers, hardcoded values, and code smells using regex and golden-ratio math
homepagehttps://github.com/Ruffian-L/niodoo-tcs
repositoryhttps://github.com/Ruffian-L/niodoo-tcs
max_upload_size
id1937671
size237,719
ruffian (Ruffian-L)

documentation

https://docs.rs/bullshitdetector

README

πŸ‘» Bullshitdetector

Blazing-fast static analysis tool for detecting magic numbers, hardcoded values, and code smells in Rust (and other languages).

Crates.io License: MIT

πŸš€ 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:

cargo install bullshitdetector

As a library:

[dependencies]
bullshitdetector = "0.1"

🎯 Quick Start

Scan for magic numbers:

bullshitdetector scan-magic ./src

Scan for code smells:

bullshitdetector scan ./src --output report.json

As a library:

use bullshitdetector::{DetectConfig, scan_code};

let code = r#"
    if confidence > 0.85 {  // ⚠️ Magic number!
        do_something();
    }
"#;

let config = DetectConfig::default();
let alerts = scan_code(code, &config)?;

for alert in alerts {
    println!("Found {} at line {}", alert.issue_type, alert.location.0);
}

πŸ” 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:

[detect]
confidence_threshold = 0.618  # Golden ratio inverse
max_snippet_length = 500
enable_regex_fallback = true

[scan]
exclude_patterns = ["**/test/**", "**/tests/**"]
include_extensions = ["rs", "py", "js"]

πŸŽ“ How It Works

  1. Regex Pattern Matching - Lightning-fast detection of common patterns
  2. AST Analysis - (Optional) Tree-sitter based deep inspection
  3. Golden Ratio Scoring - Confidence scoring using Ο† = 1.618034...
  4. MΓΆbius Transforms - Non-orientable topology for code structure
  5. PAD Valence - Pleasure-Arousal-Dominance emotional model

πŸ”§ Advanced Usage

Custom Patterns:

use bullshitdetector::{DetectConfig, BullshitType};

let mut config = DetectConfig::default();
config.enable_tree_sitter = false;  // Regex only for speed
config.confidence_threshold = 0.7;   // Adjust sensitivity

let alerts = scan_code(code, &config)?;

Shell Script Integration:

#!/bin/bash
# Pre-commit hook
./bullshitdetector scan-magic src | grep -q "CRITICAL" && exit 1

πŸ“š 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:

  1. Add to BullshitType enum in src/lib.rs
  2. Implement detection in src/detect.rs
  3. Add test cases
  4. 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!

Commit count: 0

cargo fmt