As part of a large refactoring project, I need to identify methods that are no longer used, or where the 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 Hint] Project1.dpr(6): H2219 Private symbol 'Method1' declared but never used", which is very helpful. But there are other issues with this code that I would like to be warned about:
Are there any tools I can use to identify issues like these?
Pascal Analyzer can do it and much more cases.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With