AL icon indicating copy to clipboard operation
AL copied to clipboard

Rule AA0150 triggers false positives for nested calls

Open hemisphera opened this issue 2 years ago • 0 comments

1. Describe the bug The CodeCop rule AA0150 generates false positives if the parameter that was declared by var is not actually used in the method call itself, but passed along to a second method that has this parameter also declared by var.

While it is true that the method itself does not change the value of that parameter, it might get changed by the second method call, there's no way of knowing. In this case the rule should not trigger.

This scenario happens a lot when an event is declared with a var-parameter and also a utility method is declared to do nothing more than raise that event.

2. To Reproduce See the code example below

local procedure RaiseSomeEvent(var theParameterOvHell: Integer)
begin
  OnSomeEvent(theParameterOvHell); // falsely triggers AA0150
end;

[IntegrationEvent(false, false)]
local procedure OnSomeEvent(var theParameterOvHell: Integer)
begin
end;

3. Expected behavior AA0150 should not rigger.

4. Actual behavior AA0150 riggers.

5. Versions:

  • AL Language: v12.0.849798
  • Visual Studio Code: 1.81.1
  • Business Central: n/a
  • List of Visual Studio Code extensions that you have installed: n/a

hemisphera avatar Aug 24 '23 07:08 hemisphera