AL icon indicating copy to clipboard operation
AL copied to clipboard

Code fix for AL0606 warning is overdoing it

Open gntpet opened this issue 2 years ago • 0 comments

When applying code fix action for implicit with warning (AL0606), action is overdoing it for SETRANGE statements. There is no need to use epxlict table name in the first param for SETRANGE statement. It makes code unreadable.

The same applies to more AL statements: setfilter, setuccrentkey, calcfields

For e.g.

    local procedure FilterFields(var DataExportRecField: Record "Data Export Record Field"; DataExportRecordSource: Record "Data Export Record Source")
    begin
        with DataExportRecField do begin
            SETRANGE("Data Export Code", DataExportRecordSource."Data Export Code");
            SETRANGE("Data Exp. Rec. Type Code", DataExportRecordSource."Data Exp. Rec. Type Code");
            SETRANGE("Table No.", DataExportRecordSource."Table No.");
            SETRANGE("Source Line No.", DataExportRecordSource."Line No.");
        end;
    end;

becomes like this:

    local procedure FilterFields(var DataExportRecField: Record "Data Export Record Field"; DataExportRecordSource: Record "Data Export Record Source")
    begin
        DataExportRecField.SETRANGE(DataExportRecField."Data Export Code", DataExportRecordSource."Data Export Code");
        DataExportRecField.SETRANGE(DataExportRecField."Data Exp. Rec. Type Code", DataExportRecordSource."Data Exp. Rec. Type Code");
        DataExportRecField.SETRANGE(DataExportRecField."Table No.", DataExportRecordSource."Table No.");
        DataExportRecField.SETRANGE(DataExportRecField."Source Line No.", DataExportRecordSource."Line No.");
    end;

expected result is:

    local procedure FilterFields(var DataExportRecField: Record "Data Export Record Field"; DataExportRecordSource: Record "Data Export Record Source")
    begin
        DataExportRecField.SETRANGE("Data Export Code", DataExportRecordSource."Data Export Code");
        DataExportRecField.SETRANGE("Data Exp. Rec. Type Code", DataExportRecordSource."Data Exp. Rec. Type Code");
        DataExportRecField.SETRANGE("Table No.", DataExportRecordSource."Table No.");
        DataExportRecField.SETRANGE("Source Line No.", DataExportRecordSource."Line No.");
    end;

Best Regards, Gintautas

gntpet avatar Oct 13 '22 05:10 gntpet