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

I think this is a cool metric but I just have to laugh at the juxtaposition of the name and the “I created this without looking at it” remark. Truly we live in fascinating times.

5 Likes

I like it and I want to use it in my projects, if it were a custom credo check rather than another tool I have to plug into pipelines and not forgetting to run locally.

AFAICT, the whole idea is perfectly fitting the custom credo checks. Being an author or oeditus_credo I would kindly ask you if you are open to either contribute to it directly, or to let me steal the code to become a part of this supplemental credo checks lib.

Sidenote: muex suffered a whole lot of improvements this weekend, so you’d probably want to try the newest version. THe noise should be drastically decreased.

1 Like

Please, feel free to grab code! It’s all MIT license. I love the idea of it being in a credo check.