Understanding branches for Salesforce project
  • 20 Sep 2022
  • 3 Minutes to read
  • Contributors
  • Dark

Understanding branches for Salesforce project

  • Dark

When you create an analysis project from Salesforce, the org or sandbox you authorize, will become your main branch. You can add your sandboxes as analysis project branches by editing your project (from the Project Analysis page). This allows for easy comparison between the production orgs or sandboxes and is especially good for checking features before production.

  1. Select your Salesforce project from the My Projects screen.
  2. Go to the More tab and select Project Analysis from the dropdown.
  3. Click on Edit Project.
  4. Click on image.png button to add a new branch.
  5. Assign a name to your branch and choose the branch type:
    • Comparison Branch- This branch determines only the recent issues in a project branch based on comparing with the standard branch in your project.
    • Standard Branch- This branch will have your project's entire history and dashboards.


  1. Select your Salesforce environment.
  2. Once you click on Authorize, it will redirect you to the Salesforce login page to validate your credentials.
  3. This triggers the project analysis and the project being added under your CodeScan organization.
  4. You'll be redirected to the Project Analysis screen, where you can view the status of your triggered analysis.

Features of a comparison branch

When you create a comparison branch, the issues shown are only the new ones in that branch, not the general issues you see in the project's main branch.

The property below is responsible for changing the UI labels and texts from Pull Requests to Comparison Branches.


Points to Note:

The codescan.comparison.branches property is in OFF state by default.

The comparison branches feature is enabled automatically when you:

  • create new comparison branch via CodeScan user interface inside project with Salesforce as the integration type or,
  • run sonar-scanner or CodeScan SFDX utility with these two new scanner properties:


Another way is via Autorabit-CodeScan integration.

The new properties sonar.comparison.branch and sonar.comparison.base are equivalents/aliases of these existing two: sonar.pullrequest.branch and sonar.pullrequest.base.

So, because they are equivalents - the rest logic will be the same. If you mark any issue as False Positive or Resolve as Won't fix in your Comparison Branch, then this issue will not re-appear in base branch (master) after changes are merged.
Similarly, the new comparison branches reflect the changes on issues made by the user on the project’s main branch.

To test the new feature using sonar-scanner:

  1. Execute the initial analysis on base branch using the below command:
sonar-scanner -Dsonar.host.url=https://app.codescan.io -Dsonar.organization=<org-id>
-Dsonar.projectKey=<project-key> -Dsonar.login=<security-token>
  1. Execute analysis on a comparison branch:
sonar-scanner -Dsonar.host.url=https://app.codescan.io -Dsonar.comparison.branch=<comparison-branch-name>
-Dsonar.comparison.base=<base-branch-name> -Dsonar.organization=<org-id> -Dsonar.projectKey=<project-key>

Managing branches

On your Project Analysis page, go to Project Setting > Branches.

On this page, you can:

  • View the branches you have created and segregated into master branches (including standalone branches) and comparison branches in two different tabs.
  • Delete all the branches except the main branch.
  • Renaming of the branch applies only to the main branch.

Delete a branch

For example, to delete a comparison branch, navigate to the Comparisons Branches tab, click on image.png icon and click on Delete Comparison Branch. Note that this process cannot be undone.

Rename the main branch

To update the name of the main branch, navigate to the Branches tab, and look for the main branch.
Click on image.png icon under the Actions tab and click on Rename branch.

Give the main branch a new name and click on Rename.

Comparing Branches


  1. Select your Salesforce project from the My Projects page.
  2. When you click on the main branch dropdown for your project, you can see the list of all branches that you have created or added.
  3. If there are any violations for your branch, such details will appear. If you click on a branch, the details of the violations can be seen on the Quality Gate Status screen.
Important Note:

All new branches added in this way will be deleted in 30 days if they are not analyzed again.

If you have any further questions about CodeScan Cloud, please contact us.

Was this article helpful?