Please wait
Talk to Expert
CodeCop Analyzer, Microsoft Dynamics Business central, Visual Studio Code

CodeCop Analyzer for Business Central

resized

What is CodeCop Analyzer?

  • CodeCop is an analyzer that enforces the official AL Coding Guidelines.

 

How can we apply that into our AL Project?

Follow the below steps to Apply/Add the CodeCop Analyzer into the Current Project.

  • Step 1: Select Setting under File menu as below image.
  • Step 2: Expand the Extension tab and click on Edit in Settings.json.
  • Step 3: Add below two lines into setting.json. We also have other options like AppSource and pertenantext. But in our case, we don’t need those values. After adding values in the JSON file reload window for the suggestion.
    “al.enableCodeAnalysis”: true,
    “al.codeAnalyzers”: [“${CodeCop}”,”${UICop}”]
  • Now you can see the warnings are pop up under the Problem tab it will suggest you some changes as per Microsoft standard Coding Guidelines.
  • It will help us to remove unnecessary codes from our project. Suggest warnings that will become errors in future upgraded versions of Business Central.

Result

  • As you can see in the below image, we have defined a one-page variable customer list for our internal use in the report Delete Uncoupled Account. In our case we are not using this page variable anywhere in our code. So, we must need to remove this as per Microsoft standard guidelines.

 

To get more idea regarding CodeCop dev can follow below links:

  • https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-using-code-analysis-tool
  • https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/analyzers/appsourcecop
  • https://www.waldo.be/2018/03/26/enable-the-updated-code-analysis-for-al/

Comments