How can I analyze the project with the sonar-project.properties file located in the subdirectory?

The relevant section of my project directory is as follows:

> |- Project_Source
  |   >|- configs
  |    |  >|- sonar-project.properties
  |    |  >|- CMakeList.txt
  |    |  >|- // other config files ...
  |   >|- executable
  |   >|- inc
  |   >|- drv
  |   >|- src-common

My commands are as follows:

cd Project_Source
cd configs
mkdir build-sonarqube
cd build-sonarqube
cmake ..
cd ..
build-wrapper-linux-x86-64 --out-dir bw-output cmake --build build-sonarqube/ --config Release 
sonar-scanner -Dsonar.projectKey=... -Dsonar.cfamily.build-wrapper-output=bw-output -Dsonar.host.url=http://... -Dsonar.login=....

Before this editing, the files in the “configs” folder were placed under “project_source” and analysis output was obtained without any problems. Since I wanted to ensure code integrity and keep it in a separate place, I wanted to analyze it by taking it to a subfolder (of course, I rearranged the relative and absolute paths) but as a result, 0 files were analyzed.

The analysis is a success, but the number of scanned files shows 0, what exactly is the reason for this?

You will need to initiate the scan from the root directory you want to scan. If you can’t keep the sonar-project.properties file there, you should point to it as documented

  • The property project.settings can be used to specify the path to the project configuration file (this option is incompatible with the sonar.projectBaseDir property). Ex:
sonar-scanner -Dproject.settings=../myproject.properties

So you mean move the sonar-project.properties file to the root of the project?

It’s one option – or take the other option suggested and use -Dproject.settings to point to the properties file in the subdirectory, while still initiating the scan from the root of the project.

Unfortunately, I tried this command after your previous comment, and the result is successful but the file analysis still shows 0.

I would suggest sharing the logs from your scanner command.

I could not reply because of a long break, there was a place I missed in the path configuration definition, and the problem has been fixed.

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