Maintain and improve code quality using PHPInsights without decreasing quality thresholds...
make phpinsights returns errors)Maintain exceptional code quality standards using PHPInsights while preserving hexagonal architecture, DDD patterns, and CQRS design.
Success Criteria:
make phpinsights passes without errorsCRITICAL: These thresholds in phpinsights.php must NEVER be lowered:
'requirements' => [
'min-quality' => 100, // Code quality
'min-complexity' => 94, // Cyclomatic complexity
'min-architecture' => 100, // Architecture compliance
'min-style' => 100, // Coding style
],
Policy: If PHPInsights fails, fix the code - NEVER lower these thresholds.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ When PHPInsights fails, you MUST FIX THE CODE. โ
โ NEVER lower thresholds in phpinsights.php. โ
โ โ
โ โ FORBIDDEN: Changing config to pass checks โ
โ โ
REQUIRED: Refactoring code to meet standards โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
# Find top 20 most complex classes
make analyze-complexity
# Find top 10 classes
make analyze-complexity N=10
# Export as JSON for tracking
make analyze-complexity-json N=20 > complexity-report.json
Output shows:
See: reference/analysis-tools.md
make phpinsights
โ [COMPLEXITY] 93.5 pts (target: 94%)
โ Method `CustomerCommandHandler::handle` has cyclomatic complexity of 12
See: refactoring-strategies.md for proven patterns:
make phpinsights
Repeat until all scores meet thresholds.
Problem: Method has too many decision points (if/else/switch/loops)
Identify hotspots:
make analyze-complexity N=10
Solutions:
See: refactoring-strategies.md for DDD/CQRS-specific patterns
Problem: Layer dependencies violated (e.g., Domain depending on Infrastructure)
Solutions:
See: deptrac-fixer skill for fixing architectural violations
Problem: Code doesn't meet PSR-12 or Symfony coding standards
Solution:
# Auto-fix most style issues
make phpcsfixer
# Re-run PHPInsights to verify
make phpinsights
Problem: Lines exceed configured limit
Solutions:
See: reference/project-configuration.md
phpinsights.phpphpinsights-tests.phpmake phpinsights after refactoringmake analyze-complexity to find hotspotsmake ci before committing[CODE] 100.0 pts โ
Target: 100%
[COMPLEXITY] 94.0 pts โ
Target: 94%
[ARCHITECTURE] 100 pts โ
Target: 100%
[STYLE] 100.0 pts โ
Target: 100%
โ
CI checks successfully passed!
After refactoring:
make phpinsights passes without errorsmake deptrac passes)make all-tests)# Find complex classes
make analyze-complexity N=10
# Run PHPInsights
make phpinsights
# Find complex methods with PHPMD
make phpmd
# Auto-fix style issues
make phpcsfixer
# Validate architecture
make deptrac
# Run all tests
make all-tests
# Full CI check
make ci
For detailed patterns, strategies, and troubleshooting:
When facing multiple issues: