PHPackages                             mridang/cpd-annotations - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. mridang/cpd-annotations

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

mridang/cpd-annotations
=======================

Turns CPD style XML reports into Github pull-request annotations via the Checks API. This script is meant for use within your Github Action.

0.0.1(6y ago)01.3kMITPHPPHP ^7.0CI failing

Since Apr 5Pushed 6y agoCompare

[ Source](https://github.com/mridang/cpd-annotations)[ Packagist](https://packagist.org/packages/mridang/cpd-annotations)[ GitHub Sponsors](https://github.com/mridang)[ RSS](/packages/mridang-cpd-annotations/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

Annotate pull-requests based on a CPD XML-report
================================================

[](#annotate-pull-requests-based-on-a-cpd-xml-report)

Turns CPD style XML-reports into Github pull-request [annotations via the Checks API](https://developer.github.com/v3/checks/). This script is meant for use within your Github Action.

That means you no longer have to search through your Github Action log files or the console output. No need to interpret messages which are formatted differently with every tool. Instead you can focus on your pull-request, and you don't need to leave the pull-request area.

[![Logs Example](https://github.com/mheap/phpunit-github-actions-printer/raw/master/phpunit-printer-logs.png?raw=true)](https://github.com/mheap/phpunit-github-actions-printer/blob/master/phpunit-printer-logs.png?raw=true)

[![Context Example](https://github.com/mheap/phpunit-github-actions-printer/raw/master/phpunit-printer-context.png?raw=true)](https://github.com/mheap/phpunit-github-actions-printer/blob/master/phpunit-printer-context.png?raw=true)*Images from *

Installation
============

[](#installation)

Install the binary via Composer

```
composer require mridang/cpd-annotations
```

Example Usage
=============

[](#example-usage)

`cpd2pr` can be used on a already existing CPD-report XML-report. Alternatively you might use it in the UNIX pipe notation to chain it into your existing cli command.

Run one of the following commands within your Github Action workflow:

Process a CPD formatted file
----------------------------

[](#process-a-cpd-formatted-file)

```
vendor/bin/cpd2pr /path/to/cpd-report.xml
```

### Available Options

[](#available-options)

- `--graceful-warnings`: Don't exit with error codes if there are only warnings
- `--colorize`: Colorize the output. Useful if the same lint script should be used locally on the command line and remote on Github Actions. With this option, errors and warnings are better distinguishable on the command line and the output is still compatible with Github annotations

Pipe the output of another commmand
-----------------------------------

[](#pipe-the-output-of-another-commmand)

This works for **any** command which produces a CPD-formatted report. Examples can bee seen below:

### Using [PHCPD](https://github.com/phcpd/phcpd)

[](#using-phcpd)

```
phcpd . xml codesize,naming,unusedcode,controversial,design --exclude libs,var,build,tests --ignore-violations-on-exit | vendor/bin/cpd2pr
```

Example GithubAction workflow
-----------------------------

[](#example-githubaction-workflow)

If you're using `shivammathur/setup-php` to setup PHP, `cpd2pr` binary is shipped within:

```
# ...
jobs:
    phcpd-analysis:
      name: phcpd static code analysis
      runs-on: ubuntu-latest
      steps:
          - uses: actions/checkout@v2
          - name: Setup PHP
            uses: shivammathur/setup-php@v1
            with:
                php-version: 7.3
                coverage: none # disable xdebug, pcov
                tools: cpd2pr
          - run: |
                composer install # install your apps dependencies
                vendor/bin/phcpd . xml codesize,naming,unusedcode,controversial,design --exclude libs,var,build,tests --ignore-violations-on-exit | cpd2pr
```

If you use a custom PHP installation, then your project needs to require `mridang/cpd-annotations`

```
# ...
jobs:
    phcpd-analysis:
      name: phcpd static code analysis
      runs-on: ubuntu-latest
      steps:
          - uses: actions/checkout@v2
          - name: Setup PHP
            run: # custom PHP installation
          - run: |
                composer install # install your apps dependencies
                composer require mridang/cpd-annotations # install cpd2pr
                vendor/bin/phcpd . xml codesize,naming,unusedcode,controversial,design --exclude libs,var,build,tests --ignore-violations-on-exit | vendor/bin/cpd2pr
```

Resources
=========

[](#resources)

[GithubAction Problem Matchers](https://github.com/actions/toolkit/blob/master/docs/problem-matchers.md)

###  Health Score

23

—

LowBetter than 26% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2270d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2b193d399917d22f08b8d20644f1056adadee49b25438d5df2e82132ab88d771?d=identicon)[mridang](/maintainers/mridang)

---

Tags

annotationsgithubactionsCPD

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mridang-cpd-annotations/health.svg)

```
[![Health](https://phpackages.com/badges/mridang-cpd-annotations/health.svg)](https://phpackages.com/packages/mridang-cpd-annotations)
```

###  Alternatives

[tormjens/eventy

The WordPress filter/action system in Laravel

438937.3k22](/packages/tormjens-eventy)[minime/annotations

The KISS PHP annotations library

229386.3k38](/packages/minime-annotations)[spiral/attributes

PHP attributes reader

244.1M56](/packages/spiral-attributes)[bainternet/php-hooks

A fork of the WordPress filters hook system rolled in to a class to be ported into any PHP-based system

27623.1k5](/packages/bainternet-php-hooks)[jwage/changelog-generator

Generate a markdown changelog document from a GitHub milestone.

10374.2k](/packages/jwage-changelog-generator)[lekoala/silverstripe-cms-actions

Add actions to your models in SilverStripe

39317.0k29](/packages/lekoala-silverstripe-cms-actions)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
