fractalizer / ai-mess-detector
CLI tool for static analysis of PHP code - detects architectural mess and complexity issues
v0.2.2
2026-03-05 20:07 UTC
Requires
- php: ^8.4
- amphp/parallel: ^2.0
- nikic/php-parser: ^5.0
- psr/log: ^3.0
- symfony/config: ^7.4 || ^8.0
- symfony/console: ^7.4 || ^8.0
- symfony/dependency-injection: ^7.4 || ^8.0
- symfony/finder: ^7.4 || ^8.0
- symfony/yaml: ^7.4 || ^8.0
Requires (Dev)
- deptrac/deptrac: ^2.0
- friendsofphp/php-cs-fixer: ^3.0
- phpstan/phpstan: ^2.0
- phpunit/phpunit: ^12.0
Suggests
- ext-igbinary: For faster serialization in parallel processing
- ext-parallel: For true parallel processing with threads (alternative to ext-pcntl)
- ext-pcntl: Required for parallel processing on Unix (alternative to ext-parallel)
README
Static analysis tool for PHP code quality metrics.
Features
- Complexity Metrics: Cyclomatic (CCN), Cognitive, NPATH
- Maintainability: Halstead metrics, Maintainability Index
- Coupling: RFC, Instability, Abstractness, Distance from Main Sequence
- Cohesion: TCC/LCC, LCOM4, WMC
- Size: LOC, Class/Method/Property Count
- Structure: DIT, NOC
- Architecture: Circular Dependency Detection
Quick Start
# Install composer require --dev fractalizer/ai-mess-detector # Analyze bin/aimd analyze src/ # With specific format bin/aimd analyze src/ --format=json # Pre-commit hook bin/aimd hook:install
Output Formats
| Format | Use Case |
|---|---|
text |
CLI, human-readable |
json |
CI/CD integration |
checkstyle |
Jenkins, SonarQube |
sarif |
GitHub Security, VS Code |
gitlab |
GitLab Code Quality |
Configuration
Create aimd.yaml:
rules: complexity: warning_threshold: 10 error_threshold: 20 cognitive: warning_threshold: 15 error_threshold: 30
Or use CLI options:
bin/aimd analyze src/ --cc-warning=10 --cc-error=20
Git Integration
# Analyze staged files only bin/aimd analyze src/ --staged # Show violations in changed files bin/aimd analyze src/ --diff=main
Baseline Support
# Generate baseline for existing violations bin/aimd analyze src/ --generate-baseline=baseline.json # Use baseline bin/aimd analyze src/ --baseline=baseline.json
Documentation
Requirements
- PHP 8.4+
- Composer
Development
composer install composer test # Run tests composer phpstan # Static analysis composer check # Full validation
License
MIT