As part of a large refactoring project, I need to identify methods that are no longer in use or where visibility can be reduced.
Consider the following code:
program Project1; type TMyClass = class(TObject) private function Method1 : integer; public function Method2 : integer; function Method3 : integer; function Method4 : integer; end; var vMyObject : TMyClass; function TMyClass.Method1: integer; begin Result := Method2; end; function TMyClass.Method2: integer; begin Result := 2; end; function TMyClass.Method3: integer; begin Result := 3; end; function TMyClass.Method4: integer; begin Result := 4; end; begin vMyObject := TMyClass.Create; try writeln(vMyObject.Method3); finally vMyObject.Free; end; end.
The Delphi compiler gives the warning "[DCC Board] Project1.dpr (6): H2219 The private symbol" Method1 "is declared but not used", which is very useful. But there are other problems with this code that I would like to warn about:
- Method4 is never used, but I do not get a warning, as it is publicly available.
- Method2 is declared public, but is used only privately.
Are there any tools that I can use to identify such problems?
Svein bringsli
source share