PHPackages                             mridang/pmd-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/pmd-annotations

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

mridang/pmd-annotations
=======================

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

0.0.2(6y ago)0113.2k↓16.7%1[1 PRs](https://github.com/mridang/pmd-annotations/pulls)7MITPHPPHP ^7.0CI failing

Since Mar 31Pushed 4y agoCompare

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

READMEChangelogDependencies (1)Versions (3)Used By (7)

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

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

Turns PMD 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/pmd-annotations
```

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

[](#example-usage)

`pmd2pr` can be used on a already existing PMD-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 PMD formatted file
----------------------------

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

```
vendor/bin/pmd2pr /path/to/pmd-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 PMD-formatted report. Examples can bee seen below:

### Using [PHPMD](https://github.com/phpmd/phpmd)

[](#using-phpmd)

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

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

[](#example-githubaction-workflow)

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

```
# ...
jobs:
    phpmd-analysis:
      name: phpmd 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: pmd2pr
          - run: |
                composer install # install your apps dependencies
                vendor/bin/phpmd . xml codesize,naming,unusedcode,controversial,design --exclude libs,var,build,tests --ignore-violations-on-exit | pmd2pr
```

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

```
# ...
jobs:
    phpmd-analysis:
      name: phpmd 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/pmd-annotations # install pmd2pr
                vendor/bin/phpmd . xml codesize,naming,unusedcode,controversial,design --exclude libs,var,build,tests --ignore-violations-on-exit | vendor/bin/pmd2pr
```

Resources
=========

[](#resources)

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

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity30

Limited adoption so far

Community21

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 78.9% of commits — single point of failure

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

Every ~0 days

Total

2

Last Release

2240d ago

### Community

Maintainers

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

---

Top Contributors

[![staabm](https://avatars.githubusercontent.com/u/120441?v=4)](https://github.com/staabm "staabm (60 commits)")[![localheinz](https://avatars.githubusercontent.com/u/605483?v=4)](https://github.com/localheinz "localheinz (10 commits)")[![tristanbes](https://avatars.githubusercontent.com/u/346010?v=4)](https://github.com/tristanbes "tristanbes (2 commits)")[![shivammathur](https://avatars.githubusercontent.com/u/1571086?v=4)](https://github.com/shivammathur "shivammathur (1 commits)")[![prisis](https://avatars.githubusercontent.com/u/2716058?v=4)](https://github.com/prisis "prisis (1 commits)")[![korelstar](https://avatars.githubusercontent.com/u/6277619?v=4)](https://github.com/korelstar "korelstar (1 commits)")[![kevinpapst](https://avatars.githubusercontent.com/u/533162?v=4)](https://github.com/kevinpapst "kevinpapst (1 commits)")

---

Tags

checkstylegithub-actionsmess-detectorphpmdpmdannotationsgithubactions

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[tormjens/eventy

The WordPress filter/action system in Laravel

438912.9k16](/packages/tormjens-eventy)[minime/annotations

The KISS PHP annotations library

229378.6k37](/packages/minime-annotations)[jbzoo/ci-report-converter

The tool converts different error reporting standards for deep integration with popular CI systems (TeamCity, IntelliJ IDEA, GitHub Actions, etc)

30784.4k2](/packages/jbzoo-ci-report-converter)[spiral/attributes

PHP attributes reader

233.6M45](/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

27621.3k2](/packages/bainternet-php-hooks)[unicodeveloper/laravel-emoji

A Laravel 5 Package for Using &amp; Working With Emojis

21024.9k](/packages/unicodeveloper-laravel-emoji)

PHPackages © 2026

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