org.sonar.l10n.delphi.rules.community-delphi.TooManyNestedRoutines.html Maven / Gradle / Ivy
Why is this an issue?
Routines with many nested routines make for code that is difficult to navigate and understand.
While nested routines can be helpful for small units of work specific to a particular routine,
their easily missed syntax and non-linear control flow make them confusing when containing large
amounts of functionality.
How to fix it
Consider if the nested routines can be inlined to the body of the main routine:
procedure DoThing;
procedure DoSubThing;
begin
Log('Hello!');
end;
// ...
begin
DoSubThing;
// ...
end;
procedure DoThing;
begin
Log('Hello');
// ...
end;
Otherwise, extract the nested routines out into one or more independent routine:
procedure DoThing;
procedure DoSubThing;
begin
// ...
end;
// ...
begin
// ...
end;
procedure DoSubThing;
begin
// ...
end;
procedure DoThing;
begin
// ...
end;
© 2015 - 2024 Weber Informatics LLC | Privacy Policy