StefanMaron / BusinessCentral.LinterCop

Community driven code linter for AL (MS Dynamics 365 Business Central)
https://stefanmaron.com
MIT License
76 stars 31 forks source link

LC0069: False positive for empty if-statements #803

Closed cegekaJG closed 3 days ago

cegekaJG commented 3 days ago

LC0069 currently triggers on if-statements that are immediately terminated with a semicolon. For example:

if SalesHeader.FindFirst() then;

This is a very common method to capture output and avoid unwanted errors, so this shouldn't count as a violation.

StefanMaron commented 3 days ago

I agree that this is very commonly used.

However, as a code reviewer I would probably still wonder why you did not do something along those lines:

if not SalesHeader.FindFirst() then
    Clear(SalesHeader);
if not SalesHeader.FindFirst() then
    exit;
if not SalesHeader.FindFirst() then
    // Maybe create new record

So the rule stays valid in my opinition, asking you to add a comment to explain why exaclty you need this type of if syntax.