PHPackages                             leovie/clover-crap-check - 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. leovie/clover-crap-check

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

leovie/clover-crap-check
========================

v2.0.2(1y ago)2431[4 PRs](https://github.com/LeoVie/clover-crap-check/pulls)MITPHPPHP &gt;=8.4CI passing

Since Feb 23Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/LeoVie/clover-crap-check)[ Packagist](https://packagist.org/packages/leovie/clover-crap-check)[ RSS](/packages/leovie-clover-crap-check/feed)WikiDiscussions main Synced today

READMEChangelog (10)Dependencies (13)Versions (19)Used By (0)

clover-crap-check
=================

[](#clover-crap-check)

This tool reads the clover.xml report from phpunit and checks, if all files have a [CRAP index](https://blog.ndepend.com/crap-metric-thing-tells-risk-code/)below a specified threshold.

Installation
------------

[](#installation)

### PHAR (recommended)

[](#phar-recommended)

You can download the latest PHAR from

### Composer

[](#composer)

Install via composer as a dev dependency

```
composer require --dev leovie/clover-crap-check
```

Usage
-----

[](#usage)

The tool has two required arguments

1. The path of the clover.xml file, that's generated by phpunit. The path can be absolute or relative to cwd.
2. The CRAP index threshold that is acceptable (min `1`)

Generate the clover.xml file by using phpunit and run `clover-crap-check` afterwards:

```
vendor/bin/phpunit --coverage-clover clover.xml
vendor/bin/clover-crap-check clover.xml 50
```

This can give you an output like the following

```
 [ERROR] The following methods are crappier than allowed

 ------------ -------- ------
  Class        method   CRAP
 ------------ -------- ------
  ClassA       m1       100
  Foo\ClassB   m2       60
 ------------ -------- ------

```

### Baseline feature

[](#baseline-feature)

When using `clover-crap-check` with legacy code, likely you don't want to refactor all your files to have a low CRAP index. At the same time you want your new code to be as less CRAPpy as possible.

To achieve this with clover-crap check, there is a baseline feature.

#### 1. Generate the baseline

[](#1-generate-the-baseline)

In addition to the required arguments, pass the option `--generate-baseline`with a path to where the baseline file should get stored. The path can be absolute or relative to cwd.

```
vendor/bin/clover-crap-check clover.xml 50 \
  --generate-baseline=baseline.json
```

This will run `clover-crap-check` and generate a baseline file that contains all your files with a CRAP index over the defined threshold (50 in this case).

The baseline files looks like the following

```
[
  {
    "classFQN": "ClassA",
    "name": "m1",
    "crap": 100
  },
  {
    "classFQN": "Foo\\ClassB",
    "name": "m2",
    "crap": 60
  }
]
```

#### 2. Use the baseline

[](#2-use-the-baseline)

After generating the baseline, you can use it in the next runs. To do this, simply pass the path to the baseline file via the option `--baseline` to the tool. The path can be absolute or relative to cwd.

```
vendor/bin/clover-crap-check clover.xml 50 \
  --baseline=baseline.json
```

`clover-crap-check` should not report anything in that case.

Now, when you add new files with a CRAP index over the defined threshold (`50` in this case), you will get noticed about that. The same thing happens, when files in your baseline get CRAPpier, than they were when the baseline was generated.

This can give you an output like the following

```
 [ERROR] The baseline is not up to date

 [ERROR] The following methods are newly occurring

 -------- -------- ------
  Class    method   CRAP
 -------- -------- ------
  ClassC   m3       70
 -------- -------- ------

 [ERROR] The following methods got crappier

 -------- -------- ------
  Class    method   CRAP
 -------- -------- ------
  ClassA   m1       65
 -------- -------- ------

```

#### 3. Keeping the baseline up to date

[](#3-keeping-the-baseline-up-to-date)

You can decide to generate the baseline once and then never touch it again. This can be useful when you have very many files in the baseline and don't want to bother with improving the legacy code over the time.

But you can also decide to get noticed, when a file gets less CRAPpy. To do this, you can pass the option `--report-less-crappy-methods`to `clover-crap-check`

```
vendor/bin/clover-crap-check clover.xml 50 \
  --baseline=baseline.json \
  --report-less-crappy-methods
```

This will give you a hint, e.g. when a file that had a CRAP index of `100` when you generated the baseline now has a CRAP index of `60`.

```
 [ERROR] The baseline is not up to date

 [INFO] The following methods got less crappy

 -------- -------- ------
  Class    method   CRAP
 -------- -------- ------
  ClassA   m1       60
 -------- -------- ------

```

You can than manually update the CRAP value in the baseline file (to `60` in this case).

There's also another option `--report-vanished-methods`. When activated, `clover-crap-check` will notice you when there are methods in your baseline, that are not occurring anymore in the clover report or have a CRAP index below your threshold, now.

```
 [ERROR] The baseline is not up to date

 [INFO] The following methods vanished

 -------- -------- ------
  Class    method   CRAP
 -------- -------- ------
  ClassA   m1       100
 -------- -------- ------

```

###  Health Score

43

—

FairBetter than 89% of packages

Maintenance62

Regular maintenance activity

Popularity14

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~63 days

Recently: every ~180 days

Total

13

Last Release

463d ago

Major Versions

v0.0.7 → v1.0.02023-02-28

v1.0.3 → v2.0.02025-03-26

PHP version history (3 changes)v0.0.1PHP &gt;=8.2

v1.0.3PHP &gt;=8.1

v2.0.0PHP &gt;=8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/876f842b58e2a0e54d85eddfb8ed1b599586e94d9071efaddd208383ea85932c?d=identicon)[leo.viezens@web.de](/maintainers/leo.viezens@web.de)

---

Top Contributors

[![LeoVie](https://avatars.githubusercontent.com/u/7249788?v=4)](https://github.com/LeoVie "LeoVie (41 commits)")

---

Tags

dev

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Psalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/leovie-clover-crap-check/health.svg)

```
[![Health](https://phpackages.com/badges/leovie-clover-crap-check/health.svg)](https://phpackages.com/packages/leovie-clover-crap-check)
```

###  Alternatives

[craftcms/cms

Craft CMS

3.6k3.6M3.0k](/packages/craftcms-cms)[friendsoftypo3/content-blocks

TYPO3 CMS Content Blocks - Content Types API | Define reusable components via YAML

103519.9k53](/packages/friendsoftypo3-content-blocks)[chameleon-system/chameleon-base

The Chameleon System core.

1028.6k5](/packages/chameleon-system-chameleon-base)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.4M203](/packages/sulu-sulu)[blackfire/player

A powerful web crawler and web scraper with Blackfire support

49517.1k](/packages/blackfire-player)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.1k17.8k](/packages/prestashop-prestashop)

PHPackages © 2026

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