SonarQube only outputting duplicate code Code Smells

sonarqube
sonarcfamily

(Michael Kostek) #1

I am running the Sonar Scanner and can view my results on the SonarQube website, but only get duplicate code as the only kind of issue. The code base is hundreds of thousands of lines of code and I have manually verified there are other rules being broken. I am using one of our enterprise C++ Quality Profiles which has 160+ rules set to active. Any ideas what I’m doing wrong? Here is the output of SonarScanner:

INFO: Scanner configuration file: C:\Users\J64377\Desktop\SonarQube\sonar-scanner-3.3.0.1492-windows\bin\..\conf\sonar-scanner.properties
INFO: Project root configuration file: C:\Users\J64377\scs\sonar-project.properties
INFO: SonarQube Scanner 3.3.0.1492
INFO: Java 1.8.0_121 Oracle Corporation (64-bit)
INFO: Windows 7 6.1 amd64
INFO: User cache: C:\Users\J64377\.sonar\cache
INFO: SonarQube server 7.4.0
INFO: Default locale: "en_US", source code encoding: "UTF-8"
INFO: Publish mode
INFO: Load global settings
INFO: Load global settings (done) | time=234ms
INFO: Server id: 079D80A9-1b0155b627f94ab
INFO: User cache: C:\Users\J64377\.sonar\cache
INFO: Load/download plugins
INFO: Load plugins index
INFO: Load plugins index (done) | time=134ms
INFO: Load/download plugins (done) | time=354ms
INFO: Loaded core extensions: branch-scanner
INFO: Process project properties
INFO: Execute project builders
INFO: Execute project builders (done) | time=4ms
INFO: Load project branches
INFO: Load project branches (done) | time=96ms
INFO: Load project pull requests
INFO: Load project pull requests (done) | time=48ms
INFO: Load branch configuration
INFO: Load branch configuration (done) | time=8ms
INFO: Load project repositories
INFO: Load project repositories (done) | time=632ms
INFO: Load quality profiles
INFO: Load quality profiles (done) | time=89ms
INFO: Load active rules
INFO: Load active rules (done) | time=2025ms
INFO: Load metrics repository
INFO: Load metrics repository (done) | time=66ms
INFO: Project key: SCS
INFO: Project base dir: C:\Users\J64377\scs
INFO: -------------  Scan SCS
INFO: Base dir: C:\Users\J64377\scs
INFO: Working dir: C:\Users\J64377\scs\.scannerwork
INFO: Source paths: src/scs
INFO: Source encoding: UTF-8, default locale: en_US
INFO: Load server rules
INFO: Load server rules (done) | time=333ms
WARN: Property 'sonar.abap.file.suffixes' is not declared as multi-values/property set but was read using 'getStringArray' method. The SonarQube plugin declarin
g this property should be updated.
INFO: Index files
INFO: Included sources:
INFO:   **/*.cpp
INFO:   **/*.c
INFO:   **/*.h
INFO:   **/*.hpp
INFO: 1172 files indexed
INFO: 208 files ignored because of inclusion/exclusion patterns
INFO: Quality profile for c: C Profile
INFO: Quality profile for cpp: C++ Profile
INFO: Sensor SonarJavaXmlFileSensor [java]
INFO: Sensor SonarJavaXmlFileSensor [java] (done) | time=167ms
INFO: Sensor HTML [web]
INFO: Sensor HTML [web] (done) | time=16ms
INFO: Sensor JaCoCo XML Report Importer [jacoco]
INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=6ms
INFO: Sensor CFamily [cpp]
INFO: Using build-wrapper output: C:\Users\J64377\scs\bw_output\build-wrapper-dump.json
INFO: Available processors: 8
INFO: Using 8 threads for analysis according to value of "sonar.cfamily.threads" property.
WARN: Metric 'comment_lines_data' is deprecated. Provided value is ignored.
INFO: 0 compilation units analyzed
INFO: Sensor CFamily [cpp] (done) | time=29715ms
INFO: Sensor Zero Coverage Sensor
INFO: Sensor Zero Coverage Sensor (done) | time=172ms
INFO: Sensor JavaSecuritySensor [security]
INFO: Reading UCFGs from: C:\Users\J64377\scs\.scannerwork\ucfg2\java
INFO: UCFGs: 0, excluded: 0, source entrypoints: 0
INFO: No UCFGs have been included for analysis.
INFO: Sensor JavaSecuritySensor [security] (done) | time=4ms
INFO: Sensor CSharpSecuritySensor [security]
INFO: Reading UCFGs from: C:\Users\J64377\scs\ucfg_cs2
INFO: UCFGs: 0, excluded: 0, source entrypoints: 0
INFO: No UCFGs have been included for analysis.
INFO: Sensor CSharpSecuritySensor [security] (done) | time=1ms
INFO: 60 files had no CPD blocks
INFO: Calculating CPD for 1112 files
INFO: 822/1112 - current file: XXXXXXXXXX
INFO: CPD calculation finished
INFO: Analysis report generated in 62414ms, dir size=26 MB
INFO: Analysis reports compressed in 138252ms, zip size=7 MB
INFO: Analysis report uploaded in 13799ms
INFO: ANALYSIS SUCCESSFUL, you can browse XXXXXXXXX
INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
INFO: Task total time: 9:07.354 s
INFO: ------------------------------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ------------------------------------------------------------------------
INFO: Total time: 9:11.072s
INFO: Final Memory: 77M/1497M
INFO: -----------------------------------------------------

(Massimo Paladin) #2

Hi @MichaelPKostek,

how are you generating the bw_output\build-wrapper-dump.json file? Are you invoking build-wrapper with a clean build?
Is the bw_output\build-wrapper-dump.json empty?


(Michael Kostek) #3

I realized this problem is caused due to generating the build wrapper on Linux and the scanner on Windows. The paths in the wrapper are all wrong in this situation causing this failure. We do not have access to internet on the Linux machines and can’t build on Windows. Any suggestions?


(Massimo Paladin) #4

Hi @MichaelPKostek,

unfortunately no, it is a requirement to have the build and the analysis on the same machine. Cannot you connect from your linux machine to your SonarQube instance? If they are on the same network you don’t need internet access.