> For the complete documentation index, see [llms.txt](https://docs.flosum.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.flosum.com/devops/pipeline/pipeline-operations/pipeline-operation-code-scan.md).

# Pipeline Operation: Code Scan

{% hint style="warning" %}

#### Written for the Old UI

This article was written for the old UI. The instructions are still usable, but the screenshots are outdated. In some cases, items referenced in the instructions have moved or changed. If you cannot find an item, see the [Where Did It Go](/devops/new-ui-ux-transition/where-did-it-go.md) article.
{% endhint %}

## ![](https://1800549522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2FG5ZbxX918xOHwbAwAJ4n%2FSummary2-Small-Icon.svg?alt=media\&token=da26a67f-ff7f-47b3-8669-06be960dc2d7) 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:

* [#scan-types](#scan-types "mention")
* [#severity-levels](#severity-levels "mention")
* [#code-scan-operation-configuration](#code-scan-operation-configuration "mention")
* [#code-scan-results-1](#code-scan-results-1 "mention")

{% hint style="info" %}

#### 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.
  {% endhint %}

### 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. In the Check type dropdown menu, Flosum Scan is listed as Flosum.

#### 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.

{% hint style="info" %}

#### 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.
  {% endhint %}

#### 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.

<table><thead><tr><th width="399.666748046875">Language</th><th align="center">Apex PMD</th><th align="center">Flosum Scan</th></tr></thead><tbody><tr><td>JavaScript / Lightning Web Components</td><td align="center"><img src="https://1800549522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2FFyAlTI4AIHg46Nb6SL90%2FCheckBox-Icon.svg?alt=media&amp;token=3ab847f7-5568-405e-aa0a-23e02f38d451" alt="" data-size="line"></td><td align="center"><img src="https://1800549522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2FFyAlTI4AIHg46Nb6SL90%2FCheckBox-Icon.svg?alt=media&amp;token=3ab847f7-5568-405e-aa0a-23e02f38d451" alt="" data-size="line"></td></tr><tr><td>TypeScript</td><td align="center"><img src="https://1800549522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2FzwOFIIvK4ue9gjxBh5iX%2FX-Icon.svg?alt=media&amp;token=bbcd7bc0-1097-450d-b6ce-62677c4c4097" alt="" data-size="line"></td><td align="center"><img src="https://1800549522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2FFyAlTI4AIHg46Nb6SL90%2FCheckBox-Icon.svg?alt=media&amp;token=3ab847f7-5568-405e-aa0a-23e02f38d451" alt="" data-size="line"></td></tr><tr><td>Apex</td><td align="center"><img src="https://1800549522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2FFyAlTI4AIHg46Nb6SL90%2FCheckBox-Icon.svg?alt=media&amp;token=3ab847f7-5568-405e-aa0a-23e02f38d451" alt="" data-size="line"></td><td align="center"><img src="https://1800549522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2FFyAlTI4AIHg46Nb6SL90%2FCheckBox-Icon.svg?alt=media&amp;token=3ab847f7-5568-405e-aa0a-23e02f38d451" alt="" data-size="line"></td></tr><tr><td>Salesforce Metadata</td><td align="center"><img src="https://1800549522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2FFyAlTI4AIHg46Nb6SL90%2FCheckBox-Icon.svg?alt=media&amp;token=3ab847f7-5568-405e-aa0a-23e02f38d451" alt="" data-size="line"></td><td align="center"><img src="https://1800549522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2FFyAlTI4AIHg46Nb6SL90%2FCheckBox-Icon.svg?alt=media&amp;token=3ab847f7-5568-405e-aa0a-23e02f38d451" alt="" data-size="line"></td></tr><tr><td>HTML / Salesforce Lightning Design System</td><td align="center"><img src="https://1800549522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2FFyAlTI4AIHg46Nb6SL90%2FCheckBox-Icon.svg?alt=media&amp;token=3ab847f7-5568-405e-aa0a-23e02f38d451" alt="" data-size="line"></td><td align="center"><img src="https://1800549522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2FFyAlTI4AIHg46Nb6SL90%2FCheckBox-Icon.svg?alt=media&amp;token=3ab847f7-5568-405e-aa0a-23e02f38d451" alt="" data-size="line"></td></tr><tr><td>Salesforce Flow</td><td align="center"><img src="https://1800549522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2FzwOFIIvK4ue9gjxBh5iX%2FX-Icon.svg?alt=media&amp;token=bbcd7bc0-1097-450d-b6ce-62677c4c4097" alt="" data-size="line"></td><td align="center"><img src="https://1800549522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2FFyAlTI4AIHg46Nb6SL90%2FCheckBox-Icon.svg?alt=media&amp;token=3ab847f7-5568-405e-aa0a-23e02f38d451" alt="" data-size="line"></td></tr><tr><td>Visualforce</td><td align="center"><img src="https://1800549522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2FFyAlTI4AIHg46Nb6SL90%2FCheckBox-Icon.svg?alt=media&amp;token=3ab847f7-5568-405e-aa0a-23e02f38d451" alt="" data-size="line"></td><td align="center"><img src="https://1800549522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2FFyAlTI4AIHg46Nb6SL90%2FCheckBox-Icon.svg?alt=media&amp;token=3ab847f7-5568-405e-aa0a-23e02f38d451" alt="" data-size="line"></td></tr></tbody></table>

<figure><img src="https://1800549522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2FmEJomEj5Qdzu2DhZttFe%2FPipelineOperationCodeScan-Chart-01.png?alt=media&amp;token=f613ed31-b5e6-431f-af8f-24fa0d48a3bf" alt=""><figcaption></figcaption></figure>

### 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.

<table><thead><tr><th width="150">Severity Level</th><th>Description</th></tr></thead><tbody><tr><td>Blocker</td><td>Severe security risks or critical bugs that can cause system failure or data loss.</td></tr><tr><td>Critical</td><td>Significant issues that typically violate Salesforce AppExchange standards.</td></tr><tr><td>Major</td><td>Best-practice violations or performance issues that affect maintainability.</td></tr><tr><td>Minor</td><td>Low-impact code-quality issues or stylistic inconsistencies.</td></tr><tr><td>Info</td><td>Informational messages that require no action.</td></tr></tbody></table>

## Code Scan Operation Configuration

{% hint style="info" %}
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](/devops/pipeline/configuring-pipeline-steps/adding-a-pipeline-step.md)
{% endhint %}

{% stepper %}
{% step %}

### Select Operation and Type

1. Click the **Operation** dropdown menu.
2. Select **Code Scan**.

   <div align="left"><figure><img src="https://1800549522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2FJylQJG03TIzkfefDNYLj%2FPipelineOperationCodeScan-Config-S01-01.png?alt=media&amp;token=50da9df9-7700-4111-b356-1d43b6601806" alt="" width="563"><figcaption></figcaption></figure></div>
3. Click the **Check type** dropdown menu.
4. Select **Apex PMD** or **Flosum**. **Flosum** is the Flosum Scan type. See the Scan Types section above for more details.

   <div align="left"><figure><img src="https://1800549522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2FkMG1WoaoeonBhuJpbd9u%2FPipelineOperationCodeScan-Config-S01-02.png?alt=media&amp;token=14189fc7-aaf4-443f-9c2b-2a36f9cb4911" alt="" width="563"><figcaption></figcaption></figure></div>

{% endstep %}

{% step %}

### 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 Severity Levels section above for more details.

   <div align="left"><figure><img src="https://1800549522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2FA6IsOXnlWyUCGVXt6kL4%2FPipelineOperationCodeScan-Config-S02-01.png?alt=media&amp;token=571b2ca8-d64f-4a4f-a48a-d9f29c889b2d" alt="" width="563"><figcaption></figcaption></figure></div>

{% hint style="info" %}
The **Severity threshold** means that if an issue at or above the selected severity level is found, the Code Scan will fail.
{% endhint %}
{% endstep %}
{% endstepper %}

## Code Scan Results

{% hint style="info" %}
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.

* [Viewing Pipeline Results](/devops/pipeline/pipeline-actions/viewing-pipeline-results.md)
  {% endhint %}

{% stepper %}
{% step %}

### 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.

<div align="left"><figure><img src="https://1800549522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2FCqkIBlg2aZej5hNl2buC%2FPipelineOperationCodeScan-Results-S01-01.png?alt=media&amp;token=0f223c77-c928-428b-8552-b78e9abcb0c4" alt="" width="563"><figcaption></figcaption></figure></div>

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

<table><thead><tr><th width="200.3333740234375">Fields</th><th>Description</th></tr></thead><tbody><tr><td>Status</td><td><p><strong>Completed</strong> if all issues found are below the set Severity Threshold.</p><p><strong>Exception</strong> if any issue meets or exceeds the Severity Threshold.</p></td></tr><tr><td>Duration</td><td>Time the Code Scan took to complete, shown in hours, minutes, and seconds.</td></tr><tr><td>Date started/finished</td><td>The date and time the Code Scan started and finished.</td></tr><tr><td>Issues Found</td><td>Number of issues found at each Severity Level.</td></tr><tr><td>Log</td><td>Log entries for the Code Scan job. Use the log to review the job's status and any error messages.</td></tr></tbody></table>

Example of a Code Scan log:

{% code overflow="wrap" expandable="true" %}

```
[May 22, 2026 1:09 PM]: [info] Job started
[May 22, 2026 1:09 PM]: [info] Create salesforce project started
[May 22, 2026 1:09 PM]: [info] Create salesforce project completed
[May 22, 2026 1:09 PM]: [info] Retrieve salesforce components started
[May 22, 2026 1:09 PM]: [info] Retrieve salesforce components completed
[May 22, 2026 1:09 PM]: [info] Code analyzer started
[May 22, 2026 1:10 PM]: [info] Code analyzer completed
[May 22, 2026 1:10 PM]: [error] Job failed: Code scan exceeded the allowed value: "Minor"
```

{% endcode %}
{% endstep %}

{% step %}

### 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**.

   <div align="left"><figure><img src="https://1800549522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2FrOAv0f836UScNKtf3aS0%2FPipelineOperationCodeScan-Results-S02-01.png?alt=media&amp;token=a15a8b79-c6f1-47f9-8b0f-4f88264ae34a" alt="" width="563"><figcaption></figcaption></figure></div>

{% hint style="info" %}
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**
  {% endhint %}

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.

<div align="left"><figure><img src="https://1800549522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2FaJKENrYjN8xUipfT7eFB%2FPipelineOperationCodeScan-Results-S02-02.png?alt=media&amp;token=d942f17b-de32-4f35-8474-0fca346a4c6f" alt="" width="563"><figcaption></figcaption></figure></div>
{% endstep %}

{% step %}

### 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.

   <div align="left"><figure><img src="https://1800549522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2FCP8sA4LTlyR8ZVbTguv7%2FPipelineOperationCodeScan-Results-S03-01.png?alt=media&amp;token=4df75b5f-1c1c-4dd3-bbc3-b556d01af65d" alt="" width="563"><figcaption></figcaption></figure></div>
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.

<div align="left"><figure><img src="https://1800549522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2FHdwii7OwDPNZ8z4dOuIC%2FPipelineOperationCodeScan-Results-S03-02.png?alt=media&amp;token=9556a7af-d237-43f8-968f-55b1212b8694" alt="" width="563"><figcaption></figcaption></figure></div>

<table><thead><tr><th width="199.66668701171875">Column</th><th>Description</th></tr></thead><tbody><tr><td>Severity Level</td><td>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.</td></tr><tr><td>Rule Name</td><td>The name of the rule that flagged the issue.</td></tr><tr><td>Violation Description</td><td>A description of the issue's cause.</td></tr><tr><td>Violation Location</td><td>The line and column number where the issue was found.</td></tr></tbody></table>
{% endstep %}
{% endstepper %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.flosum.com/devops/pipeline/pipeline-operations/pipeline-operation-code-scan.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
