Releases: Phauthentic/cognitive-code-analysis
Release 1.11.1
1.11.1 - GitHub Action, CI Docs & Configuration Refinements
What's Changed
✨ New Features
-
GitHub Action for Pull Request Analysis by @floriankraemer in #72
- Added a composite GitHub Action in a dedicated repository: cognitive-code-analysis-github-action
- Install via PHAR download or existing Composer binary (
install-mode: phar|composer) - Analyses changed
.phpfiles on pull requests (comma-separated path support) - Configurable PR comments, workflow annotations, artifacts, SARIF upload, and optional threshold failure
- Example workflow added to this repository:
.github/workflows/cognitive-code-analysis.yaml - Use
Phauthentic/cognitive-code-analysis-github-action@v1in consumer projects
-
Runtime Configuration Feedback by @floriankraemer in #72
analyseandchurnnow print the active config source and cache status at startup- Example console output:
Config: ./phpcca.yaml Cache: enabled - New
RuntimeStatusRendererclass used by both Cognitive and Churn configuration pipeline stages - Relative paths are shown when the config file is inside the working directory
-
CI Integration Guide by @floriankraemer in #72
- New
docs/CI-Integration.mdwith end-to-end CI setup documentation - GitHub Actions workflow examples (Markdown PR comments, SARIF upload, artifacts)
- GitLab CI workflow examples (merge request notes, Code Quality widget)
- Correct comma-separated path usage for analysing multiple changed files in one invocation
- Linked from
readme.md
- New
🔧 Configuration Enhancements
-
Standardized Config Filename:
phpcca.yamlby @floriankraemer in #72- Renamed bundled project config from
config.ymltophpcca.yaml bin/phpcca initnow createsphpcca.yamlin the current directory (wascca.yamlin 1.11.0)- Auto-discovery updated:
analyseandchurnload./phpcca.yamlwhen present - Explicit
--configalways takes precedence over auto-discovery - PHAR bundle (
box.json.dist),ConfigService, andConfigInitializerupdated to referencephpcca.yaml
- Renamed bundled project config from
-
Focused Default Output by @floriankraemer in #72
- Bundled
phpcca.yamlsetsshowOnlyMethodsExceedingThreshold: trueby default - Console and Markdown output focus on methods exceeding
scoreThreshold - Reduces noise in local runs and CI reports when using the default configuration
- Bundled
🏗️ Architecture Improvements
-
Configuration Pipeline Refactoring by @floriankraemer in #72
- Simplified
ConfigurationStagein both Cognitive and Churn pipelines - Centralized runtime status rendering via
RuntimeStatusRenderer - Clearer error handling when configuration loading fails
- Simplified
🧪 Testing & Quality Assurance
-
Updated Golden-File Tests by @floriankraemer in #72
- Console output fixtures updated to include
Config:andCache:status lines CognitiveMetricsCommandCoverageTestuses an explicit test config to avoid coupling to bundled defaults- Added
RuntimeStatusRendererTestfor built-in config, relative path, and absolute path formatting - Updated
InitCommandTestandConfigInitializerTestforphpcca.yamlnaming
- Console output fixtures updated to include
📚 Documentation
-
Configuration & README Updates by @floriankraemer in #72
docs/Configuration.mdupdated forphpcca.yamlnaming and auto-discoveryreadme.mdupdated withinitworkflow andphpcca.yamlreferencesdocs/CI-Integration.mddocuments GitHub Action usage alongside manual workflow snippets
Changes
- Adding Analysis Action and Fixes to the Configuration by @floriankraemer in #72
Full Changelog: 1.11.0...1.11.1
Key Highlights
- One-Line CI Setup: The new GitHub Action lets teams add cognitive complexity checks to pull requests without writing shell scripts
- Clearer Runtime Feedback: Config source and cache status are visible at the start of every
analyseandchurnrun - Consistent Config Naming:
phpcca.yamlis now the single recommended filename for project configuration, init output, and auto-discovery - Less Noisy Defaults: Threshold filtering is enabled in the bundled config so reports highlight methods that actually need attention
- CI Documentation: A dedicated integration guide covers GitHub Actions, GitLab CI, report formats, and changed-file analysis
Migration Guide
If you're upgrading from 1.11.0, please note:
- Rename Your Config File: If you use
cca.yamlorconfig.yml, rename it tophpcca.yaml(or keep your filename and pass--configexplicitly) - Init Output Changed:
bin/phpcca initnow createsphpcca.yamlinstead ofcca.yaml - Auto-Discovery Updated:
analyseandchurnlook for./phpcca.yamlin the working directory when--configis omitted - Default Filtering: The bundled config enables
showOnlyMethodsExceedingThreshold: true— set it tofalsein yourphpcca.yamlif you want all methods listed - GitHub Action Available: For PR workflows, consider cognitive-code-analysis-github-action@v1 instead of maintaining a custom workflow
- No Breaking CLI Changes: All existing commands, report types, and
--configbehaviour remain compatible
Example Usage
Project Setup
bin/phpcca init # interactive setup → creates phpcca.yaml
bin/phpcca init --silent # non-interactive, all defaults
bin/phpcca init --path=./phpcca.yamlAnalyse with Auto-Discovered Config
bin/phpcca analyse src/ # auto-loads ./phpcca.yaml when present
bin/phpcca analyse src/ --config=custom.yaml # explicit config overrides auto-discoveryGitHub Action (New)
# .github/workflows/cognitive-code-analysis.yaml
name: Cognitive Code Analysis
on:
pull_request:
paths:
- '**/*.php'
permissions:
pull-requests: write
contents: read
jobs:
analyse:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: Phauthentic/cognitive-code-analysis-github-action@v1
with:
install-mode: phar
post-comment: true
upload-artifact: true
emit-annotations: trueAnalyse Multiple Changed Files in CI
CHANGED_FILES=$(git diff --name-only --diff-filter=ACMR $BASE_SHA...$HEAD_SHA | grep '\.php$' | tr '\n' ' ')
ANALYSE_PATH=$(echo "$CHANGED_FILES" | tr ' ' ',')
bin/phpcca analyse "$ANALYSE_PATH" --report-type=markdown --report-file=cca-report.mdSee docs/CI-Integration.md and docs/Configuration.md for complete documentation.
Contributors
Release 1.11.0
1.11.0 - CI Integration, Project Setup & Baseline Tracking
What's Changed
✨ New Features
- Init Command &
cca.yamlAuto-Discovery by @floriankraemer in #70- Added
bin/phpcca initto scaffold a project configuration file - Interactive mode prompts for key settings with explanatory text before each question
--silentflag skips prompts and uses schema defaults--path/-pto specify the target file (default:./cca.yamlin the current directory)--force/-fto overwrite an existing config file- Automatic config discovery:
analyseandchurnload./cca.yamlwhen present - Explicit
--configalways takes precedence over auto-discovery - New
InitCommand,ConfigInitializer, andConfigFileResolverclasses
- Added
- CI Report Formats by @floriankraemer in #68
- Added Checkstyle XML report for Jenkins, Maven Checkstyle Plugin, and IDEs
- Added JUnit XML report for Jenkins JUnit plugin and Maven Surefire
- Added SARIF 2.1.0 report for GitHub Code Scanning
- Added GitLab Code Quality report (CodeClimate-style JSON) for GitLab merge request widgets
- Added GitHub Actions report with
::warning/::errorworkflow commands for inline PR annotations - Methods exceeding
scoreThresholdare reported as violations or failures
- Baseline Tracking Overhaul by @floriankraemer in #66
- Introduced baseline format v2.0 with metadata (
version,createdAt,configHash,metrics) - Auto-detection of the latest baseline file in
./.phpcca/baseline/baseline-*.json - Auto-generation of timestamped baseline files via
--generate-baseline/-g - JSON Schema validation against
schemas/baseline.json(Draft 7) - Config hash validation with warnings when metric weights differ from the baseline
- Expanded metric coverage in baseline files (counts, weights, and score per method)
- Backward-compatible support for legacy baseline JSON format
- Comprehensive documentation in
docs/Baseline-Analysis.md
- Introduced baseline format v2.0 with metadata (
- Optional Result Cache by @floriankraemer in #56
- Added PSR-6 file-based cache to speed up consecutive analysis runs
- Caches per-file metric results in
./.phpcca.cache(configurable) - Enabled by default in bundled
config.yml; setcache.enabled: falseto disable - New
FileCache,CacheItem, andCacheConfigclasses - Added
psr/cacheas a direct dependency
- Single-Table HTML and Markdown Reports by @floriankraemer in #69
- HTML and Markdown reports now honour
groupByClass: false - HTML renders one table with a Class column when grouping is disabled
- Markdown renders a flat "All Methods" table with class included per row
- Aligns report output with console behaviour introduced in 1.4.0
- HTML and Markdown reports now honour
🏗️ Architecture Improvements
- Command Pipeline Pattern by @floriankraemer in #66, #69, #70
- Replaced handler-based command flow with explicit pipeline stages
- Cognitive
analysepipeline: Validation → Configuration → Coverage → Metrics Collection → Baseline → Sorting → Baseline Generation → Report Generation → Output - Churn pipeline: Validation → Configuration → Coverage → Calculation → Report Generation → Output
- New
CommandPipeline,ChurnPipeline,ExecutionContext, andPipelineStageabstractions - Stage timing and statistics available in debug mode (
--debug) - Removed legacy handler classes (
BaselineHandler,ConfigurationLoadHandler,SortingHandler, etc.)
- Streaming Report Generation by @floriankraemer in #66, #69
- Introduced
StreamableReportInterfacewithstartReport(),writeMetricBatch(), andfinalizeReport() - Implemented by CSV, JSON, and Markdown reporters for incremental writes on large codebases
- Configurable flush interval via
performance.batchSize(default: 100)
- Introduced
- Baseline Domain Model Refactoring by @floriankraemer in #66
- Extracted
Baseline,BaselineFile, andBaselineSchemaValidatorfrom monolithic baseline logic - Added
FilenameNormalizerutility for consistent reporter filenames - Improved type safety and separation of concerns across baseline operations
- Extracted
🧪 Testing & Quality Assurance
- Comprehensive Test Coverage by @floriankraemer in #56, #66, #68, #69, #70
- Added
InitCommandTestfor silent, interactive, force, and validation scenarios - Added
ConfigFileResolverTestandConfigInitializerTestfor config scaffolding - Added
ConfigAutoDiscoveryTestfor automaticcca.yamlloading inanalyseandchurn - Added reporter tests for all five CI formats:
CheckstyleReporterTestJUnitReporterTestSarifReporterTestGitHubActionsReporterTestGitLabCodeQualityReporterTest
- Added cache tests:
FileCacheTest,CacheItemTest,CacheExceptionTest - Updated HTML and Markdown approval tests for single-table output
- Updated
BaselineServiceTestfor baseline v2.0 format
- Added
📚 Documentation
- Baseline Analysis Guide by @floriankraemer in #66
- New
docs/Baseline-Analysis.mdwith comprehensive baseline usage documentation - Covers auto-detection, auto-generation, schema validation, and config hash warnings
- Documents baseline v2.0 format and legacy compatibility
- New
- Configuration & Setup Guide by @floriankraemer in #70
🔧 Configuration Enhancements
- Cache Configuration by @floriankraemer in #56
- Added
cachesection toconfig.yml:enabled(default:true)directory(default:./.phpcca.cache)
- Added
.phpcca.cache/to.gitignore
- Added
- Performance Configuration by @floriankraemer in #66, #69
- Added
performance.batchSizeoption for streaming report flush interval (default: 100)
- Added
- Project Config via
initby @floriankraemer in #70cca.yamlreplaces manual config file setup as the recommended project config filename- Interactive
initprompts for:scoreThreshold,showOnlyMethodsExceedingThreshold,showHalsteadComplexity,showCyclomaticComplexity,showDetailedCognitiveMetrics, andgroupByClass
Changes
- Optional Cache to speedup consecutive Runs by @floriankraemer in #56
- Refactoring the Baseline Functionality by @floriankraemer in #66
- Adding more report Report Generators by @floriankraemer in #68
- HTML and Markdown report generation with single table configuration by @floriankraemer in #69
- Init config command added to create a default config by @floriankraemer in #70
Full Changelog: 1.10.0...1.11.0
Key Highlights
- Guided Project Setup: The new
initcommand andcca.yamlauto-discovery make it easy to configure and run analysis without manually writing config files - CI/CD Ready: Five new report formats integrate directly with Jenkins, GitHub Actions, GitHub Code Scanning, and GitLab Code Quality
- Baseline Tracking: Redesigned baseline system with schema validation, metadata, auto-detection, and expanded metric coverage
- Faster Repeated Runs: Optional PSR-6 file cache skips unchanged files on subsequent analysis runs
- Pipeline Architecture: Handler classes replaced by explicit, extensible command pipeline stages with debug timing
- Consistent Report Layout: HTML and Markdown exports now support single-table output via
groupByClass: false
Migration Guide
If you're upgrading from 1.10.0, please note:
- No Breaking Changes: All existing functionality remains compatible — commands, config options, and custom reporters continue to work unchanged
- Recommended Setup: Run
bin/phpcca initonce per project to create acca.yamlinstead of maintaining a hand-written config file - Auto-Discovery: When
cca.yamlexists in the working directory,--configis no longer required foranalyseandchurn - Cache Enabled by Default: Review
cache.enabledin your config; add.phpcca.cache/to.gitignoreif not already present - Regenerate Baselines: Run
--generate-baselineto create v2.0 baseline files with metadata and schema validation - CI Integration: New report types (
checkstyle,junit,sarif,gitlab-codequality,github-actions) are optional — existing JSON/CSV/HTML/Markdown workflows are unchanged
Example Usage
Project Setup (New)
bin/phpcca init # interactive setup → creates cca.yaml
bin/phpcca init --silent # non-interactive, all defaults
bin/phpcca init --path=./cca.yamlAnalyse with Auto-Discovered Config
bin/phpcca analyse src/ # auto-loads ./cca.yaml when present
bin/phpcca analyse src/ --config=custom.yaml # explicit config overrides auto-discoveryCI Report Formats (New)
bin/phpcca analyse src/ --report-type checkstyle --report-file checkstyle.xml
bin/phpcca analyse src/ --report-type junit --report-file junit.xml
bin/phpcca analyse src/ --report-type sarif --report-file results.sarif
bin/phpcca analyse src/ --report-type gitlab-codequality --report-file gl-code-quality.json
bin/phpcca analyse src/ --report-type github-actions --report-file -Baseline Tracking (Enhanced)
# Generate a timestamped baseline
bin/phpcca analyse src/ --generate-baseline
# Compare against a specific baseline
bin/phpcca analyse src/ --baseline=./.phpcca/baseline/baseline-2025-01-18_14-30-45.json
# Auto-detect latest baseline in ./.phpcca/baseline/
bin/phpcca analyse src/Single-Table Report...
1.10.0 - Custom Reporters & Architecture Improvements
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
ReporterRegistryclass for managing and loading custom reporters - Configuration support via
config.ymlfor 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:
DataExporterInterface→ReportGeneratorInterface - Improved naming consistency across the codebase
-
Enhanced Factory Pattern Implementation by @floriankraemer in #61
- Introduced
ChurnReportFactoryandChurnReportFactoryInterface - Introduced
CognitiveReportFactoryandCognitiveReportFactoryInterface - Removed legacy
ChurnExporterFactoryandCognitiveExporterFactory - Better separation of concerns with dedicated factory interfaces
- Support for dynamic reporter registration and instantiation
- Introduced
-
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:
CompositeChurnSpecificationCompositeCognitiveMetricsValidationSpecification
- Individual specification classes for focused validation:
CoverageFileExistsCoverageFormatSupportedCoverageFormatExclusivityCustomExporterValidationSortFieldValidSortOrderValidReportOptionsComplete
- 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 logicConfigurationLoadHandler- Manages configuration loadingCoverageLoadHandler- Handles coverage data loadingSortingHandler- Manages metrics sorting
- Enhanced
ChurnReportHandlerandCognitiveMetricsReportHandler - Simplified command classes by delegating to specialized handlers
-
Enhanced Data Models by @floriankraemer in #61
- Introduced
ChurnMetricsclass for better data encapsulation - Introduced
ChurnMetricsCollectionfor collection management - New
OperationResultclass for standardized command results - Improved type safety and data structure consistency
- Introduced
-
Code Organization Improvements by @floriankraemer in #61
- Moved
DirectoryScannertoBusiness/Utility/namespace - Moved
CoverageDataDetectortoBusiness/Utility/namespace - Better logical grouping of utility classes
- Improved namespace structure
- Moved
🧪 Testing & Quality Assurance
- Comprehensive Test Coverage by @floriankraemer in #61
- Added 1,000+ lines of new test coverage
- New test fixtures for custom reporters:
ConfigAwareChurnTextReporterConfigAwareTextReporterCustomChurnTextReporterCustomTextReporter
- Comprehensive tests for specification pattern:
ChurnSpecificationPatternTestCognitiveMetricsSpecificationPatternTest
- Factory pattern tests:
ChurnReporterFactoryCustomTestCognitiveReporterFactoryCustomTest
- Configuration tests:
CustomExportersConfigTest
- Command tests:
- Enhanced
ChurnCommandTest - Enhanced
CognitiveMetricsCommandTest
- Enhanced
- 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
customReporterssection toconfig.yml - Support for cognitive and churn reporter registration
- Flexible configuration with optional file paths
- Example configuration in default config file
- Added
Changes
- Support for custom Reporters by @floriankraemer in #61
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:
- No Breaking Changes: All existing functionality remains compatible
- Optional Feature: Custom reporters are entirely optional - existing workflows continue to work unchanged
- Configuration: If you want to use custom reporters, add the
customReporterssection to yourconfig.yml(see documentation) - 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.htmlUsing 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.pdfSee docs/Creating-Custom-Reporters.md for complete documentation.
1.9.0 - Code Coverage Integration & Architecture Improvements
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-coberturaand--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
CyclomaticComplexityCalculatorclass - Improved separation of concerns and code maintainability
- Enhanced testability with dedicated calculator interface
- Better encapsulation of complexity calculation algorithms
- Extracted cyclomatic complexity logic into dedicated
-
Extracting Halstead Calculations from the Visitor by @floriankraemer in #63
- Created dedicated
HalsteadMetricsCalculatorclass for cleaner architecture - Separated calculation logic from AST visitor pattern
- Improved code organization and reusability
- Enhanced test coverage for Halstead metrics calculations
- Created dedicated
🔧 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.mdwith detailed contribution guidelines - Created structured issue templates for better bug reporting
- Enhanced project documentation and community guidelines
- Improved developer onboarding experience
- Added comprehensive
Changes
- Add code coverage support to CognitiveMetrics command by @floriankraemer in #57
- Refactoring Cyclomatic Complexity Calculation by @floriankraemer in #64
- Extracting Halstead Calculations from the Visitor by @floriankraemer in #63
- Adding PHPCS Slevomat Coding Standard Rules by @floriankraemer in #62
- Github contribution and issue configuration by @floriankraemer in #59
- Moving the Github issue template by @floriankraemer
- Renaming the issue template file by @floriankraemer
Full Changelog: 1.8.0...1.9.0
Release 1.8.0 - Markdown Export & Enhanced Reporting
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
- Add line number tracking to CognitiveMetrics by @floriankraemer in #51
- Add Markdown export functionality for Churn by @floriankraemer in #52
- Adding a markdown report generator by @floriankraemer in #50
- Refactoring for maintainability by @floriankraemer in #53
- Fix exclude files via config by @floriankraemer in #54
Full Changelog: 1.7.0...1.8.0
Release 1.7.0 - Optional Code Coverage as Factor in Churn Analysis
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
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 inCognitiveMetricsCollectorfor handling multiple paths - Added
getCognitiveMetricsFromPaths()method inMetricsFacadefor streamlined multi-path processing - Enhanced path parsing logic with robust trimming and filtering of empty paths
- Improved code maintainability with better separation of concerns
- Introduced
🧪 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
- Added unit tests for
Full Changelog: 1.5.0...1.6.0
1.5.0 - Performance Improvements & more!
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
showDetailedCognitiveMetricsconfiguration option to control detailed metric display - Improved console output readability by making detailed metrics optional
- Added
⚡ Performance Enhancements
- Significantly increase analysis performance by @floriankraemer in #46
- Introduced
CombinedMetricsVisitorto 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
- Introduced
🧪 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
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
- https://github.com/Phauthentic/cognitive-code-analysis/blob/master/docs/Sorting-and-Filtering.md
- https://github.com/Phauthentic/cognitive-code-analysis/blob/master/docs/Configuration.md
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
1.3.0
What's Changed
- Adding a Churn Treemap Exporter by @floriankraemer in #25
- Adding Halstead and Cyclomatic Complexity to the output by @floriankraemer in #37
- Made the Cyclomatic and Halstead metrics configurable by @floriankraemer in #38
- Symfony 6 & 7 Compatibility, Refactorings for extendibility by @floriankraemer in #39
- Updating docs: Halstead and Cyclomatic explanations by @floriankraemer in #40
Full Changelog: 1.2.4...1.3.0