What code metric(s) convince you that provided code is "crappy"?

Not an automated solution, but I find WTF's per minute useful.

WTF's Per Minute
(source: osnews.com)


No metrics regarding coding-style are part of such a warning.

For me it is about static analysis of the code, which can truly be 'on' all the time:

  • cyclomatic complexity (detected by checkstyle)
  • dependency cycle detection (through findbugs for instance)
  • critical errors detected by, for instance findbugs.

I would put coverage test in a second step, as such tests can take time.


Do not forget that "crappy" code are not detected by metrics, but by the combination and evolution (as in "trend) of metrics: see the What is the fascination with code metrics? question.

That means you do not have just to recommend code metrics to "automatically identify "crappy code"", but you also have to recommend the right combination and trend analysis to go along those metrics.


On a sidenote, I do share your frustration ;), and I do not share the point of view of tloach (in the comments of another answers) "Ask a vague question, get a vague answer" he says... your question deserve a specific answer.


Number of warnings the compiler spits out when I do a build.