Ryan's Rambling

Wednesday, May 04, 2005

Cyclomatic Complexity for Delphi

I am releasing an internal tool for determining Cyclomatic Complexity of Delphi (or Pascal) source code. Cyclomatic complexity is a great way to determine the level of unit testing required on different methods in a class or module. It is an integrated tool in the Delphi IDE and supports Delphi 6, 7, and 2005. The wizard integration is something new so there might be a glitch or two - let me know.

Anyway, you can find out more on the CCP page.

Update: There was a bug when exiting Delphi if you had any ccp messages in the message view. An updated 0.9.1.2006 build and source are on the site now for anyone that downloaded the software already. You can confirm the version by right clicking on the bpl and choosing properties.

Labels:

4 Comments:

  • Still fails to deal with switch/case statements adequately. It's impossible to write (say) a message handler with an acceptable cyclomatic complexity, so you end up having to remember that some units/methods will always get flagged but you need to ignore them.

    By Anonymous, At 1:48 AM  

  • From a testability perspective it is accurate since it represents the number of potential branches that may be followed. I would like to think case/switch statements are somehow cheaper than the alternative joined if else if expressions but altering the point system would be stepping away from the cross-language application of the numbers.

    It also points to having alternate implementations than large case statements such as message maps etc. Doesn't cover all cases, may not be the most performant, but it definitely flags that alternatives may exist that are more easily consumed.

    By Ryan, At 7:30 AM  

  • D6 problem. Installs and operates. When Delphi is restarted, the message "RtsCcpWizardRegistration Error List index out of bounds (-1). On pressing OK, the tool is not loaded or available in the menu.

    By Anonymous, At 2:18 PM  

  • I have not heard of that behaviour before. You may want to try compiling from source. My e-mail is on the ccp page if you want some assistance.

    By Ryan, At 12:51 PM  

Post a Comment



Links to this post:

Create a Link

<< Home