All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sonar.l10n.delphi.rules.community-delphi.MemberDeclarationOrder.html Maven / Gradle / Ivy

There is a newer version: 1.12.1
Show newest version

Why is this an issue?

For clarity and consistency, visibility sections within the body of a class, interface, or record declaration should be organized in the following order:

  1. Field declarations
  2. Routine declarations
  3. Property declarations

The Delphi compiler also forbids field declarations from appearing after routine or property declarations in the same visibility section.

How to fix it

Reorder the offending visibility section into fields, then routines, then properties:

type
  TMyType = class(TObject)
  private
    FMyVar: Integer;
    property MyVar: Integer read FMyVar;
    procedure DoThing;
    procedure DoAnotherThing;
    property MyOtherVar: Integer read FMyVar;
  end;
type
  TMyType = class(TObject)
  private
    FMyVar: Integer;
    procedure DoThing;
    procedure DoAnotherThing;
    property MyVar: Integer read FMyVar;
    property MyOtherVar: Integer read FMyVar;
  end;

Resources





© 2015 - 2024 Weber Informatics LLC | Privacy Policy