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

LC0068 - false positive with IndirectPermissions #750

Closed jwikman closed 2 months ago

jwikman commented 2 months ago

The following code triggers LC0068 on the Insert() statement.

    [InherentPermissions(PermissionObjectType::TableData, Database::MyTable, 'I')]
    procedure InsertSomeData()
    var
        MyTable: Record MyTable;
    begin
        MyTable.Init();
        MyTable.MyField := 1;
        MyTable.Insert(true);
    end;

And this correctly removes LC0068

    [InherentPermissions(PermissionObjectType::TableData, Database::MyTable, 'i')]
    procedure InsertSomeData()
    var
        MyTable: Record MyTable;
    begin
        MyTable.Init();
        MyTable.MyField := 1;
        MyTable.Insert(true);
    end;

But I believe that LC0068 should not be fired in the first case either, since no permissions are needed for the user to run this piece of code.

The same applies to the InherentPermissions R, M and D vs. r, m and d.

StefanMaron commented 2 months ago

This should be fixed now in the latest pre-release

jwikman commented 2 months ago

Seems to work, thanks!