Skip to content

Releases: Phauthentic/cognitive-code-analysis

1.10.0 - Custom Reporters & Architecture Improvements

14 Oct 20:13
ff4f2c5

Choose a tag to compare

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.

1.9.0 - Code Coverage Integration & Architecture Improvements

13 Oct 21:00
28d0dea

Choose a tag to compare

What's Changed

✨ New Features

  • Code Coverage Support for CognitiveMetrics Command by @floriankraemer in #57
    • Added comprehensive code coverage integration to the cognitive metrics analysis
    • Support for both Clover XML and Cobertura XML coverage formats
    • Enhanced metrics display with coverage information
    • New command-line options: --coverage-cobertura and --coverage-clover
    • Improved risk assessment by factoring in test coverage data

🏗️ Architecture Improvements

  • Refactoring Cyclomatic Complexity Calculation by @floriankraemer in #64

    • Extracted cyclomatic complexity logic into dedicated CyclomaticComplexityCalculator class
    • Improved separation of concerns and code maintainability
    • Enhanced testability with dedicated calculator interface
    • Better encapsulation of complexity calculation algorithms
  • Extracting Halstead Calculations from the Visitor by @floriankraemer in #63

    • Created dedicated HalsteadMetricsCalculator class for cleaner architecture
    • Separated calculation logic from AST visitor pattern
    • Improved code organization and reusability
    • Enhanced test coverage for Halstead metrics calculations

🔧 Code Quality & Standards

  • Adding PHPCS Slevomat Coding Standard Rules by @floriankraemer in #62
    • Integrated Slevomat Coding Standard for enhanced code quality
    • Added comprehensive PHPCS rules including:
      • Unused imports detection
      • Useless variable detection
      • Early exit enforcement
      • Yoda comparison disallowance
      • Useless documentation detection
    • Improved code consistency across the project

📚 Documentation & Community

  • Github contribution and issue configuration by @floriankraemer in #59
    • Added comprehensive CONTRIBUTING.md with detailed contribution guidelines
    • Created structured issue templates for better bug reporting
    • Enhanced project documentation and community guidelines
    • Improved developer onboarding experience

Changes

Full Changelog: 1.8.0...1.9.0

Release 1.8.0 - Markdown Export & Enhanced Reporting

06 Oct 11:08
72b54e8

Choose a tag to compare

What's Changed

✨ New Features

  • Markdown Export for Cognitive Metrics by @floriankraemer in #50

    • Added comprehensive Markdown export functionality for cognitive complexity analysis
    • Support for multiple configuration scenarios (all metrics, cyclomatic only, halstead only, minimal, threshold-based)
    • Enhanced report generation with detailed formatting and table structures
    • Comprehensive test coverage with approval tests for various output scenarios
  • Markdown Export for Churn Metrics by @floriankraemer in #52

    • Added Markdown export functionality for churn analysis reports
    • Support for both standard and coverage-weighted churn metrics
    • Enhanced report formatting with detailed tables and metrics breakdown
    • Integration with existing churn analysis workflow
  • Line Number Tracking Enhancement by @floriankraemer in #51

    • Added line number tracking to CognitiveMetrics for better code location identification
    • Enhanced AST visitor to capture and store line number information
    • Improved debugging and code navigation capabilities

🐛 Bug Fixes

  • Fix Exclude Files via Config by @floriankraemer in #54
    • Fixed exclusion pattern merging in source file scanning

Changes

Full Changelog: 1.7.0...1.8.0

Release 1.7.0 - Optional Code Coverage as Factor in Churn Analysis

02 Oct 11:30
5194050

Choose a tag to compare

What's Changed

Code Coverage Integration for Churn Analysis

🎯 Enhanced Churn Analysis

  • Risk-weighted churn calculation that factors in test coverage
  • Support for multiple coverage formats: Clover XML and Cobertura XML
  • Churn risk assessment based on coverage data
  • New command-line options for coverage integration:
    • --coverage-cobertura: Path to Cobertura XML coverage file
    • --coverage-clover: Path to Clover XML coverage file

📊 Advanced Churn Metrics

  • Standard Churn: churn = timesChanged × cognitiveScore
  • Risk Churn: riskChurn = timesChanged × cognitiveScore × (1 - coverage)
  • Coverage-weighted risk levels for better prioritization

📚 Documentation & Configuration

  • Updated churn documentation with coverage integration examples
  • Enhanced configuration options for coverage analysis
  • Improved command-line help with coverage-specific options

Full Changelog: 1.6.0...1.7.0

Release 1.6.0 - Multi-Path Analysis Support

30 Sep 20:08
63384f5

Choose a tag to compare

What's Changed

✨ New Features

  • Support for multiple file and folder paths by @floriankraemer in #48
    • Added ability to pass comma-separated list of paths to analyze specific files and folders
    • Enhanced command-line interface to accept multiple paths for targeted analysis
    • Improved efficiency by allowing analysis of only changed files or specific directories
    • Added comprehensive test coverage for various path combinations (files, directories, mixed)

🔧 Code Quality & Refactoring

  • Refactor metrics collection architecture for multi-path support
    • Introduced collectFromPaths() method in CognitiveMetricsCollector for handling multiple paths
    • Added getCognitiveMetricsFromPaths() method in MetricsFacade for streamlined multi-path processing
    • Enhanced path parsing logic with robust trimming and filtering of empty paths
    • Improved code maintainability with better separation of concerns

🧪 Testing & Quality Assurance

  • Comprehensive test coverage for multi-path functionality
    • Added unit tests for collectFromPaths() method with various path combinations
    • Implemented data provider tests for command-line interface with multiple paths
    • Added test scenarios for mixed file and directory paths
    • Enhanced test coverage for edge cases including spaces and empty paths

Full Changelog: 1.5.0...1.6.0

1.5.0 - Performance Improvements & more!

24 Sep 20:46
11597c3

Choose a tag to compare

What's Changed

🐛 Bug Fixes

  • Fix analysis breaking for anonymous classes by @floriankraemer in #44
    • Improved error handling for anonymous classes during AST parsing
    • Added comprehensive test coverage for anonymous class scenarios

🎨 User Experience Improvements

  • Hide cognitive metric details in console output by @floriankraemer in #43
    • Added showDetailedCognitiveMetrics configuration option to control detailed metric display
    • Improved console output readability by making detailed metrics optional

⚡ Performance Enhancements

  • Significantly increase analysis performance by @floriankraemer in #46
    • Introduced CombinedMetricsVisitor to process all metrics in a single AST traversal
    • Eliminated multiple AST parsing passes, reducing analysis time substantially
    • Optimized visitor pattern implementation across all metric collectors

🧪 Testing & Quality Assurance

  • Add comprehensive approval tests for console output by @floriankraemer in #47

    • Implemented approval testing framework to detect unintended changes in console output
    • Added test fixtures for various configuration scenarios
    • Improved file collection and sorting consistency across platforms
  • Add PHPBench performance benchmarking by @floriankraemer in #45

    • Integrated PHPBench for continuous performance monitoring
    • Added comprehensive benchmarks for different code complexity scenarios
    • Established baseline performance metrics for future optimization

🔧 Code Quality & Refactoring

  • Refactor cognitive metrics handling and parser architecture
    • Simplified cyclomatic complexity instantiation and data handling
    • Enhanced type safety with improved type hints
    • Removed unused methods and improved code maintainability
    • Better separation of concerns in metrics collection

Full Changelog: 1.4.0...1.5.0


Key Highlights

  • Major performance improvement through single-pass AST traversal
  • Enhanced configurability with new output display options
  • Robust testing with approval tests and performance benchmarks
  • Better error handling for edge cases like anonymous classes
  • Improved code quality through refactoring and type safety enhancements

This release represents a significant step forward in both performance and reliability, making the tool more efficient and easier to configure for different use cases.

Added Sorting & Filtering

08 Sep 19:35
0f04916

Choose a tag to compare

What's Changed

New Features Added

  • Sorting functionality with command-line options --sort-by and --sort-order
  • 13 sortable fields: score, halstead, cyclomatic, class, method, lineCount, argCount, returnCount, variableCount, propertyCallCount, ifCount, ifNestingLevel, elseCount
  • Sort orders: ascending (asc) and descending (desc) with asc as default
  • Grouping by class via new groupByClass configuration option (default: true)
  • Enhanced filtering with better handling of ignored items and method filtering

Configuration Changes

  • Added groupByClass: true option to config.yml
  • Updated ConfigFactory and ConfigLoader to support the new option
    Enhanced CognitiveConfig class with groupByClass property

Documentation Updates

Full Changelog: 1.3.0...1.4.0

Example

To generate the output below these settings were used in the config.yaml and this command executed bin/phpcca analyse ./src --sort-by=score --sort-order=desc

cognitive:
  showOnlyMethodsExceedingThreshold: true
  groupByClass: false
image

1.3.0

17 Jul 18:19
14efd09

Choose a tag to compare

What's Changed

Full Changelog: 1.2.4...1.3.0

1.2.4

09 Jul 11:44
7d625f2

Choose a tag to compare

What's Changed

  • Made the threshold in the renderer use the configuration value. by @floriankraemer in #33

Full Changelog: 1.2.3...1.2.4

1.2.3

04 Jul 14:37
1181775

Choose a tag to compare

What's Changed

Full Changelog: 1.2.2...1.2.3