如何确定方法所需的最低可见性?

Sve*_*sli 7 delphi refactoring

作为大型重构项目的一部分,我需要确定不再使用的方法,或者可以降低可见性的方法.

请考虑以下代码:

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.
Run Code Online (Sandbox Code Playgroud)

Delphi编译器发出警告"[DCC Hint] Project1.dpr(6):H2219私有符号'Method1'声明但从未使用过",这非常有用.但是我希望警告此代码还有其他问题:

  1. 方法4从未使用过,但我没有得到警告,因为它是公开的.
  2. Method2声明为public,但仅用于私有.

我可以使用任何工具来识别这些问题吗?

The*_*rse 3

Pascal 分析器可以做到这一点以及更多的情况。