Warn about insufficient/invalid arguments in a call to the built-in GET procedure #85
Replies: 3 comments
-
@rvanbekkum I get new AL0697 warnings in our pipelines when targeting NextMajor
|
Beta Was this translation helpful? Give feedback.
-
Test cases for this rule: local procedure TestRecordGetLocalVariable()
var
ItemVariant: Record "Item Variant";
begin
// Warning
ItemVariant.Get('10000');
end;
local procedure TestRecordGetLocalVariableNoWarning()
var
ItemVariant: Record "Item Variant";
begin
// NO warning
ItemVariant.Get('10000', 'VARIANTCODE');
end;
local procedure TestRecordGetParameter(var ItemVariant: Record "Item Variant")
begin
// Warning
ItemVariant.Get('10000');
end;
local procedure TestRecordGetReturnValue() ItemVariant: Record "Item Variant"
begin
// Warning
ItemVariant.Get('10000');
end;
local procedure TestRecordGetMethod()
begin
// Warning
TestRecordGetReturnValue().Get('10000');
end;
local procedure TestRecordGetReportDataItem()
begin
// Warning
InvLineDataItem.Get('10000');
end;
local procedure TestRecordGetXmlPortTableElement()
begin
// Warning
InvLineXmlPortTableElement.Get('10000');
end;
local procedure TestRecordGetSetupTableNoArgumentsProvided()
var
CompanyInformation: Record "Company Information";
begin
// NO warning
CompanyInformation.Get();
end;
local procedure TestRecordGetSetupTableCorrectArgumentsProvided()
var
CompanyInformation: Record "Company Information";
begin
// NO warning
CompanyInformation.Get('');
end;
local procedure TestRecordGetSetupTableIncorrectArgumentsProvided()
var
CompanyInformation: Record "Company Information";
begin
// Warning
CompanyInformation.Get('', 12345);
end;
local procedure TestRecordGetLocalVariableRecordID()
var
ItemVariant: Record "Item Variant";
MyRecordId: RecordId;
begin
// NO warning
ItemVariant.Get(MyRecordId);
end;
local procedure TestRecordGetParameterRecordID(MyRecordId: RecordId)
var
ItemVariant: Record "Item Variant";
begin
// NO warning
ItemVariant.Get(MyRecordId);
end;
local procedure TestRecordGetReturnValueRecordID() MyRecordId: RecordId
var
ItemVariant: Record "Item Variant";
begin
// NO warning
ItemVariant.Get(MyRecordId);
end;
local procedure TestRecordGetMethodRecordID()
var
ItemVariant: Record "Item Variant";
begin
// NO warning
ItemVariant.Get(TestRecordGetReturnValueRecordID());
end;
local procedure TestRecordGetBuiltInMethodRecordID()
var
ItemVariant: Record "Item Variant";
begin
// NO warning
ItemVariant.Get(ItemVariant.RecordId());
end;
local procedure TestRecordGetFieldRecordID()
var
ApprovalEntry: Record "Approval Entry";
begin
// NO warning
ApprovalEntry.Get(ApprovalEntry."Record ID to Approve");
end; |
Beta Was this translation helpful? Give feedback.
-
In the (pre)release v0.31.4 version of the LinterCop this is handled by two rules;
The LC0051 supports additional scenario's like for example, where the parameter is composition of possible multiple variables. procedure MyProcedure()
var
SalesHeader: Record "Sales Header";
Prefix: Code[5];
DocumentNo: Code[20];
begin
SalesHeader.Get("Sales Document Type"::Order, StrSubstNo(Prefix, DocumentNo));
end; |
Beta Was this translation helpful? Give feedback.
-
Copied from: https://experience.dynamics.com/ideas/idea/?ideaid=0e3cebdf-d36f-e911-80e7-0003ff68bfb9 (please vote here as well, if you want to see this in the AL compiler)
Also reported on GitHub by @fvet: microsoft/AL#4622
I think this one has chances to make it into the AL Language extension, but I wanted to file it as an idea here as well, although it might not be as trivial to implement.
Beta Was this translation helpful? Give feedback.
All reactions