Redundant record parameter in method call (LC0096)

When a method is invoked on a record variable and the same variable is also passed as an argument, the parameter is redundant. Inside a table, page, or extension the same applies to the implicit Rec variable: calling a sibling method and passing Rec as an argument is unnecessary because the method already operates on the same record.

Removing the redundant parameter (and the corresponding parameter definition) simplifies code and avoids confusion about which copy of the record is being used.

Example: external call

The following code passes Customer to a method that is already invoked on Customer:

codeunit 50100 MyCodeunit
{
    procedure MyProcedure()
    var
        Customer: Record Customer;
    begin
        Customer.DoSomething(Customer);
    end;
}

To fix this, remove the redundant parameter and update the method signature:

codeunit 50100 MyCodeunit
{
    procedure MyProcedure()
    var
        Customer: Record Customer;
    begin
        Customer.DoSomething();
    end;
}

Example: internal call

The following code inside a table passes Rec to a sibling method:

table 50100 MyTable
{
    fields
    {
        field(1; Name; Text[100]) { }
    }

    procedure Validate()
    begin
        DoSomething(Rec);
    end;

    procedure DoSomething(var MyTable: Record MyTable)
    begin
    end;
}

To fix this, remove the parameter:

table 50100 MyTable
{
    fields
    {
        field(1; Name; Text[100]) { }
    }

    procedure Validate()
    begin
        DoSomething();
    end;

    procedure DoSomething()
    begin
    end;
}

When the rule does not trigger

The rule suppresses the diagnostic when any of the following conditions apply:

  • The argument is a different variable than the instance (e.g. Customer.DoSomething(Customer2))
  • The argument is a field access expression (e.g. Customer.DoSomething(Customer."No."))
  • The target method is an event publisher (passing Rec to events is idiomatic AL)
  • The target method is a built-in method (e.g. Clear, Page.RunModal)
  • The target method is defined in a different module (the developer cannot refactor external signatures)
  • Inside a page or page extension, the target method is not local (public/internal methods that accept the source record are considered intentional API design for decoupling and testability)

Migration from BusinessCentral.LinterCop

This rule replaces LC0094 from BusinessCentral.LinterCop . Key differences:

AspectBC.LinterCop LC0094ALCops LC0096
ScopeTables onlyTables, pages, table extensions, page extensions
Page methodsN/AOnly local methods flagged (public/internal are intentional API design)
Module restrictionString-based module name comparisonObject identity comparison
Rec matchingString comparison against "Rec"Symbol identity resolution

See also