Issue in SonarCloud Apex/Salesforce integration for code analysis

Hi,

I am using SonarCloud for Apex/salesforce code analysis.
I have created a Bitbucket pipeline to execute checks from Sonar Cloud.

My .yml File is as below:

clone:
  depth: full    # SonarCloud scanner needs the full history to assign issues properly

definitions:
  services:
    docker:
      memory: 5120
  # caches:
   # sonar: ~/.sonar/cache  # Caching SonarCloud artifacts will speed up your build
  steps:
    - step: &build-test-sonarcloud
        name: Build, test and analyze on SonarCloud
        # caches:
          # - node
          # - sonar
        size: 2x # Double resources available for this step.


        script:
          - pipe: sonarsource/sonarcloud-scan:1.4.0
          - pipe: sonarsource/sonarcloud-quality-gate:0.1.6
  
pipelines:
  default:
    - step: *build-test-sonarcloud

Error after execution is:
Quality Gate failed: Could not fetch quality gate status: b’{“errors”:[{“msg”:“Analysis with id \u0027None\u0027 is not found”}]}

I referred one existing thread on same topic:

In above thread sonar-project.properties file is referred.
Do I need to build the same for Apex? If yes what will be the project key in that case?
Is there is documentation around this for Salesforce/Apex?

Attaching whole log file for above execution.

pipelineLog-{47f970a4-c91a-4d25-a3ae-a6d856de67ed}.txt (23.0 KB)

Regards,
Manasi

Hi @Manasi_Joshi,

We investigated the issue. The reason you received this error is that your organization has exceeded the maximum number of lines for analysis. I will send you the exact message privately.

We will make a fix to give an appropriate error message for this situation in the future.

Hi Serhat,

Thank you for updates.
Currently org has very small code base. But still this error is there. Is there any workaround for this?
Do I need to maintain the sonar-project.properties file as well (as per attached thread)?
If yes then what is the syntax for that wrt Apex code.

Regards,
Manasi

Any updates on this?

Hi Manasi,

Yes, I think some files you don’t want to analyze are also included in your analysis process. So, as you mentioned, in sonar-project.properties, you should correctly define the ‘source’ directory you want to analyze and exclude the files and folders you don’t want to analyze under your source directory. I don’t think you need to use an apex-specific syntax to do this.

There is beneficial information in the other thread. See also our primary documentation for all the possible configuration options to include or exclude files.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.