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

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

考虑下面的代码:

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.

Delphi编译器给出警告“[DCC提示] Project1.dpr(6):H2219专用符号'Method1'声明但从未使用过”,这非常有帮助。 但是,我希望对此代码还有其他一些问题需要警告:

  • Method4从未被使用过,但我没有收到警告,因为它是公开的。
  • Method2是公开的,但只能私下使用。
  • 有什么工具可以用来识别这些问题吗?


    帕斯卡分析仪可以做到这一点,更多的情况。


    来自Peganza和/或CodeHealer的PAL可能可以帮助您。

    链接地址: http://www.djcxy.com/p/54379.html

    上一篇: How do I identify the lowest required visibility of methods?

    下一篇: IIS 7 unable to load DLL (Access Denied)