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.