SonarCloud not scanning code when sonar.inclusions is defined

Hi,

When I see the sonar.inclusions property, the code section in sonarcloud is empty. When I do not define the sonar.inclusions property, the code section in sonarcloud isn’t empty, but only assets are shown, and no .vue, .js and .ts files are shown, the folder name matches the name of the actual folder.

This is my sonarcloud prepare:

      - task: SonarCloudPrepare@3
        inputs:
          sonarCloud: SonarCloud
          organization: {{ORGNAME}}
          scannerMode: CLI
          configMode: 'manual'
          cliProjectKey: {{PROJECT_KEY}}
          cliProjectName: {{PROJECTNAME}}
          cliSources: '$(System.DefaultWorkingDirectory)/{{FOLDER_NAME}}/src/'
          extraProperties: |
            sonar.inclusions=**/*.js,**/*.ts,**/*.vue
            sonar.javascript.lcov.reportPaths={{FOLDER_NAME}}/coverage/lcov.info

In the master branch it DOES show everything- but in the DEV branch, it only shows a few files (none code files) and in a descending branch of DEV - it shows a few code files, but not everything - I have literally no clue what’s going on, is there anyone who can help?

Hey there.

It sounds like you are analyzing a short-lived branch, where the only code that will be displayed is the code that has changed in that branch. If you want to show everything on that branch, you’ll need to delete the branch, adjust the long-lived branch name pattern for your project, and reanalyzed the branch.

1 Like

Hi, i got my FE scanning to work, by adding 2 flags to my job properties:

- checkout: self
   fetchDepth 0

and then specified my FE SonarCloudPrepare task as such:

      - task: SonarCloudPrepare@3
        inputs:
          sonarCloud: SonarCloud
          organization: {{org}}
          scannerMode: CLI
          configMode: 'manual'
          cliProjectKey: {{key}}
          cliProjectName: {{proj_name}}
          cliSources: {{source}}
          extraProperties: |
            sonar.projectBaseDir={{working dir}}
            sonar.sources=src/
            sonar.inclusions=**/*.js,**/*.ts,**/*.vue
            sonar.exclusions=**/*.cs,**/node_modules/**,**/*.json,**/api-client-generated.ts
            sonar.javascript.lcov.reportPaths={{reportpath}}

Which fixed my issue for the FE, but I am still unable to get my .net scanner to work, it just keeps saying that there’s no code, but with the checkout: self, and fetchDepth of 0 it should be fixed (forcing a fetch all, which is what we need on ALL analyzed branches)

I tried to adjust the naming pattern, by creating a new project - and analyzing that instead, with a different long-lived branch pattern, but that didn’t work either :frowning: the long-lived-branch-pattern never matched our dev branch

To match a branch named DEV, the pattern should’ve been:

(master|dev|dev_*)-.*

Correct?

I just changed the long lived branches and it fixed it, thank you

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