Home
Archives
About us...
Advertising
Contacts
Site Map
 

ruby in steel

 

code healer blank programming CodeHealer 2.1
SOCK Software
http://www.socksoftware.com/
Requirements: A Professional, Enterprise or Architect version of Delphi 5 to 2006.  
Source code analysis
$379 :: Free Trial Available


No piece of software can guarantee to eliminate all potential bugs from your programs. However, CodeHealer can at least help you to find and fix a variety of errors which might otherwise have passed unnoticed.

codehealer
CodeHealer is a standalone tool for analysing Delphi programs

CodeHealer is a source code analysis tool for Delphi which reads through your code and reports on errors of logic and syntax as well as on inelegant or inefficient coding techniques. To use it you just up your Delphi project file and click an icon to analyse it. CodeHealer zips through all the files in the project and lists each unit in a window. Any warnings or errors are displayed in another window. If a syntax error is located at this time you will be prompted to load the file into the Delphi editor in order to fix the error.

The errors are arranged in the form of an outline. The outline headers give information on each types of error – such as ‘Assignment to constant items of expressions’, ‘Delphi directive names used as identifiers’ or ‘Undefined function return values’. If there are multiple errors of the same type, these are grouped together as branches beneath a single heading. Other types of error which it may locate include type assignment incompatibilities and array index errors. In theory, it also warns about unreachable code - that is, code which, because of faulty program logic, can never be executed. In practice, this doesn’t work. When I asked the developers, I was told that the unreachable code option is disabled in this release (though, confusingly, the option is still listed) due to the fact that it was generating too many false positives; this feature will be reinstated in version 2.2 which is supplied as a free update to purchasers.

code healer analysis window
The analysis results are listed as branches in this window. You can click a branch to locate the problem in a code window.

To give you some idea of the kinds of problems CodeHealer can locate, here are a few of the warnings it produced from some of my own projects:

  • The variable ‘FName’ hides the field of the same name declared on line 1292 of ‘Classes.pas’
  • The identifier ‘Index’ is also a Delphi directive’
  • The local constant ‘ERRORICON’ is declared but is never used.

You can click an error message to locate the source of the error in your code; the file is loaded into a window and the identifier or expression causing the problem is highlighted. You can either edit the code in the code display window or you can click a button to load the file into Delphi with the cursor placed on the problem line.

In fact, in some cases there is an easier way of fixing errors. You just have to highlight them one by one and click the ‘Heal’ button. This lets you do things such as comment out or delete an unused variable or assign a value to an uninitialised variable. If you change your mind, an Undo button undoes the edit. There are limits to what the Heal button can do, however. If you have a name-clash error, for example, or an assignment to a constant, the Heal button stays greyed out. That means you have only two options: either ignore the error or edit it by hand.

healer
In some cases the code 'healing' can be done at the click of a mouse!

If the analysis is not comprehensive enough for you, there are extra options that can be activated. For example, by default CodeHealer won’t warn if you use a class name such as TObject as a variable. But when you activate an option to report type names that are hidden by non type names, this will be reported as an error.

options
You can configure the reports by selecting from a large number of options

You can also generate a report on a project ‘metrics’. This displays a variety of statistical information such as the numbers of code and comment lines in a specific files, the number of classes, functions, string constants and identifiers. It also displays the number of ‘branches’ (things such as if..else and case statements), loops (for, repeat, while) and ‘cyclomatic complexity’ (a measure of the possible paths through a piece of code). While none of this information necessarily indicates the presence of errors, some people believe that high values indicate code complexity which might be taken as a rough indicator either of inefficiency or opaqueness – though that, it has to be said, is open to interpretation!

Overall, CodeHealer does a pretty thorough job of analysing Delphi projects and reporting on errors, inefficiencies and redundancies. Currently restricted to analysing Object Pascal programs targeted at Win32, it will be even more useful when it is updated for Delphi .NET projects (which is promised) or indeed for other languages such as C# (which, while not promised, we can, at least, hope for).

In brief, CodeHealer is not likely to appeal to amateur coders, but for anyone developing commercial quality software using Delphi, it would be an extremely valuable tool.

 

Huw Collingbourne

May 2006

 


Home | Archives | Contacts

Copyright © 2006 Dark Neon Ltd. :: not to be reproduced without permission