microsoft / AL

Home of the Dynamics 365 Business Central AL Language extension for Visual Studio Code. Used to track issues regarding the latest version of the AL compiler and developer tools available in the Visual Studio Code Marketplace or as part of the AL Developer Preview builds for Dynamics 365 Business Central.
MIT License
744 stars 245 forks source link

AA0175 does not mark multiple Finds #6353

Closed JulianSchmidtkeGWS closed 2 years ago

JulianSchmidtkeGWS commented 3 years ago

Describe the bug When you activate CodeCop with Rule AA0175 all positions where a record is fetched from the database but not used should be found. When you call multiple finds in a row, or with a Reset() inbetween, only the last find is marked as an error.

To Reproduce Steps and to reproduce the behavior:

  1. Create A Function with a local Record Variable (e.g. User)
  2. Enable CodeCop Rule AA0175
  3. Call FindSet(First/Last/...) multiple times
  4. Only the last one is shown as an error

AL Code to reproduce the issue

    procedure AA00175()
    var
        User: Record User;
    begin
        User.FindFirst(); // Should be marked
        User.FindFirst(); // Only this is marked
    end;
    procedure AA00175()
    var
        User: Record User;
    begin
        User.FindFirst(); // Should be marked
        User.Reset();
        User.FindFirst(); // Only this is marked
    end;

In this code no error is thrown, even though the first FindFirst is not necessary

    procedure AA00175()
    var
        User: Record User;
    begin
        User.FindFirst(); // Should be marked
        User.FindFirst();
        Message(User."User Name");
    end;

Expected behavior Every Find Function that is not necessary should be highlighted. It should not matter if you fetch it again later without reading it inbetween.

Screenshots image

5. Versions:

Also #6138 and #5727 are problems i encountered again.

github-actions[bot] commented 2 years ago

Hi,

Many thanks for raising this issue. Unfortunately we have not been able to get to this issue as soon as we'd have liked. Since it has been a long time since this issue was last updated, it is possible that this has been fixed by a newer release of Business Central and the AL extension for Visual Studio Code. We have thus decided to close it.

If the issue still affects you on the latest insider build of Business Central, please help us and open a new issue for us with the latest steps to reproduce the issue, and link back to this closed issue to track any comments or discussions.

Thanks,
Thaddeus