{"title":"The code analysis tool","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/devenv-using-code-analysis-tool/","by":"JOP-AL","license":"Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-using-code-analysis-tool, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact.","credit":"Microsoft Corporation, CC BY 4.0","origin":"https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-using-code-analysis-tool","source":{"name":"Business Central developer and IT pro docs","repo":"https://github.com/MicrosoftDocs/dynamics365smb-devitpro-pb","commit":"828b6ee72fcd75755627cd6011f3d20899217ab2","date":"2026-11-19"},"checked":"2026-11-19","description":"Using static code analysis tool on an AL project.","date":"2026-08-25","meta":{"topic":"how-to"},"outline":[{"level":2,"title":"Enable the code analysis","slug":"enable-the-code-analysis","at":425,"chars":1132},{"level":2,"title":"Add your own code to the project","slug":"add-your-own-code-to-the-project","at":1557,"chars":563},{"level":2,"title":"View the results of the code analysis","slug":"view-the-results-of-the-code-analysis","at":2120,"chars":632},{"level":2,"title":"Code analyzers","slug":"code-analyzers","at":2752,"chars":1607},{"level":2,"title":"Enable code analysis on large projects","slug":"enable-code-analysis-on-large-projects","at":4359,"chars":199},{"level":2,"title":"Related information","slug":"related-information","at":4558,"chars":294}],"text":"This article shows you how to use static code analysis tool on an AL project from within Visual Studio Code. The code analysis tool is a feature of the AL Language extension for Microsoft Dynamics 365 Business Central for Visual Studio Code that helps you to write better code by analyzing your code for potential issues. The tool runs in the background and provides warnings and errors in the code editor as you write code.\n## Enable the code analysis\nFollow these steps to create a basic project in AL.\n1. Select Alt+ A, Alt+L to create a new project.\n2. Open the Command Palette Ctrl+Shift+P and choose either User Settings or Workspace Settings.\n3. Under Extensions, go to Al Language extension configuration. When you scroll down, you find Code Analyzers section, choose Edit in settings.json.\n4. Set the al.enableCodeAnalysis in the settings file to true. <br> `\"al.enableCodeAnalysis\": true`\n5. In the al.codeanalyzers setting, use Ctrl+Space to pick from the available code analyzers. Separate the list of code analyzers with commas. For more information about the available analyzers, see analyzers/appsourcecop, analyzers/codecop, analyzers/pertenantextensioncop, and analyzers/uicop.\nAt this point, the selected analyzers run on your project. Next, add some code to the project that will, in the following example, be used to demonstrate a violation of the AA0001 \"There must be exactly one space character on each side of a binary operator such as := + - AND OR =.\" code analysis rule.\n> NOTE\n> By default, code analysis runs in the background.\n## Add your own code to the project\nIn the Visual Studio Code Explorer, open the HelloWorld.al file and replace the existing code with the following code:\n```al\npageextension 50100 CustomerListExt extends \"Customer List\"\n{\n    trigger OnOpenPage();\n    var\n        result: Integer;\n    begin\n        // The following line will trigger the warning\n        // AA0001 \"There must be exactly one space character on each side\n        // of a binary operator such as := + - AND OR =.\"\n        result := 2+2;\n        Message('2 + 2 = ' + Format(result));\n    end;\n}\n```\n## View the results of the code analysis\nThe code analysis tools run in the background. You see the faulty expression underlined and the warning \"There must be exactly one space character on each side of '+'.\" display if you move cursor over the underlined code. You can also view the list of issues by selecting the View tab of Visual Studio Code and choosing the Problems option.\nUsing the Ctrl+Shift+B shortcut to build your project runs the code analysis tools on the entire project and the detected issues display in the Output window of Visual Studio Code. Learn more about AL keyboard shortcuts in devenv-keyboard-shortcuts.\n## Code analyzers\nA code analyzer is a library that builds on the compiler's functionality to offer enhanced analysis of the syntax and semantics of your code at build time. The AL Language extension for Microsoft Dynamics 365 Business Central for Visual Studio Code contains four analyzers:\n CodeCop is an analyzer that enforces the official AL Coding Guidelines. For more information about the CodeCop rules, see CodeCop Analyzer Rules<analyzers/codecop>.\n PerTenantExtensionCop is an analyzer that enforces rules that must be respected by extensions meant to be installed for individual tenants. For more information about the PerTenantExtensionCop rules, see PerTenantExtensionCop Analyzer Rules<analyzers/pertenantextensioncop>.\n AppSourceCop is an analyzer that enforces rules that must be respected by extensions meant to be published to Microsoft Marketplace. For more information about the AppSourceCop rules, see AppSourceCop Analyzer Rules<analyzers/appsourcecop>.\n UICop is an analyzer that enforces rules that must be respected by extensions that are meant to customize the web client. For more information about the UserInterfaceCop rules, see UICop Analyzer Rules<analyzers/uicop>.\n> IMPORTANT\n> Starting with Business Central 2026 release wave 2, the AL Language extension deploys its included analyzer assemblies directly in the extension's bin folder. If custom tooling loads these assemblies by path, update it to use bin instead of the previous `bin/Analyzers` folder. This change doesn't affect analyzer names such as `${CodeCop}` and `${AppSourceCop}` in the al.codeAnalyzers setting.\n## Enable code analysis on large projects\nTo improve performance while running code analysis on large projects, you can follow the performance tips in devenv-code-analysis-performance-configuration.\n## Related information\ndevenv-using-code-analysis-tool-with-rule-set\ndevenv-rule-set-syntax-for-code-analysis-tools\nDevelopment in AL<devenv-dev-overview>\ndirectives/devenv-directives-in-al\nDebugging in AL<devenv-debugging>\nAL Language Extension configuration<devenv-al-extension-configuration>"}