On Monday, 15 August 2016 at 22:36:41 UTC, Basile B. wrote:
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) ?

Even detecting the main() in the AST is subject to error

°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
version(set_by_command-line)
{
  static if (modulea.a || b && modulec.c)
   void main(){}
  else
    void naim(){}
}
else
{
  version(yo_o_yo)
  {
    static if (a || modulek.b && c)
      void main(){}
    else
      void naim(){}
  }
  else
    void nami(){}
}
°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°

Good luck to find the main() with only the AST an no semantic ;)

Reply via email to