LC0024 - StefanMaron/BusinessCentral.LinterCop GitHub Wiki

Procedure declaration should not end with semicolon.

We're all about keeping things consistent. When it comes to a procedure's signature, whether you slap a semicolon at the end or not, the compiler doesn't care. This warning has been introduced primarily to enforce consistency in code style rather than to drive substantial development improvements. However, with this rule we can have a coding guideline to consistently exclude semicolons at the end of procedure declarations.

Example

procedure MyProcedure(); /* <-- that ; (semicolon) should not be there */
begin

end;

Code transformation command

image

Remove procedures semicolon from the Active Editor: removes the semicolon at the end of a procedure declaration in the current editor
Remove procedures semicolon from the Active Project: removes the semicolon at the end of a procedure declaration in the current project

The AZ AL Dev Tools/AL Code Outline extension by Andrzej Zwierzchowski has created an code transformation command to easily resolve these.

Why

We'll have to go all-the-way back to the C/SIDE Introduction in Microsoft Dynamics NAV 2009

A semicolon (statement separator) suggests that a new statement is coming up.

And if we even go further back, on the C/SIDE Application Designer's Guide, dated 1996, we find:

A common error for the C/AL newcomers is to put an extraneous semicolon at the end of a line before an ELSE. As mentioned above, this is not valid according to the syntax of C/AL, as the semicolon is used as a statement separator.

So based on the documentation, syntactically the ";" is not something that ends a statement in (Pasc)AL, but it actually is a separator symbol to separate statements. That's why procedure declaration should not end with semicolon and also the reason why you can omit it for the last statement.

VS Code Find and Replace

In stead of the Code Action above, you can also use the Find and Replace function of VS Code to remove the semicolon in bulk.

image

Open the Find and Replace for all files with (Ctrl + Shift + H) and Search with the regex ((.*)procedure(.*)\((.*)\)(.*))([;]$). Use the $1 for the value Replace in the Find and Replace Window.

Note: Make sure the Use Regular Expression button (Alt + R) is enabled.