I am trying to perform a static code analysis on my C project. However it fails with sonar-scanner step.
sonarQube Version: sonarqube-9.3.0.51899
scanner: SonarScanner 4.6.2.2472
server was hosted locally as can be seen in the following log:
C:\swapnil\tools\sonarqube-9.3.0.51899\bin\windows-x86-64>StartSonar.bat
wrapper | --> Wrapper Started as Console
wrapper | Launching a JVM...
jvm 1 | Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org
jvm 1 | Copyright 1999-2006 Tanuki Software, Inc. All Rights Reserved.
jvm 1 |
jvm 1 | 2022.02.10 14:19:45 INFO app[][o.s.a.AppFileSystem] Cleaning or creating temp directory C:\swapnil\tools\sonarqube-9.3.0.51899\temp
jvm 1 | 2022.02.10 14:19:45 INFO app[][o.s.a.es.EsSettings] Elasticsearch listening on [HTTP: 127.0.0.1:9001, TCP: 127.0.0.1:64947]
jvm 1 | 2022.02.10 14:19:45 INFO app[][o.s.a.ProcessLauncherImpl] Launch process[[key='es', ipcIndex=1, logFilenamePrefix=es]] from [C:\swapnil\tools\sonarqube-9.3.0.51899\elasticsearch]: C:\Program Files\Java\jdk-11.0.13\bin\java -XX:+UseG1GC -Djava.io.tmpdir=C:\swapnil\tools\sonarqube-9.3.0.51899\temp -XX:ErrorFile=../logs/es_hs_err_pid%p.log -Des.networkaddress.cache.ttl=60 -Des.networkaddress.cache.negative.ttl=10 -XX:+AlwaysPreTouch -Xss1m -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djna.nosys=true -Djna.tmpdir=C:\swapnil\tools\sonarqube-9.3.0.51899\temp -XX:-OmitStackTraceInFastThrow -Dio.netty.noUnsafe=true -Dio.netty.noKeySetOptimization=true -Dio.netty.recycler.maxCapacityPerThread=0 -Dio.netty.allocator.numDirectArenas=0 -Dlog4j.shutdownHookEnabled=false -Dlog4j2.disable.jmx=true -Dlog4j2.formatMsgNoLookups=true -Djava.locale.providers=COMPAT -Dcom.redhat.fips=false -Xmx512m -Xms512m -XX:MaxDirectMemorySize=256m -XX:+HeapDumpOnOutOfMemoryError -Delasticsearch -Des.path.home=C:\swapnil\tools\sonarqube-9.3.0.51899\elasticsearch -Des.path.conf=C:\swapnil\tools\sonarqube-9.3.0.51899\temp\conf\es -cp lib/* org.elasticsearch.bootstrap.Elasticsearch
jvm 1 | 2022.02.10 14:19:45 INFO app[][o.s.a.SchedulerImpl] Waiting for Elasticsearch to be up and running
jvm 1 | 2022.02.10 14:19:54 INFO app[][o.s.a.SchedulerImpl] Process[es] is up
jvm 1 | 2022.02.10 14:19:54 INFO app[][o.s.a.ProcessLauncherImpl] Launch process[[key='web', ipcIndex=2, logFilenamePrefix=web]] from [C:\swapnil\tools\sonarqube-9.3.0.51899]: C:\Program Files\Java\jdk-11.0.13\bin\java -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djava.io.tmpdir=C:\swapnil\tools\sonarqube-9.3.0.51899\temp -XX:-OmitStackTraceInFastThrow --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED --add-exports=java.base/jdk.internal.ref=ALL-UNNAMED --add-opens=java.base/java.nio=ALL-UNNAMED --add-opens=java.base/sun.nio.ch=ALL-UNNAMED --add-opens=java.management/sun.management=ALL-UNNAMED --add-opens=jdk.management/com.sun.management.internal=ALL-UNNAMED -Dcom.redhat.fips=false -Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError -Dhttp.nonProxyHosts=localhost|127.*|[::1] -cp ./lib/sonar-application-9.3.0.51899.jar;C:\swapnil\tools\sonarqube-9.3.0.51899\lib\jdbc\h2\h2-1.4.199.jar org.sonar.server.app.WebServer C:\swapnil\tools\sonarqube-9.3.0.51899\temp\sq-process8181759043686951774properties
jvm 1 | 2022.02.10 14:20:08 INFO app[][o.s.a.SchedulerImpl] Process[web] is up
jvm 1 | 2022.02.10 14:20:08 INFO app[][o.s.a.ProcessLauncherImpl] Launch process[[key='ce', ipcIndex=3, logFilenamePrefix=ce]] from [C:\swapnil\tools\sonarqube-9.3.0.51899]: C:\Program Files\Java\jdk-11.0.13\bin\java -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djava.io.tmpdir=C:\swapnil\tools\sonarqube-9.3.0.51899\temp -XX:-OmitStackTraceInFastThrow --add-opens=java.base/java.util=ALL-UNNAMED --add-exports=java.base/jdk.internal.ref=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.nio=ALL-UNNAMED --add-opens=java.base/sun.nio.ch=ALL-UNNAMED --add-opens=java.management/sun.management=ALL-UNNAMED --add-opens=jdk.management/com.sun.management.internal=ALL-UNNAMED -Dcom.redhat.fips=false -Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError -Dhttp.nonProxyHosts=localhost|127.*|[::1] -cp ./lib/sonar-application-9.3.0.51899.jar;C:\swapnil\tools\sonarqube-9.3.0.51899\lib\jdbc\h2\h2-1.4.199.jar org.sonar.ce.app.CeServer C:\swapnil\tools\sonarqube-9.3.0.51899\temp\sq-process3552908400731558858properties
jvm 1 | 2022.02.10 14:20:12 INFO app[][o.s.a.SchedulerImpl] Process[ce] is up
jvm 1 | 2022.02.10 14:20:12 INFO app[][o.s.a.SchedulerImpl] SonarQube is up
Later build wrapper step was also sucessfully performed:
C:\swapnil\Project\SWAPNIL_PROJECT\NoLeak>build-wrapper-win-x86-64.exe --out-dir bw_output cmake.exe --build C:/swapnil/Project/SWAPNIL_PROJECT/NoLeak/build-firmware-NoLeak-Debug --target all
[134/134] Linking C executable NoLeak.elf
However sonar-scanner gives followig Error:
C:\swapnil\Project\SWAPNIL_PROJECT\NoLeak>sonar-scanner
INFO: Scanner configuration file: NONE
INFO: Project root configuration file: C:\swapnil\Project\SWAPNIL_PROJECT\NoLeak\sonar-project.properties
INFO: SonarScanner 4.6.2.2472
INFO: Java 11.0.11 AdoptOpenJDK (64-bit)
INFO: Windows 10 10.0 amd64
INFO: User cache: C:\Users\u25j78\.sonar\cache
INFO: Scanner configuration file: NONE
INFO: Project root configuration file: C:\swapnil\Project\SWAPNIL_PROJECT\NoLeak\sonar-project.properties
INFO: Analyzing on SonarQube server 9.3.0
INFO: Default locale: "en_IN", source code encoding: "UTF-8"
INFO: Load global settings
INFO: Load global settings (done) | time=168ms
INFO: Server id: BF41A1F2-AX66sggETEuZGqnrZshW
INFO: User cache: C:\Users\u25j78\.sonar\cache
INFO: Load/download plugins
INFO: Load plugins index
INFO: Load plugins index (done) | time=144ms
INFO: Load/download plugins (done) | time=263ms
INFO: Loaded core extensions: developer-scanner
INFO: Process project properties
INFO: Process project properties (done) | time=6ms
INFO: Execute project builders
INFO: Execute project builders (done) | time=2ms
INFO: Project key: swapnil
INFO: Base dir: C:\swapnil\Project\SWAPNIL_PROJECT\NoLeak
INFO: Working dir: C:\swapnil\Project\SWAPNIL_PROJECT\NoLeak\.scannerwork
INFO: Load project settings for component key: 'swapnil'
INFO: Load project settings for component key: 'swapnil' (done) | time=135ms
INFO: Load project branches
INFO: Load project branches (done) | time=121ms
INFO: Load project pull requests
INFO: Load project pull requests (done) | time=120ms
INFO: Load branch configuration
INFO: Load branch configuration (done) | time=1ms
INFO: Load quality profiles
INFO: Load quality profiles (done) | time=154ms
INFO: Load active rules
INFO: Load active rules (done) | time=4796ms
INFO: Indexing files...
INFO: Project configuration:
INFO: 1096 files indexed
INFO: 1009 files ignored because of scm ignore settings
INFO: Quality profile for c: Sonar way
INFO: Quality profile for json: Sonar way
INFO: Quality profile for xml: Sonar way
INFO: ------------- Run sensors on module swapnil
INFO: Load metrics repository
INFO: Load metrics repository (done) | time=125ms
INFO: Sensor IaC CloudFormation Sensor [iac]
INFO: Load project repositories
INFO: Load project repositories (done) | time=123ms
INFO: 0 source files to be analyzed
INFO: 0/0 source files have been analyzed
INFO: Sensor IaC CloudFormation Sensor [iac] (done) | time=482ms
INFO: Sensor C# Project Type Information [csharp]
INFO: Sensor C# Project Type Information [csharp] (done) | time=1ms
INFO: Sensor C# Analysis Log [csharp]
INFO: Sensor C# Analysis Log [csharp] (done) | time=10ms
INFO: Sensor C# Properties [csharp]
INFO: Sensor C# Properties [csharp] (done) | time=3ms
INFO: Sensor HTML [web]
INFO: Sensor HTML [web] (done) | time=6ms
INFO: Sensor XML Sensor [xml]
INFO: 2 source files to be analyzed
INFO: 2/2 source files have been analyzed
INFO: Sensor XML Sensor [xml] (done) | time=257ms
INFO: Sensor Text Sensor [text]
INFO: 320 source files to be analyzed
INFO: 320/320 source files have been analyzed
INFO: Sensor Text Sensor [text] (done) | time=163ms
INFO: Sensor VB.NET Project Type Information [vbnet]
INFO: Sensor VB.NET Project Type Information [vbnet] (done) | time=2ms
INFO: Sensor VB.NET Analysis Log [vbnet]
INFO: Sensor VB.NET Analysis Log [vbnet] (done) | time=11ms
INFO: Sensor VB.NET Properties [vbnet]
INFO: Sensor VB.NET Properties [vbnet] (done) | time=0ms
INFO: Sensor JaCoCo XML Report Importer [jacoco]
INFO: 'sonar.coverage.jacoco.xmlReportPaths' is not defined. Using default locations: target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml
INFO: No report imported, no coverage information will be imported by JaCoCo XML Report Importer
INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=7ms
INFO: Sensor CSS Rules [javascript]
INFO: No CSS, PHP, HTML or VueJS files are found in the project. CSS analysis is skipped.
INFO: Sensor CSS Rules [javascript] (done) | time=2ms
INFO: Sensor ThymeLeaf template sensor [securityjavafrontend]
INFO: Sensor ThymeLeaf template sensor [securityjavafrontend] (done) | time=3ms
INFO: Sensor Serverless configuration file sensor [security]
INFO: 0 Serverless function entries were found in the project
INFO: 0 Serverless function handlers were kept as entrypoints
INFO: Sensor Serverless configuration file sensor [security] (done) | time=5ms
INFO: Sensor AWS SAM template file sensor [security]
INFO: Sensor AWS SAM template file sensor [security] (done) | time=2ms
INFO: Sensor CFamily [cpp]
INFO: CFamily plugin version: 6.30.0.42324
INFO: Using build-wrapper output: C:\swapnil\Project\SWAPNIL_PROJECT\NoLeak\bw_output\build-wrapper-dump.json
INFO: Available processors: 12
INFO: Using 4 threads for analysis according to value of "sonar.cfamily.threads" property.
INFO: Cache is explicitly disabled: Optional[false]
INFO: PCH: unique=0 use=0 (forceInclude=0,throughHeader=0,firstInclude=0) out of 0 (forceInclude=0,throughHeader=0)
INFO: SE: 0 out of 0
INFO: Z3 refutation rate: 0 out of 0
INFO: Subprocess(es) done in 28ms
INFO: 0 compilation units analyzed
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 13.791s
INFO: Final Memory: 28M/128M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarScanner execution
java.lang.IllegalStateException: The "build-wrapper-dump.json" file was found but 0 C/C++/Objective-C files were analyzed. Please make sure that:
* you are using the latest version of the build-wrapper and the CFamily analyzer
* you are correctly invoking the scanner with correct configuration
* your compiler is supported
* you are wrapping your build correctly
* you are wrapping a full/clean build
* you are providing the path to the correct build-wrapper output directory
* you are building and analyzing the same source checkout, absolute paths must be identical in build and analysis steps
at com.sonar.cpp.plugin.CFamilySensor.process(CFamilySensor.java:482)
at com.sonar.cpp.plugin.CFamilySensor.execute(CFamilySensor.java:183)
at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:64)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:85)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:62)
at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:79)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:384)
at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:380)
at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:349)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:136)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:72)
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:66)
at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
at com.sun.proxy.$Proxy0.execute(Unknown Source)
at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189)
at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
at org.sonarsource.scanner.cli.Main.execute(Main.java:112)
at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
at org.sonarsource.scanner.cli.Main.main(Main.java:61)
ERROR:
ERROR: Re-run SonarScanner using the -X switch to enable full debug logging.
following is the content of sonar-project.properties file:
#----- Default SonarQube server
sonar.host.url=http://localhost:9000
sonar.login=admin
sonar.password=admin123
sonar.cfamily.threads=4
sonar.cfamily.cache.enabled=false
sonar.cfamily.build-wrapper-output=bw_output
#sonar.cfamily.compile-commands=build-firmware-NoLeak-Debug/compile_commands.json
#----- Default source code encoding
sonar.projectKey=swapnil
sonar.projectName=swapnil
sonar.projectVersion=1.0
sonar.sources=.
sonar.language=c
#sonar.cxx.compiler.parser=GCC
#sonar.cxx.compiler.reportPath=*.log
#sonar.cxx.compiler.charset=UTF-8
sonar.sourceEncoding=UTF-8
sonar.scm.disabled=false
please let me know if you need additional information.
Thank you.