Skip to content
Google Testing Blog·

🛠️CRAP Metric Turns 15, Still Detecting Code Anti-Patterns

CRAP Metric Celebrates 15 Years of Code Quality

TL;DR

The CRAP metric, developed in 2007 to detect code anti-patterns, turns 15 this year. Originally for Java, it's now in multiple languages and tools like .NET, PHP, and Clover. Still relevant for code quality.

The CRAP metric, originally developed in 2007 by Alberto Savoia and Bob Evans, celebrates its 15th anniversary. It was designed to identify code anti-patterns that could lead to maintenance nightmares. Now, it's integrated into various languages and tools, helping developers catch bad code early. The CRAP1 formula measures code complexity and coverage, with a score over 30 indicating CRAPpy code. Despite its age, CRAP remains a go-to metric for code quality, though it doesn't cover higher-order metrics yet.

CRAP Metric Turns 15, Still Detecting Code Anti-Patterns — Google Testing Blog

Key Points

1

CRAP metric, developed in 2007, detects code anti-patterns in Java, .NET, PHP, and more.

2

CRAP1 formula: CRAP1(m) = comp(m)^2 * (1 - cov(m)/100)^3 + comp(m), with score > 30 indicating CRAPpy code.

3

CRAP metric has been adopted by the Agile community for code quality checks.

4

CRAP is integrated into free and commercial tools like Hudson's Cobertura and Atlassian's Clover.

5

CRAP metric is available for projects using Eclipse, Maven, and Ant, aiding in early code quality detection.

Why It Matters

If you're using Java, .NET, PHP, or other languages, CRAP helps catch bad code early. It's integrated into tools like Cobertura and Clover. For projects on Eclipse, Maven, or Ant, CRAP ensures better code quality from the start.

code-qualityCRAP-metriccode-anti-patternsdevopscode-analysis

Comments

Subscribe to join the conversation...

Be the first to comment

Enjoyed this article?

Get it daily. 7am. Free. Reads in 5 minutes.

Join 3,482 builders reading daily.

Also get