views:

411

answers:

5

Are there good tools to detect dead code in DELPHI2007 or above? That can integrate with the IDE? The option to look at blue dots is just time consuming, so it’s ruled out.

+5  A: 

I don't know a better way to detect dead code (Delphi does a fairly good job itself?!). But if you want to optimize functions and procedures and look for bottlenecks and leaks, then AQtime may be a good tool or the less complex and free SamplingProfiler and GpProfile can give you some kind of help.

Sorry, this is not a answer on code cleanup. But it maybe can be of some help anyway!

Tool
+6  A: 

Peganza's Pascal Analyzer has a code reduction report that might help.

Tim Sullivan
+8  A: 

Not only is looking at the blue dots time-consuming, it doesn't work very well. The blue dots disappear only next to code which definitely cannot be invoked. They don't disappear next to code which is not, in fact, invoked, but could be invoked, perhaps in some non-obvious way. Virtual methods can be invoked by indirect references in code; the compiler doesn't see the address of the jump.

AQtime does have a code coverage profiler. It works well, but only in the context of a particular application session. However, you could combine AQtime's coverage analysis with TestComplete's automated test execution to get coverage analysis over the execution of your entire regression series.

Even then, however, some human intelligence is going to be required. There is simply not a foolproof and entirely automated way to do this, and, given that published methods can be invoked via reflection (you could store the name of the class and method as strings in the database, and no compiler/static analyzer would ever see it), there can never be such a way.

Craig Stuntz
To invoke a method by name, a method needs to be *published*, not necessarily *virtual*. Most event handlers are non-virtual, and yet they're the primary use case for fetching methods' addresses by name (loading a DFM and hooking up event properties).
Rob Kennedy
Yes, Rob, I agree. The virtual part is important WRT the question insofar as the compiler can't directly look at jump addresses to find covered code. I'll clarify the reply.
Craig Stuntz
+5  A: 

It doesn't integrate into the IDE, but CodeHealer warns you about unreachable code.

Bruce McGee
+2  A: 

cnWizards (a free Delphi IDE Expert collection) contains a tool which removes unused units in the uses list. I used it on a large project and it boosted the compile/link time almost by 10%.

http://www.cnpack.org/

mjustin
It made your project compile faster? How could you tell? ;)
Mason Wheeler
Don't know, after installing the wizards, it just felt like 10% ;)
mjustin