{"title":"Using the code analysis tools with the ruleset","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/devenv-using-code-analysis-tool-with-rule-set/","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-with-rule-set, 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-with-rule-set","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":"Configuring and using a custom ruleset on an AL project.","date":"2023-03-07","meta":{"topic":"how-to"},"outline":[{"level":2,"title":"Use rulesets with code analysis","slug":"use-rulesets-with-code-analysis","at":225,"chars":1117},{"level":2,"title":"Add your own code to the project","slug":"add-your-own-code-to-the-project","at":1342,"chars":838},{"level":2,"title":"Create and customize a ruleset","slug":"create-and-customize-a-ruleset","at":2180,"chars":1032},{"level":2,"title":"Running the code analysis","slug":"running-the-code-analysis","at":3212,"chars":393},{"level":2,"title":"Limitations","slug":"limitations","at":3605,"chars":385},{"level":2,"title":"Related information","slug":"related-information","at":3990,"chars":280}],"text":"This article helps you to customize a ruleset for the severity of diagnostics produced by the code analysis tools that are part of the AL Language extension for Microsoft Dynamics 365 Business Central for Visual Studio Code.\n## Use rulesets with code analysis\nFirst, create a basic project in AL by following the steps below:\n1. Select Alt+A, Alt+L to create a new project.\n2. Open the Command Palette by using the Ctrl+Shift+P shortcut and choose either User Settings or Workspace Settings.\n3. Under Extensions, go to Al Language extension configuration. When you scroll down, you'll 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 violations 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## 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```\nOn the View tab of Visual Studio Code, select the Problems option and you'll see a warning with the message \"There must be exactly one space character on each side of '+'.\". In this case, the problem can be fixed by running the AL Formatter command. See devenv-al-formatter.\n## Create and customize a ruleset\nTo create and customize a ruleset of your own, follow the next steps:\n1. On the File tab in Visual Studio Code, choose New File.\n2. Save the empty file with a name, for example `<name>.ruleset.json` and make a note of the file path.\n3. Add the following code to the `<name>.ruleset.json` file:\n ```json\n {\n     \"name\": \"My Custom ruleset\",\n     \"rules\": [\n         {\n             \"id\": \"AA0001\",\n             \"action\": \"None\"\n         }\n     ]\n }\n ```\n4. In your project settings, set Rule Set Path to the path of the `<name>.ruleset.json` file, relative to the project root. For more information about custom rules, see devenv-rule-set-syntax-for-code-analysis-tools.\n> NOTE\n> Use the truleset and trule snippets provided by the AL Language extension for Microsoft Dynamics 365 Business Central to create your ruleset. The ruleset will be applied to all the analyzers enabled for the current project. For more information about selectively enabling analyzers, see devenv-using-code-analysis-tool.\n## Running the code analysis\nThe code analysis runs in the background and you'll see the warning \"There must be exactly one space character on each side of '+'.\" disappear from the Problems option in Visual Studio Code.\nTo trigger a new compilation manually, use the Ctrl+Shift+B shortcut to build your project. For more information about AL keyboard shortcuts, see devenv-keyboard-shortcuts.\n## Limitations\nThe AL Language extension for Microsoft Dynamics 365 Business Central won't detect when the contents of the ruleset file changes. To see the effects of changing the ruleset file, you can try any of the following steps:\n Reload the window.\n In the project settings, change the Rule Set Path setting to an nonexisting path and save it. Then change it back and save again.\n## Related information\ndevenv-rule-set-syntax-for-code-analysis-tools\ndevenv-using-code-analysis-tool\ndirectives/devenv-directives-in-al\nDevelopment in AL<devenv-dev-overview>\nDebugging in AL<devenv-debugging>\nAL Language Extension Configuration<devenv-al-extension-configuration>"}