ExCrap - a library to calculate Change Risk Anti-Patterns (CRAP scores)

I recently published ExCrap, a library (primarily a mix task) for calculating Change Risk Anti-Patterns scores (or CRAP scores).

What are CRAP scores?

From the README:

CRAP combines function-level cyclomatic complexity with function-level coverage to highlight code that is risky to change because it is both complex and under-tested. The default threshold of 30 follows the historical CRAP convention.

It’s a measure that combines test coverage and cyclomatic complexity to try to measure how “risky” any given function is.

The usage is simple. It’s used as a mix task:

mix crap
mix crap --verbose
mix crap --max-cover 10

NOTE:

I created the library without looking at the code (though I checked the code before publishing it) as a personal experiment in verification. I use the library in my projects. But I mention that because some people might have reservations about using it knowing that I didn’t manually write the code myself. So, just want to be clear about it.

I also wrote a blog post on why I created it that way.

Links

5 Likes