Skip to content

[Bug]: AC0031 and AC0032 are contradictory for table permissions  #295

Description

@ralf-escher

Analyzer

ApplicationCop
AL version: BC 28
ALCop version: 0.8.3

Issue type

False positive (diagnostic fires when it shouldn't)

Rule ID

AC0031 and AC0032

Description

AC0031 and AC0032 are contradictory for table permissions that are required at runtime but not directly visible to the static analyzer. Declaring the permission triggers AC0032; removing it triggers AC0031. There is no way to satisfy both rules simultaneously without a #pragma suppression.

To reproduce

Consider a codeunit that receives a Record "Posted Whse. Shipment Line" as a parameter and reads a field from it:

With the permission declared: AC0032 fires — "Permission 'tabledata Posted Whse. Shipment Line' is declared but this object performs no database operations on table 'Posted Whse. Shipment Line'."
With the permission removed: AC0031 fires — "Permission for table 'Posted Whse. Shipment Line' is missing."
Expected behavior

Passing a record as a parameter and accessing its fields constitutes a read operation. AC0031/AC0032 should recognise record parameters as an implicit = R usage and not flag the permission as unused.

Actual behavior

Both AC0031 and AC0032 fire depending on whether the permission is declared or not. The only escape is:

#pragma warning disable AC0032
tabledata "Posted Whse. Shipment Line" = R,   // needed at runtime via record parameter
#pragma warning restore AC0032

Additional context

This also occurs for permissions required through:

Event subscriber parameters carrying a record variable
Indirect calls where the record is passed through a chain of local procedures

AL code to reproduce

{
    Permissions =
        tabledata "Posted Whse. Shipment Line" = R;  // AC0032 fires here

    procedure DoSomething(ShipmentLine: Record "Posted Whse. Shipment Line")
    begin
        // Reading a field value — no explicit Get/FindSet/FindFirst call
        if ShipmentLine."No." <> '' then
            DoWork(ShipmentLine."No.");
    end;
}

Additional context

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions