The sonar-scanner can not indexed this files correctly。

Must-share information (formatted with Markdown):

  • sonar-scanner-4.8.0.2856-linux
    sonarqube enterprise 10.0
  • how is SonarQube deployed: zip,
  • what are you trying to achieve
    I want to scanner some file of c language
  • what have you tried so far to achieve this
    The sonar-scanner can not indexed this files correctly。
INFO: Scanner configuration file: /usr/local/sonar-scanner-4.8.0.2856-linux/conf/sonar-scanner.properties
INFO: Project root configuration file: /work_build-sw_12_5_SPJ40/prj_switch/tmp/rootfs-build/sda_xgs/sonar-project.properties
INFO: SonarScanner 4.8.0.2856
INFO: Java 11.0.17 Eclipse Adoptium (64-bit)
INFO: Linux 3.10.0-957.el7.x86_64 amd64
INFO: User cache: /root/.sonar/cache
INFO: Analyzing on SonarQube server 10.0.0.68432
INFO: Default locale: "en_US", source code encoding: "GBK"
INFO: Load global settings
INFO: Load global settings (done) | time=81ms
INFO: Server id: A22B7A3A-AYBKsacb-ne8H-Wu9gBs
INFO: User cache: /root/.sonar/cache
INFO: Load/download plugins
INFO: Load plugins index
INFO: Load plugins index (done) | time=33ms
INFO: Load/download plugins (done) | time=240ms
INFO: Loaded core extensions: developer-scanner
INFO: Process project properties
INFO: Process project properties (done) | time=8ms
INFO: Execute project builders
INFO: Execute project builders (done) | time=1ms
INFO: Project key: switch_sda_xgs:sda
INFO: Base dir: /work_build-sw_12_5_SPJ40/prj_switch/tmp/rootfs-build/sda_xgs
INFO: Working dir: /work_build-sw_12_5_SPJ40/prj_switch/tmp/rootfs-build/sda_xgs/.scannerwork
INFO: Load project settings for component key: 'switch_sda_xgs:sda'
INFO: Load project settings for component key: 'switch_sda_xgs:sda' (done) | time=28ms
INFO: Load project branches
INFO: Load project branches (done) | time=15ms
INFO: Load branch configuration
INFO: Found manual configuration of branch/PR analysis. Skipping automatic configuration.
INFO: Load branch configuration (done) | time=1ms
INFO: Load quality profiles
INFO: Load quality profiles (done) | time=65ms
INFO: Load active rules
INFO: Load active rules (done) | time=1804ms
INFO: Load analysis cache
INFO: Load analysis cache (404) | time=7ms
INFO: Pull request 322869 for merge into maintain_1.24.0 from refs/for/maintain_1.24.0
WARN: The properties 'sonar.login' and 'sonar.password' are deprecated and will be removed in the future. Please pass a token with the 'sonar.token' property instead.
INFO: Load project repositories
INFO: Load project repositories (done) | time=44ms
INFO: SCM collecting changed files in the branch
INFO: Merge base sha1: e863109481ef19ed98e6f819ee9357721c28107f
INFO: SCM collecting changed files in the branch (done) | time=152ms
INFO: Indexing files...
INFO: Project configuration:
INFO:   Excluded sources: xgs_sda_sw_deb/**
WARN: Not indexing due to symlink loop: /work_build-sw_12_5_SPJ40/prj_switch/tmp/rootfs-build/sda_xgs/xgs_sda_sw_deb/tmp/build/app
INFO: 0 files indexed
INFO: 2533 files ignored because of inclusion/exclusion patterns
INFO: 833 files ignored because of scm ignore settings
drwxr-xr-x.  8 root root  250 May 22 18:09 ./
drwxr-xr-x. 11 root root 4096 May 22 16:41 ../
drwxr-xr-x.  2 root root   48 May 22 18:10 .scannerwork/
drwxr-xr-x.  8 root root   88 May 22 16:41 include/
-rw-r--r--.  1 root root  518 May 22 16:41 make_ltsw_sda.sh
-rwxr-xr-x.  1 root root  529 May 22 16:41 make_sda.sh*
-rw-r--r--.  1 root root  532 May 22 16:41 make_sim_sda.sh
drwxr-xr-x.  5 root root   53 May 22 16:41 sim_sda_deb/
-rw-r--r--.  1 root root 1205 May 22 18:02 sonar-project.properties
drwxr-xr-x. 18 root root  233 May 22 16:41 source/
-rw-r--r--.  1 root root  721 May 22 16:41 switch_asic_driver.mk
drwxr-xr-x.  6 root root   71 May 22 16:41 xgs_sda_ltsw_sw_deb/
drwxr-xr-x.  7 root root   82 May 22 16:41 xgs_sda_sw_deb/

When I add -X, got this

10:40:05.342 DEBUG: Will ignore generated code
10:40:05.343 DEBUG: Will ignore generated code
10:40:05.355 INFO: Indexing files...
10:40:05.356 INFO: Project configuration:
10:40:05.356 INFO:   Excluded sources: xgs_sda_sw_deb/**
10:40:05.387 DEBUG: 1 non excluded files in this Git repository
10:40:05.394 DEBUG: File '/work_build-sw_12_5_SPJ40/prj_switch/tmp/rootfs-build/sda_xgs/make_ltsw_sda.sh' is excluded by the scm ignore settings.
10:40:05.395 DEBUG: File '/work_build-sw_12_5_SPJ40/prj_switch/tmp/rootfs-build/sda_xgs/make_sda.sh' is excluded by the scm ignore settings.
10:40:05.396 DEBUG: File '/work_build-sw_12_5_SPJ40/prj_switch/tmp/rootfs-build/sda_xgs/make_sim_sda.sh' is excluded by the scm ignore settings.
10:40:05.397 DEBUG: File '/work_build-sw_12_5_SPJ40/prj_switch/tmp/rootfs-build/sda_xgs/switch_asic_driver.mk' is excluded by the scm ignore settings.
10:40:05.398 DEBUG: File '/work_build-sw_12_5_SPJ40/prj_switch/tmp/rootfs-build/sda_xgs/xgs_sda_ltsw_sw_deb/301_sdk_ko/make/sdk_ko.mk' is excluded by the scm ignore settings.
......

There was not .gitignore file in the repo

I want know how ths sonar-scanner work .

Hey there.

It doesn’t look like there’s a .git folder either… what SCM are you using?

It’s use git

the repo floder is xgs

drwxr-xr-x. 12 root root  201 May 23 18:50 ./
drwxr-xr-x.  1 root root 4096 May 22 16:11 ../
drwxr-xr-x.  8 root root  198 May 22 15:36 .git/
drwxr-xr-x.  4 root root   31 May 22 15:28 diag_cmd/
drwxr-xr-x.  9 root root  212 May 22 15:28 ltsw-sdk-frm/
drwxr-xr-x.  4 root root   91 May 22 15:54 oob-sda/
drwxr-xr-x.  8 root root  201 May 22 15:28 oob-sdk-frm/
drwxr-xr-x.  9 root root  261 May 22 16:19 sda/
drwxr-xr-x.  6 root root  154 May 22 15:28 sda_pktd/
drwxr-xr-x.  9 root root  212 May 22 15:28 sdk-frm/
drwxr-xr-x.  9 root root  212 May 22 15:28 sim-sdk-frm/

then to perform the compilation, I need to establish a soft link

ln -s xgs/sda xgs_sda

The file corresponding to build-wrapper is in the xgs_sda folder

It’s not clear to me where the exclusions are coming from. I’ll flag this for attention, but in the meantime I suggest adding sonar.scm.exclusions.disabled=true as an analysis parameter.

Hello @zhangjiuwang ,

The issue is because you are starting the analysis from the symbolic link. We are using the JGit library to check for scm ignore settings, and it considers symbolic link as excluded.

If you go in the actual directory to start the analysis (xgs/sda), it should fix your issue.

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