When SonarQube scans the Git Submodule project, only the files of the super project are scanned

Viewed 889

When SonarQube scans the Git submodule project, only the files of the super project are scanned.
Run in jenkins(Linux)
SonarQube version is 7.9.3
a maven project

the super project: only 2 file: .gitmodules and pom.xml

in other project,maven project have module,but not use git submodule can work.

the log: only 1 file, the pom.xml for super project are scanned.

[INFO] User cache: /var/lib/jenkins/.sonar/cache
[INFO] SonarQube version: 7.9.3
[INFO] Default locale: "en_US", source code encoding: "UTF-8"
[WARNING] SonarScanner will require Java 11 to run starting in SonarQube 8.x
[INFO] Load global settings
[INFO] Load global settings (done) | time=86ms
[INFO] Server id: 0697A0C6-AXLFaD-v57HRhyHJwu5i
[INFO] User cache: /var/lib/jenkins/.sonar/cache
[INFO] Load/download plugins
[INFO] Load plugins index
[INFO] Load plugins index (done) | time=55ms
[INFO] Plugin [l10nzh] defines 'l10nen' as base plugin. This metadata can be removed from manifest of l10n plugins since version 5.2.
[INFO] Load/download plugins (done) | time=83ms
[INFO] Process project properties
[INFO] Execute project builders
[INFO] Execute project builders (done) | time=5ms
[INFO] Project key: szyh_apps
[INFO] Base dir: /var/lib/jenkins/workspace/sonar/ ****
[INFO] Working dir: /var/lib/jenkins/workspace/sonar/ **** /target/sonar
[INFO] Load project settings for component key: 'szyh_apps'
[INFO] Load project settings for component key: 'szyh_apps' (done) | time=14ms
[INFO] Load quality profiles
[INFO] Load quality profiles (done) | time=51ms
[INFO] Detected Jenkins
[INFO] Load active rules
[INFO] Load active rules (done) | time=567ms
[INFO] Indexing files...
[INFO] Project configuration:
[INFO] Indexing files of module '******'
[INFO]   Base dir: /var/lib/jenkins/workspace/sonar/ ****
[INFO]   Source paths: pom.xml, src/main/java
[INFO]   Test paths: src/test/java
...
[INFO] Indexing files of module '****(the aggregator project)****'
[INFO]   Base dir: /var/lib/jenkins/workspace/sonar/ ****
[INFO]   Source paths: pom.xml
[INFO] 1 file indexed
[INFO] 0 files ignored because of scm ignore settings
[INFO] Quality profile for xml: Sonar way
[INFO] ------------- Run sensors on module ****
[INFO] Load metrics repository
[INFO] Load metrics repository (done) | time=16ms
[INFO] Sensor JavaXmlSensor [java]
[INFO] Sensor JavaXmlSensor [java] (done) | time=1ms
[INFO] Sensor JaCoCo XML Report Importer [jacoco]
[INFO] Sensor JaCoCo XML Report Importer [jacoco] (done) | time=3ms
[INFO] ------------- Run sensors on module ****
[INFO] Sensor JavaXmlSensor [java]
[INFO] Sensor JavaXmlSensor [java] (done) | time=0ms
[INFO] Sensor JaCoCo XML Report Importer [jacoco]
[INFO] Sensor JaCoCo XML Report Importer [jacoco] (done) | time=1ms
...
[INFO] Sensor MyBatisLint Sensor [mybatis]
[INFO] stmtIdExcludeList: []
[INFO] Sensor MyBatisLint Sensor [mybatis] (done) | time=78ms
[INFO] Sensor JavaXmlSensor [java]
[INFO] 1 source files to be analyzed
[INFO] Load project repositories
[INFO] Load project repositories (done) | time=16ms
[INFO] Sensor JavaXmlSensor [java] (done) | time=172ms
[INFO] 1/1 source files have been analyzed
[INFO] Sensor HTML [web]
[INFO] Sensor HTML [web] (done) | time=13ms
[INFO] Sensor XML Sensor [xml]
[INFO] 1 source files to be analyzed
[INFO] Sensor XML Sensor [xml] (done) | time=143ms
[INFO] Sensor JaCoCo XML Report Importer [jacoco]
[INFO] 1/1 source files have been analyzed
[INFO] Sensor JaCoCo XML Report Importer [jacoco] (done) | time=2ms
[INFO] ------------- Run sensors on project
[INFO] Sensor Zero Coverage Sensor
[INFO] Sensor Zero Coverage Sensor (done) | time=0ms
[INFO] SCM provider for this project is: git
[INFO] 1 files to be analyzed
[INFO] 1/1 files analyzed
[INFO] Calculating CPD for 0 files
[INFO] CPD calculation finished
[INFO] Analysis report generated in 70ms, dir size=191 KB
[INFO] Analysis report compressed in 9ms, zip size=16 KB
[INFO] Analysis report uploaded in 20ms
[INFO] ANALYSIS SUCCESSFUL, you can browse http:// **** /dashboard?id=szyh_apps
[INFO] Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
[INFO] More about the report processing at http:// **** /api/ce/task?id=****
[INFO] Analysis total time: 5.244 s
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 

In SonarQube,only pom.xml

disabled scm can work, but no time and author information

mvn jacoco:prepare-agent sonar:sonar \
  -Dsonar.projectKey=szyh_apps \
  -Dsonar.host.url=http://**** \
  -Dsonar.login=**** \
  -Dsonar.scm.disabled \
  -s /usr/share/maven/conf/settings-szyh_apps.xml
1 Answers

you can set -Dsonar.scm.exclusions.disabled=true in cmd line or from SonarQube Dashboard->Administration->General settings->SCM->Disable the scm sensor=TRUE

This is working fine for me, I am using SonarQube V7.9.5

This is something related with how git is reading your repo. first try cmd in you repository: git ls-tree -r HEAD

You can refer to Ann's answer :https://community.sonarsource.com/t/no-results-for-git-submodules/8464: """ Looking at the source of sonar-scm-git-plugin, I understand that actually it’s not strictly "adding exclusions based on project’s .gitignore", but instead it’s ignoring every file that’s not managed by the root repository.

You can verify this running git ls-tree -r HEAD in your git repo. The submodule’s files are not listed and basically this is what the Git Plugin 1.8 is doing. """

Related