org.sonar.l10n.delphi.rules.community-delphi.ProjectFileVariable.html Maven / Gradle / Ivy
The newest version!
Why is this an issue?
The Delphi project file (.dpr) contains the initialization logic for the program. It is
partially generated by the IDE, is generally abstracted over by the .dproj file, and is
underemphasized in editor tooling.
Use of the project file for complex logic bloats the application entry point, makes the project
more difficult to navigate, and reduces visibility.
How to fix it
Move any complex logic into a routine in a separate unit, which you can then reference from the
initialization section of the project file:
// MyProject.dpr
// ...
var
MyVar: string;
begin
MyVar := Readln;
Writeln(MyVar);
end.
// MyProject.dpr
// ...
uses MyUnit;
begin
Foo;
end.
// MyUnit.pas
interface
procedure Foo;
implementation
procedure Foo;
var
MyVar: string;
begin
MyVar := Readln;
Writeln(MyVar);
end;
© 2015 - 2024 Weber Informatics LLC | Privacy Policy