Skip to content

1.10.0 - Custom Reporters & Architecture Improvements

Choose a tag to compare

@github-actions github-actions released this 14 Oct 20:13
· 15 commits to master since this release
ff4f2c5

What's Changed

✨ New Features

  • Custom Reporters Support by @floriankraemer in #61
    • Added comprehensive extensibility framework for creating custom reporters
    • Support for both cognitive metrics and churn metrics reporters
    • New ReporterRegistry class for managing and loading custom reporters
    • Configuration support via config.yml for registering custom reporters
    • Automatic detection of constructor requirements (with or without CognitiveConfig)
    • Support for both autoloaded classes and file-based reporters
    • Comprehensive documentation in docs/Creating-Custom-Reporters.md

🏗️ Architecture Improvements

  • Terminology Refactoring: Exporters → Reports by @floriankraemer in #61

    • Renamed all "Exporter" classes to "Report" for better semantic clarity
    • Migrated Business/Churn/Exporter/Business/Churn/Report/
    • Migrated Business/Cognitive/Exporter/Business/Cognitive/Report/
    • Updated interface names: DataExporterInterfaceReportGeneratorInterface
    • Improved naming consistency across the codebase
  • Enhanced Factory Pattern Implementation by @floriankraemer in #61

    • Introduced ChurnReportFactory and ChurnReportFactoryInterface
    • Introduced CognitiveReportFactory and CognitiveReportFactoryInterface
    • Removed legacy ChurnExporterFactory and CognitiveExporterFactory
    • Better separation of concerns with dedicated factory interfaces
    • Support for dynamic reporter registration and instantiation
  • Specification Pattern for Command Validation by @floriankraemer in #61

    • Implemented comprehensive validation using Specification Pattern
    • New command context classes: ChurnCommandContext, CognitiveMetricsCommandContext
    • Composite specifications for complex validation logic:
      • CompositeChurnSpecification
      • CompositeCognitiveMetricsValidationSpecification
    • Individual specification classes for focused validation:
      • CoverageFileExists
      • CoverageFormatSupported
      • CoverageFormatExclusivity
      • CustomExporterValidation
      • SortFieldValid
      • SortOrderValid
      • ReportOptionsComplete
    • Validation specification factories for both commands
    • Improved error messages and validation feedback
  • Command Handler Refactoring by @floriankraemer in #61

    • Introduced dedicated handler classes for better separation of concerns
    • New handlers for cognitive analysis:
      • BaselineHandler - Handles baseline comparison logic
      • ConfigurationLoadHandler - Manages configuration loading
      • CoverageLoadHandler - Handles coverage data loading
      • SortingHandler - Manages metrics sorting
    • Enhanced ChurnReportHandler and CognitiveMetricsReportHandler
    • Simplified command classes by delegating to specialized handlers
  • Enhanced Data Models by @floriankraemer in #61

    • Introduced ChurnMetrics class for better data encapsulation
    • Introduced ChurnMetricsCollection for collection management
    • New OperationResult class for standardized command results
    • Improved type safety and data structure consistency
  • Code Organization Improvements by @floriankraemer in #61

    • Moved DirectoryScanner to Business/Utility/ namespace
    • Moved CoverageDataDetector to Business/Utility/ namespace
    • Better logical grouping of utility classes
    • Improved namespace structure

🧪 Testing & Quality Assurance

  • Comprehensive Test Coverage by @floriankraemer in #61
    • Added 1,000+ lines of new test coverage
    • New test fixtures for custom reporters:
      • ConfigAwareChurnTextReporter
      • ConfigAwareTextReporter
      • CustomChurnTextReporter
      • CustomTextReporter
    • Comprehensive tests for specification pattern:
      • ChurnSpecificationPatternTest
      • CognitiveMetricsSpecificationPatternTest
    • Factory pattern tests:
      • ChurnReporterFactoryCustomTest
      • CognitiveReporterFactoryCustomTest
    • Configuration tests:
      • CustomExportersConfigTest
    • Command tests:
      • Enhanced ChurnCommandTest
      • Enhanced CognitiveMetricsCommandTest
    • Reporter registry tests:
      • ExporterRegistryTest
    • Custom reporter integration tests:
      • MetricsFacadeCustomExportersTest

📚 Documentation

  • Creating Custom Reporters Guide by @floriankraemer in #61
    • Comprehensive 287-line documentation for custom reporter development
    • Detailed examples for both cognitive and churn reporters
    • Configuration guidelines and best practices
    • Constructor pattern explanations
    • Troubleshooting section
    • Built-in reporter reference

🔧 Configuration Enhancements

  • Custom Reporters Configuration by @floriankraemer in #61
    • Added customReporters section to config.yml
    • Support for cognitive and churn reporter registration
    • Flexible configuration with optional file paths
    • Example configuration in default config file

Changes

Full Changelog: 1.9.0...1.10.0

Key Highlights

  • Major Extensibility Enhancement: The custom reporters feature allows developers to create their own output formats without modifying the core codebase
  • Improved Architecture: Comprehensive refactoring with better separation of concerns, specification pattern validation, and enhanced factory patterns
  • Better Code Organization: Terminology improvements (Exporters → Reports) and logical namespace restructuring
  • Robust Testing: Over 1,000 lines of new test coverage ensuring reliability of the new features
  • Developer-Friendly: Comprehensive documentation and examples make it easy to create custom reporters

Migration Guide

If you're upgrading from 1.9.0, please note:

  1. No Breaking Changes: All existing functionality remains compatible
  2. Optional Feature: Custom reporters are entirely optional - existing workflows continue to work unchanged
  3. Configuration: If you want to use custom reporters, add the customReporters section to your config.yml (see documentation)
  4. Internal API Changes: If you've extended the codebase, note that "Exporter" classes have been renamed to "Report" classes

Example Usage

Using Built-in Reports (Unchanged)

# Cognitive metrics
bin/phpcca analyse ./src --format=json --output=report.json

# Churn metrics
bin/phpcca churn ./src --format=html --output=churn.html

Using Custom Reporters (New)

# config.yml
cognitive:
  customReporters:
    cognitive:
      pdf:
        class: 'My\Custom\PdfReporter'
        file: '/path/to/PdfReporter.php'
bin/phpcca analyse ./src --format=pdf --output=report.pdf

See docs/Creating-Custom-Reporters.md for complete documentation.