[PATCH] [clang-tidy] Add a checker for long functions.

Benjamin Kramer benny.kra at gmail.com
Mon Aug 25 03:59:54 PDT 2014


>>! In D4986#4, @alexfh wrote:
> I wonder if any style guides define function size threshold in terms of cyclomatic complexity? Is it actually useful as a warning?

It doesn't seem to be very common in C++ coding styles (probably due to lack of tools). I've seen warnings for this in other languages, e.g. Microsoft's C# analyzer puts an upper bound on cyclomatic complexity. It's yet another metric that seems slightly more useful than counting lines or statements.

I couldn't fully make up my mind about the static analyzer as its goals are slightly different. It tries hard to prune dead paths to avoid false positives while we still want to warn about complex functions that are mostly dead. Not sure if that matters in practice though.

This checker is a bit of a grab bag of metrics I could think of. It needs some configuration from the user to be useful.

http://reviews.llvm.org/D4986






More information about the cfe-commits mailing list