Using Crap4j

Running Crap4j

To get a CRAP report for your project:

  1. In the Package Explorer, select the project to be analyzed.

    The Crap4j icon becomes enabled in the toolbar and on the menu bar.

  2. Click the icon or select the menu item.

    The Crap4j tool analyzes your codebase. It opens the JUnit runner and runs all tests in the project.

    When the analyisis is finished, an HTML report opens displaying the results of the analysis. This html report is located in <project root>/agitar/reports/crap4j.

Reading the Report

The CRAP report shows the percentage of methods in the project that are above the CRAP threshold of 8. It also shows the number of methods that are above the CRAP threshold and other statistics.

At the bottom of the report are links to method-level details sorted by various criteria.

Definitions

CRAP
The method CRAP level as defined by the equation:
(complexity ^ 2)((1 - coverage) ^ 3) + complexity
CRAP Threshold
The CRAP score beyond which the code is deemed to be crappy. Currently, 8.
CRAP Load
The amount of work required to reduce the code to below the CRAP Threshold. This can be a combination of adding tests for code missing coverage, or refactoring code into smaller methods with lower complexity.