AL icon indicating copy to clipboard operation
AL copied to clipboard

AA0228 (Local Method is declared but never used) is not raised in "reportextension" objects

Open rvanbekkum opened this issue 2 years ago • 0 comments

1. Describe the bug Warning AA0228 is not raised for local procedures in reportextension objects.

2. To Reproduce Steps to reproduce the behavior:

  1. Have the following code and see that the code analyzer warning is not raised for this case:
reportextension 50000 WSB_AccountScheduleSYS extends "Account Schedule"
{
    dataset
    {
    }

    local procedure MyLocalProcedure() // Warning AA0228 is not raised even though the procedure is unused
    begin

    end;
}

Investigated: I suspect the following code in Microsoft.Dynamics.Nav.CodeCop.Design.Rule228DoNotDeclareUnusedLocalMethods

private static readonly SyntaxKind[] objectSyntaxKinds = new SyntaxKind[8]
{
	SyntaxKind.CodeunitObject,
	SyntaxKind.PageObject,
	SyntaxKind.PageExtensionObject,
	SyntaxKind.ReportObject,
	SyntaxKind.TableObject,
	SyntaxKind.TableExtensionObject,
	SyntaxKind.XmlPortObject,
	SyntaxKind.QueryObject
};

should be changed to:

private static readonly SyntaxKind[] objectSyntaxKinds = new SyntaxKind[9]
{
	SyntaxKind.CodeunitObject,
	SyntaxKind.PageObject,
	SyntaxKind.PageExtensionObject,
	SyntaxKind.ReportObject,
	SyntaxKind.ReportExtensionObject,
	SyntaxKind.TableObject,
	SyntaxKind.TableExtensionObject,
	SyntaxKind.XmlPortObject,
	SyntaxKind.QueryObject
};

3. Expected behavior AA0228 is raised for local procedures in reportextension objects.

4. Actual behavior AA0228 is NOT raised for local procedures in reportextension objects.

5. Versions:

  • AL Language: 10.0.674969
  • Visual Studio Code: 1.71.0
  • Business Central: N.A.
  • List of Visual Studio Code extensions that you have installed: N.A.

Final Checklist

Please remember to do the following:

  • [x] Search the issue repository to ensure you are reporting a new issue

  • [x] Reproduce the issue after disabling all extensions except the AL Language extension

  • [x] Simplify your code around the issue to better isolate the problem

rvanbekkum avatar Sep 09 '22 11:09 rvanbekkum