AiBsCleaner

command module
v0.11.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 12, 2025 License: MIT Imports: 2 Imported by: 0

README ΒΆ

aiBsCleaner - Performance-Focused Static Analyzer for Go

Go Version License Test Coverage PRs Welcome

Performance analyzer that finds issues standard linters miss

aiBsCleaner - A high-performance static analyzer for Go that focuses on detecting performance bottlenecks, algorithmic complexity issues, and AI-generated anti-patterns.

🎯 What It Does

aiBsCleaner identifies performance issues that standard linters don't catch:

  • Algorithmic Complexity: O(nΒ²/nΒ³) loops, inefficient algorithms
  • Memory Issues: Memory leaks, goroutine leaks, GC pressure
  • Database Problems: N+1 queries, missing prepared statements
  • Concurrency Issues: Race conditions, deadlocks, channel misuse
  • AI-Generated Anti-patterns: Over-engineered solutions, unnecessary complexity
  • Resource Management: Unclosed resources, defer overhead

πŸš€ Quick Start

Installation
go install github.com/SergeiSkv/aiBsCleaner@latest
Basic Usage
# Analyze current directory
./aiBsCleaner .

# Analyze specific path
./aiBsCleaner ./src

# With configuration
./aiBsCleaner --config .aiBsCleaner.yaml .

# Enable cache for faster subsequent runs
./aiBsCleaner --enable-cache .

# JSON output for CI/CD
./aiBsCleaner --json .

πŸ“Š Current Status

  • 33 Specialized Analyzers covering performance, security, and code quality
  • Test Coverage: 66.8% (analyzer: 82.9%, cache: 56.9%)
  • Zero External Dependencies for core functionality
  • Fast: Processes large codebases efficiently with caching

πŸ” Analyzers

Performance Analyzers
  • Loop Analyzer: Detects nested loops, allocations in loops, O(nΒ²) complexity
  • Memory Leak Analyzer: Finds goroutine leaks, unclosed resources
  • GC Pressure Analyzer: Identifies excessive allocations
  • Defer Optimization: Analyzes defer overhead in hot paths
  • CPU Optimization: Cache-friendly struct layout suggestions
  • String Analyzer: String concatenation in loops, builder usage
Concurrency Analyzers
  • Race Condition Analyzer: Unsafe concurrent access patterns
  • Goroutine Analyzer: Goroutine leaks, unbounded goroutines
  • Channel Analyzer: Deadlocks, unbuffered channels in hot paths
  • Sync Pool Analyzer: sync.Pool usage optimization
Database & Network
  • Database Analyzer: N+1 queries, SQL in loops, connection leaks
  • HTTP Client Analyzer: Missing timeouts, connection reuse
  • HTTP Reuse Analyzer: Connection pooling optimization
  • Network Patterns: Efficient networking patterns
Code Quality
  • AI Bullshit Analyzer: Over-engineered solutions, unnecessary complexity
  • Interface Analyzer: Interface pollution, empty interfaces
  • Reflection Analyzer: Reflection misuse, performance impact
  • API Misuse Analyzer: Standard library misuse
Security & Best Practices
  • Crypto Analyzer: Weak crypto, insecure random
  • Privacy Analyzer: PII exposure, sensitive data logging
  • Context Analyzer: Context misuse, cancellation handling
  • Error Handling: Error checking, panic recovery

πŸ“ Configuration

Create .aiBsCleaner.yaml:

analyzers:
  loop:
    enabled: true
  defer_optimization:
    enabled: true
  memory_leak:
    enabled: true
  ai_bullshit:
    enabled: true

thresholds:
  max_loop_depth: 3
  max_complexity: 10
  max_function_length: 50

paths:
  exclude:
    - vendor/
    - testdata/
    - "*.pb.go"
    - "*_test.go"

output:
  format: text  # or: json, compact
  show_context: false

🎯 Example Output

Analyzing project...
Found 42 issues

HIGH SEVERITY (5)
────────────────────────────────────────
loop_analyzer.go:124  NESTED_LOOP_O_N3
  Triple nested loop detected: O(nΒ³) complexity
  Suggestion: Consider using hash map for O(n) lookup
  PVE-001

database.go:67  N_PLUS_ONE_QUERY
  Query in loop: SELECT * FROM users WHERE id = ?
  Suggestion: Use JOIN or batch loading
  PVE-130

MEDIUM SEVERITY (18)
────────────────────────────────────────
handler.go:45  ALLOC_IN_LOOP
  Allocation inside loop may cause GC pressure
  Suggestion: Preallocate slice with make()
  PVE-001

AI BULLSHIT DETECTED (12)
────────────────────────────────────────
utils.go:23  OVERENGINEERED_SIMPLE
  20 lines to check if number is even
  Suggestion: Just use: n%2 == 0
  PVE-201

πŸ› οΈ Development

Running Tests
# All tests
go test ./...

# With coverage
go test ./... -coverprofile=coverage.out
go tool cover -html=coverage.out

# Specific package
go test ./analyzer -v
Building
# Build binary
go build -o aiBsCleaner .

# Run linter
golangci-lint run ./...

# Run on self
./aiBsCleaner .

πŸ“ˆ Performance

  • Fast Analysis: Processes ~1000 files/second
  • Smart Caching: 10x faster on subsequent runs
  • Low Memory: <100MB for most projects
  • Parallel Processing: Utilizes multiple cores

πŸ—ΊοΈ Roadmap

Current Focus
  • βœ… 33 production-ready analyzers
  • βœ… Test coverage improvements (66.8%)
  • βœ… Dead code removal
  • βœ… Cache system with deadlock fixes
  • πŸ”„ Testing on popular Go libraries
  • πŸ”„ Documentation improvements
Future Plans
  • IDE integrations (VS Code, GoLand)
  • CI/CD examples and templates
  • More analyzers (crypto, serialization)
  • Auto-fix suggestions
  • HTML/SARIF report formats

🀝 Contributing

Contributions welcome! Areas of focus:

  1. New Analyzers: Add performance detectors
  2. Test Coverage: Improve from 66.8% to 85%+
  3. Documentation: Usage examples, best practices
  4. Bug Reports: Real-world testing feedback

πŸ“œ License

MIT License - see LICENSE file

πŸ™ Acknowledgments

  • Go team for excellent static analysis tools
  • Community for feedback and contributions
  • All developers fighting performance issues

πŸ“š Documentation


Find performance issues before they find production πŸ”

Documentation ΒΆ

The Go Gopher

There is no documentation for this package.

Directories ΒΆ

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL