Maurits Rijk
Maurits Rijk

Reputation: 9985

How to calculate cyclomatic complexity of a Clojure function?

What would be a reasonable way to calculate the cyclomatic complexity of a Clojure function? It's easy to count decision points based on functions like 'if' and 'cond', but it starts to get tricky with macros. Anyone has tried this for Clojure or maybe another functional language?

Upvotes: 4

Views: 1001

Answers (1)

Stuart Dabbs Halloway
Stuart Dabbs Halloway

Reputation: 1666

Macros are an abstraction and should not contributed to the CC calculation, any more than a function call would.

That said, I don't think that CC is particularly interesting for Clojure. I would be more interested in something that measured overuse of mutability.

Upvotes: 4

Related Questions