4

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?

Maurits Rijk
  • 9,789
  • 2
  • 36
  • 53
  • 1
    A don't think that CC makes much sense in Clojure, but, at any rate, what you want to count is not decision points per se, but possible execution paths. – Apalala Mar 19 '11 at 23:52
  • 1
    Macros shouldn't be an issue; you can use macroexpand to get rid of them completely. – Joost Diepenmaat Mar 20 '11 at 02:23

1 Answers1

4

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.

Stuart Dabbs Halloway
  • 1,658
  • 12
  • 10