Skip to content

Code Quality Analyzers

5 analyzers maintaining clean, maintainable code following Laravel conventions and PSR standards.

Overview

Code Quality analyzers focus on maintaining high code standards, reducing complexity, improving readability, and ensuring code follows best practices. These analyzers help teams write consistent, maintainable code that's easier to understand and modify.

Key Analyzers

Complexity & Structure

Code Smells

Documentation & Naming

How They Work

Code Quality analyzers use:

  1. AST Parsing: Analyzes code structure to measure complexity and detect patterns
  2. Pattern Matching: Identifies code smells and anti-patterns
  3. Metrics Calculation: Computes complexity metrics (cyclomatic, cognitive)
  4. Convention Validation: Checks code against PSR standards and Laravel conventions

Severity Levels

SeverityDescriptionExamples
HighIssues that significantly impact maintainabilityExcessive complexity, very long methods, deep nesting
MediumIssues that reduce code qualityCode duplication, magic numbers, missing documentation
LowBest practice violationsTODO comments, naming inconsistencies

Running Code Quality Analyzers

Run All Code Quality Analyzers

bash
php artisan shield:analyze --category=code-quality

Run Specific Analyzer

bash
php artisan shield:analyze --analyzer=nesting-depth
php artisan shield:analyze --analyzer=method-length
php artisan shield:analyze --analyzer=missing-docblock

Run Multiple Analyzers

bash
php artisan shield:analyze --analyzer=nesting-depth,method-length

Best Practices

Development

  • Run code quality analyzers regularly during development
  • Set complexity thresholds appropriate for your team
  • Refactor complex code before it becomes unmaintainable

Code Reviews

  • Review code quality metrics in pull requests
  • Use complexity metrics to guide refactoring decisions
  • Ensure new code follows established patterns

Team Standards

  • Agree on complexity thresholds as a team
  • Document naming conventions and coding standards
  • Use code quality metrics to track improvement over time