Joe White’s Blog

Life, .NET, and Cats


Finding unused parameters in Delphi

Yesterday at work, I was looking at a method that had about fourteen parameters, and I wasn’t sure whether it used all of them. The compiler doesn’t warn on unused parameters (nor should it; just about every GUI event handler would warn about the unused Sender parameter!), and I didn’t want to manually search through the code to see if each parameter was used.

Then I got a bright idea: use SyncEdit. Highlight the entire method (including the declaration — everything from “procedure” to “end;”) and hit Ctrl+Shift+J. If an identifier shows up more than once in the selection, it now shows up with either an underline or a box around it (except for the one with the cursor in it).

Then just skim the parameter list. If there are any parameter names that don’t have an underline, a box, or a cursor, then those parameters are unused and can be deleted. Sweet!

There are no responses to “Finding unused parameters in Delphi” yet.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>


Joe White's Blog copyright © 2004-2008. Portions of the site layout use Yahoo! YUI Reset, Fonts, and Grids.
Proudly powered by WordPress. Entries (RSS) and Comments (RSS).