Cyclomatic complexity in D ?

Basile B. via Digitalmars-d digitalmars-d at puremagic.com
Mon Aug 15 15:36:41 PDT 2016


Last night I've done a bit of documentation work on cyclomatic 
complexity. From this work it looks like the tools that do this 
static analysis are only using the AST (e.g the CC is computed 
for a each single function, and function calls inside the graph 
are considered as "connected componenents" with a constant weight 
of 1.

The problems I see with D are
- the metaprogramming features. (clearly unsolvable)
- conditional compilation: "version()" and "static if" are hardly 
handlable at the AST level, meaning that a bit of semantic is 
necessary to compute the real CC.
- functional programming, CTFE.

So what the CC for ?
- DScanner could implement it (or also the maintainability index) 
to check existing code-bases.
- As a guard, i.e when you're inspired and that you write 2000 
SLOC in the day.

So CC possible or not in D (at the AST level) ?


More information about the Digitalmars-d mailing list