[RFC] Cyclomatic complexity checker

Hello everyone,

I skimmed through available checkers in Clang Static Analyzer [1] and didn’t find a checker for cyclomatic complexity.

My assumption is that checker is not implemented because it doesn’t help to find bugs directly [2]. However I believe that this checker would help to reduce a number of bugs indirectly by decreasing a complexity of a source code.

Is there a way to see this checker in the upstream? If not what would be the best way to have it?

[1] http://clang-analyzer.llvm.org/available_checks.html
[2] By definition, "The Clang Static Analyzer is a source code analysis tool that finds bugs in C, C++, and Objective-C programs.” (from http://clang-analyzer.llvm.org/index.html)

Thanks.

Stanislav

This is correct. We do not have a checker for cyclomatic complexity. It should not be hard to implement. The trickiest part is coming up with a great user interface.

Cheers,
Anna.

Stanislav,

I believe this functionality is already in clang-tidy (look at clang-tools-extra/test/clang-tidy/readability-function-size.cpp test; “readability-function-size.BranchThreshold” option essentially computes cyclomatic complexity, though it does so in a non-traditional way – which actually might produce more useful results for C++ developers).

Yours,
Andrey

Write it :slight_smile:

If someone could mate cccc.sourceforge.net to clang, that would be nice.

Csaba