Finding unused (aka “dead”) code in Delphi

后端 未结 8 2151
忘掉有多难
忘掉有多难 2021-01-01 23:51

Are there any tools that can determine if a function/procedure/method/entire class is used?

I\'ve seen tools that can help a knowledgeable developer track down unus

相关标签:
8条回答
  • 2021-01-02 00:27

    Checkout the tools at http://www.peganza.com/ to help with some of your tasks.

    Icarus is freeware and it analyzes your 'uses' clauses to allow you to remove unused references.

    Pascal Analyzer is the full version which includes Icarus functionality and a ton of other tools.

    0 讨论(0)
  • 2021-01-02 00:29

    For units, use Pascal Analyzer. You might need to use it a multiple of times.

    For objects/classes that are registered in class factories (and the like), you will need to double check manually, as they will be fully compiled in. The reason for this is that the compiler doesn't know if you actually use them or not.

    For methods, you need to check for the blue dots. Not very practical, so there is another way (from what I have been told when I investigate the same topic). You need to do a full build with a detailed map file enabled. Once that is done, you need to compare the source to see if there is an entry in the map file. If not, then the code is not compiled in - possibly dead code (possibly because if it is component, then it might be that you don't use that functionality).

    0 讨论(0)
提交回复
热议问题