Static Code Analysis

Updated 7 months ago by Iván Minaya

Copado's Static Code Analysis allows users to detect code inefficiencies, errors and bad habits before they grow into expensive problems. By adding this powerful quality gate to the release management process, Copado users will be capable of automatically monitor developers code, and enforce the implementation best practices. Static Code Analysis Results can be run on all the Apex code across the Org and  for specific Apex code added in a particular User Story. When promoting  a collection of User Stories, Static Code Analysis Results will consider all the included Apex classes within the Promotion.

Create Static Code Analysis Settings with Default RuleSet.

  • Go to Static Code Analysis Settings page.
  • Click "New Static Code Analysis Settings Name".
  • Define a Static Code Analysis Settings Name, click Save.
  • Open the Static Code Analysis Settings, click Generate Default RuleSet.

Customise RuleSet

RuleSet can be customised (Add, Edit and Delete). Each Rule has a Priority within 1 to 5 interval, and it  can be defined according to the relevance of the violated rule. 


  • Priority 1 will be considered as a highly important rule, and a 5 priority as the lowest.
  • Scoring it's calculated by the subtraction of (6 - selected priority).
  • A high number of violated rules will throw a high Static Code Analysis Result (The higher the worst).

There is a total of 34 rules specially tailored to enforce apex code best practices.  

Assign Static Code Analysis RuleSet to Deployment Flow. 

Go to Deployment Flow page, open a Deployment Flow and assign the Static Code Analysis Setting to it. Note: From now on, Org Credentials and User Stories with Environments inside this flow will take this SCA Settings when requesting a new Static Code Analysis. 

Assign Environment Maximum Static Code Analysis Score:

  • You can add a maximum score to each Environment according to your quality requirements. This value will be used as a reference for the SCA Result graph on the Promotion page. 

Run Static Code Analysis:

  • Under any Org Credential inside the Deployment Flow with SCA Settings assigned, you can now request Static Code Analysis for all classes in the Salesforce Org. 
  • Under a User Story with an Environment inside the Deployment Flow that has SCA Settings Assigned, you can request Static Code Analysis for Apex Classes related to it.

Review Static Code Analysis Results:

  • As per v11, in the Org Credential page, go to the latest Static Code Analysis Result and navigate to the Static Code Analysis Violations related list.
  • Note: This related list relies on the latest Static Code Analysis job to be completed. It may take some time to be generated.

Review Promotion Static Code Analysis Results:

  • When promoting User Stories,  Static Code Analysis Summary score will be shown for the User Stories included in the promotion.  This allows a better quality control for the developed code before it reaches the production org.
  • From the user story page you can click the Static Code Analysis Summary button, and review details.

How did we do?