For the complete documentation index, see llms.txt. This page is also available as Markdown.

Pipeline Operation: Code Scan

Written for the Old UI

Overview

The Code Scan operation analyzes your Salesforce metadata to identify code quality issues before deployment. Through static code analysis, it reports rule violations in a branch’s Apex classes, triggers, and other components to confirm they meet your defined coding standards. The Code Scan rule set covers:

  • Coding Style and Best Practices: Improve readability, maintainability, and consistency across your codebase.

  • Security Best Practices: Identify common vulnerabilities and risky patterns in your code.

  • Performance Suggestions: Highlight inefficient logic before it affects end users.

You can set a severity threshold to abort the pipeline when violations reach or exceed a specified level. Running Code Scans in your pipeline helps maintain consistent code quality and enables you to deploy reliable, secure, and responsive components.

This article explains how to configure and use the Code Scan operation. See the following sections to learn more:

Best Practices

  • Run Code Scans automatically before every deployment.

  • Set severity thresholds based on CI/CD rules.

  • Regularly review the Code Scan Result and fix recurring issues.

  • Combine Code Scan with a Manual Step to require a review and approval before production deployment.

  • Maintain consistent Code Scan configurations across all environments.

Scan Types

The Code Scan operation supports two scan types: Apex PMD and Flosum Scan. Review the descriptions below to choose the scan type that best matches your team's quality standards.

Apex PMD

Apex PMD is an open-source ruleset that detects common issues in Salesforce components. It includes fewer rules than Flosum Scan and completes scans faster, making it a lightweight option for quick feedback. Choose Apex PMD when its baseline checks meet your needs or you prefer to detect fewer issues.

Flosum Scan

Flosum Scan is DevOps' most comprehensive ruleset, built for teams that demand the highest standard of code quality. It includes every rule in Apex PMD plus hundreds of additional checks, roughly 6 times the coverage of Apex PMD, and it extends static analysis to languages that Apex PMD does not cover, including Salesforce Flow and TypeScript. This expanded coverage delivers deeper analysis and stricter validation, giving you greater confidence with every deployment. Choose Flosum Scan for the most thorough protection of your Salesforce code.

Why Flosum Scan?

  • Broader language coverage: Adds first-class support for Salesforce Flow and TypeScript, neither of which is analyzed by Apex PMD.

  • Deeper Lightning coverage: Includes 381 rules for JavaScript and Lightning Web Components, compared to 19 in Apex PMD.

  • Stronger metadata validation: Applies 18 rules to Salesforce Metadata, compared to 2 in Apex PMD.

  • Continuously expanded: The Flosum Scan ruleset is maintained by Flosum and will grow to keep pace with Salesforce platform changes.

Rule Coverage by Language

The table below lists the languages supported by each scan type. The chart compares the rule coverage for each scan type across the supported languages. Use this information to confirm that the scan type you select provides sufficient rulesets for the languages used in your branch.

Language
Apex PMD
Flosum Scan

JavaScript / Lightning Web Components

TypeScript

Apex

Salesforce Metadata

HTML / Salesforce Lightning Design System

Salesforce Flow

Visualforce

Severity Levels

When the Code Scan finds an issue, it assigns a Severity Level that reflects how critical the issue is to the quality of your code. Use these levels to prioritize fixes and set the severity threshold that determines when the operation fails.

Severity Level
Description

Blocker

Severe security risks or critical bugs that can cause system failure or data loss.

Critical

Significant issues that typically violate Salesforce AppExchange standards.

Major

Best-practice violations or performance issues that affect maintainability.

Minor

Low-impact code-quality issues or stylistic inconsistencies.

Info

Informational messages that require no action.

Code Scan Operation Configuration

The instructions below apply to configuring this pipeline operation. For general instructions on adding a pipeline step and setting the next step, see the following article.

Adding a Pipeline Step

1

Select Operation and Type

  1. Click the Operation dropdown menu.

  2. Select Code Scan.

  3. Click the Check type dropdown menu.

  4. Select the type of code scan to perform. See the Pipeline Operation: Code Scan section above for more details.

2

Enter Description and Threshold

  1. (Optional) In the Description textbox, enter a summary of what this Code Scan performs.

  2. Click the Severity threshold dropdown menu.

  3. Select the minimum severity level that will cause the Code Scan operation to fail. See the Pipeline Operation: Code Scan section above for more details.

The Severity threshold means that if an issue at or above the selected severity level is found, the Code Scan will fail.

Code Scan Results

Once a pipeline is started, its progress and results can be viewed from the Activities tab from the branch that ran the pipeline. The instructions below show you how to review the results of this operation. For general instructions on accessing pipeline results from the branch, see the following article.

1

Summary and Log

Once the Code Scan is complete, you can view the results summary by selecting the Code Scan step from the pipeline results.

The Summary of the Code Scan results displays the following information:

Fields
Description

Status

Completed if all issues found are below the set Severity Threshold.

Exception if any issue meets or exceeds the Severity Threshold.

Duration

Time the Code Scan took to complete, shown in hours, minutes, and seconds.

Date started/finished

The date and time the Code Scan started and finished.

Issues Found

Number of issues found at each Severity Level.

Log

Log entries for the Code Scan job. Use the log to review the job's status and any error messages.

Example of a Code Scan log:

2

Code Scan Results

You can view the Code Scan Results to see which files in your branch the scan found issues with and how many of each Severity Level were found.

  1. Click See result.

Currently, the Severity Level labels on the Code Scan Result page differ from the labels used in other Code Scan sections. This minor issue will be resolved soon. In the meantime, use the following mapping to translate the Severity Levels:

  • Critical → Blocker

  • High → Critical

  • Medium → Major

  • Low → Minor

  • Minor → Info

At the top of the results page is the total number of issues found for each Severity Level. Under the totals is a list of component files with issues, along with a bar graph of issues organized by Severity.

3

File-Level Results

The file-level results explain the cause of each issue and where it occurs in the source file. Review each issue and, when applicable, make the required changes to the component.

  1. Click a file from the list to view the full list of issues.

  2. If available, click Show more to view more issues found in this file.

The screenshot and table below explain the information displayed for each issue.

Column
Description

Severity Level

A colored circle with a letter inside indicates the Severity Level. The letter matches the first letter of the Severity Level name, and the color matches the level. Note: Major and Minor both start with M, but Major is orange and Minor is green.

Rule Name

The name of the rule that flagged the issue.

Violation Description

A description of the issue's cause.

Violation Location

The line and column number where the issue was found.

Last updated

Was this helpful?