Reputation: 6078
I am searching for a Cyclomatic Complexity Api in Delphi (2010). I need to create a program that will analize a source code and report the Cyclomatic Complexity of all methods in all classes (just like SourceMonitor does).
I cant use other softwares, I really need to build one.
Does anyone knows an API for delphi 2010 that does that?
Upvotes: 1
Views: 819
Reputation: 12104
You'll need a language parser from which you can generate a control flow graph. Then you need to calculate the CC using this formula.
I know of no library that will do this for you.
You may be able to use the free pascal source to generate the control flow graph (its a common technique used in compilers to eliminate unreachable code).
Unfortunately, Delphi hasn't shipped with a complete formal definition(bnf grammar) of the language in its documentation since Delphi 6 I believe. (even then it wasn't completely accurate) So all third party parsers are shooting in the dark.
Upvotes: 3