SonarQube Has no lines of code

Pproduct: SonarQube developer edition
XCode Version: 13.0
Platform: iOS
Language: Swift

Hi,

I added empty line for check the line number of sonar analysis report. The line is empty. But I fixed my issue by running only sonar-scanner command with the line of ‘sonar.coverageReportPaths=sonarqube-generic-coverage.xml’ in sonar-project.properties file.

image

But I have already struggled with issue to sonar analysis report to sonar side. I added sonar zip file that contains sonarqube-generic-coverage.xml, xccov-to-sonarqube-generic.sh, run-sonar-swift.sh, sonar-project.properties (without login key) and all terminal log with executed sh file and bash command for generic coverage file.

Sonar.zip (115.1 KB)

Please help.

Hi,

Thanks for including your analysis log in the OP. It makes the problem pretty clear:

INFO: Project configuration:
INFO:   Included sources: *.swift
INFO:   Excluded sources: **/*.xml, Pods/**/*, *.swift
INFO:   Included tests: *.swift
INFO: 0 files indexed
INFO: 26088 files ignored because of inclusion/exclusion patterns

 
HTH,
Ann

Hi ,

I don’t understand where is the Excluded sources: *.swift line. Becuase I added inclusion for *.swift file inside sonar-project properties

Thank you for reply.

Hi,

I don’t understand where it’s coming from either, but inclusions and exclusions are not… exclusive. As you see, you can have both and the same things can appear in both.

I did glance at your properties file, and saw that there’s a lot going on in there, with a lot of properties I don’t recognize (i.e. that have no effect on analysis).

I suggest you strip this down to the bare minimum by removing your properties file and just providing URL, project key and token on the command line. See if that gets you what you want, and build back up from there.

 
Ann

Hi,

I changed file with this content but analysis is not correct. Could you guide me how to do ?

Report

All log:

adinler@Arda-Dinler-MacBook-Pro-C02WW1Q2HTD6 ugconnecttruckv2mobileios % sonar-scanner

INFO: Scanner configuration file: /usr/local/Cellar/sonar-scanner/4.7.0.2747/libexec/conf/sonar-scanner.properties

INFO: Project root configuration file: /Users/adinler/Documents/ugconnecttruckv2mobileios/sonar-project.properties

INFO: SonarScanner 4.7.0.2747

INFO: Java 11.0.16.1 Homebrew (64-bit)

INFO: Mac OS X 12.4 x86_64

INFO: User cache: /Users/adinler/.sonar/cache

INFO: Scanner configuration file: /usr/local/Cellar/sonar-scanner/4.7.0.2747/libexec/conf/sonar-scanner.properties

INFO: Project root configuration file: /Users/adinler/Documents/ugconnecttruckv2mobileios/sonar-project.properties

INFO: Analyzing on SonarQube server 8.9.7

INFO: Default locale: "en_TR", source code encoding: "UTF-8" (analysis is platform dependent)

INFO: Load global settings

INFO: Load global settings (done) | time=275ms

INFO: Server id: 2C346A59-AX_QsdAGDfT95r9IT9Tm

INFO: User cache: /Users/adinler/.sonar/cache

INFO: Load/download plugins

INFO: Load plugins index

INFO: Load plugins index (done) | time=96ms

INFO: Load/download plugins (done) | time=138ms

INFO: Loaded core extensions: developer-scanner

INFO: Process project properties

INFO: Process project properties (done) | time=9ms

INFO: Project key: tr.com.fordotosan.fordtrucks

INFO: Base dir: /Users/adinler/Documents/ugconnecttruckv2mobileios

INFO: Working dir: /Users/adinler/Documents/ugconnecttruckv2mobileios/.scannerwork

INFO: Load project settings for component key: 'tr.com.fordotosan.fordtrucks'

INFO: Load project settings for component key: 'tr.com.fordotosan.fordtrucks' (done) | time=105ms

INFO: Load project branches

INFO: Load project branches (done) | time=75ms

INFO: Load project pull requests

INFO: Load project pull requests (done) | time=53ms

INFO: Load branch configuration

INFO: Load branch configuration (done) | time=1ms

INFO: Load quality profiles

INFO: Load quality profiles (done) | time=86ms

INFO: Load active rules

INFO: Load active rules (done) | time=383ms

INFO: Indexing files...

INFO: Project configuration:

INFO: 18 files indexed

INFO: 0 files ignored because of scm ignore settings

INFO: Quality profile for swift: Sonar way

INFO: ------------- Run sensors on module FordTrucksiOS

INFO: Load metrics repository

INFO: Load metrics repository (done) | time=57ms

INFO: ------------- Run sensors on project

INFO: Sensor Zero Coverage Sensor

INFO: Sensor Zero Coverage Sensor (done) | time=0ms

INFO: Load project repositories

INFO: Load project repositories (done) | time=101ms

INFO: SCM Publisher SCM provider for this project is: git

INFO: SCM Publisher 17 source files to be analyzed

INFO: SCM Publisher 17/17 source files have been analyzed (done) | time=383ms

INFO: CPD Executor Calculating CPD for 0 files

INFO: CPD Executor CPD calculation finished (done) | time=0ms

INFO: Load New Code definition

INFO: Load New Code definition (done) | time=63ms

INFO: Analysis report generated in 134ms, dir size=67 KB

INFO: Analysis report compressed in 56ms, zip size=23 KB

INFO: Analysis report uploaded in 97ms

INFO: ANALYSIS SUCCESSFUL, you can browse https://sonarqubedev.ford.com.tr/dashboard?id=tr.com.fordotosan.fordtrucks

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 https://sonarqubedev.ford.com.tr/api/ce/task?id=AYLQz5k0kcLglC11Lx-V

INFO: Analysis total time: 2.870 s

INFO: ------------------------------------------------------------------------

INFO: EXECUTION SUCCESS

INFO: ------------------------------------------------------------------------

INFO: Total time: 5.213s

INFO: Final Memory: 7M/30M

INFO: ------------------------------------------------------------------------

adinler@Arda-Dinler-MacBook-Pro-C02WW1Q2HTD6 ugconnecttruckv2mobileios %

Thanks

Hi,

First, none of the sonar.swift properties shown in your sonar-project.properties file are having any effect. That’s one reason I advised you to provide the bare minimum on the command line. As described in the docs parameters provided on the command line override all others. And since neither of us knew where that *.swift exclusion was coming from, that seemed like the best place to try to provide a definitive property set. But oh well.

You’re saying the analysis you got is not correct, but from the fact that you’ve got a project homepage in the UI, it appears that analysis did work.

So what’s not correct about this? Could you provide a screenshot of the Size metrics on your Measures tab? (Or whatever measures you feel are most relevant?) E.G.

 
Ann

Hi Ann,

Code is empty on sonarqube, I know project have a dublication of codes (%9.9 percent) but I haven’t seen any of code duplications and any unit test coverage on sonarqube.

Coverage File:

Dashboard of FordTrucksiOS SonarQube :

Why “The main branch of this project is empty.” :slight_smile:

Terminal Log:

This is my FirebaseInitializationService.swift File:

sonar-project.properties file

sonar.host.url=https://sonarqubedev.ford.com.tr/
sonar.login=MYKEY
sonar.projectKey=tr.com.fordotosan.fordtrucks
sonar.projectName=FordTrucksiOS
sonar.language=swift
sonar.c.file.suffixes=-
sonar.cpp.file.suffixes=-
sonar.objc.file.suffixes=-
sonar.sources=.
sonar.test.inclusions=/Test/
sonar.exclusions=/*.xml,Pods//*
sonar.tests=FordTrucksTests
sonar.swift.simulator=platform=iOS Simulator,name=iPhone 12,OS=15.0
sonar.swift.project=FordTrucks.xcodeproj
sonar.swift.workspace=FordTrucks.xcworkspace
sonar.swift.appName=FordTrucks
sonar.swift.appScheme=FordTrucks
sonar.coverageReportPaths=sonarqube-generic-coverage.xml

Thanks for your time

Hi,

I fixes issue by removing xctestresult file inside DerivedData folder.

After that, clean project, build and test respectively. Then execute bash command for generating generic coverage ( bash ./xccov-to-sonarqube-generic.sh DerivedData/Logs/Test*.xcresult/ > sonarqube-generic-coverage.xml).

All problem fixes. Also coverage report has succesfully migrated to sonar platform.

Thanks for your time

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