Mismatch in changeset between GH PR and SonarQube

Must-share information (formatted with Markdown):

which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension): SonarQube 8.9.1

what problem do you have?

SonarQube doesn’t properly show coverage. Quite often SonarQube includes changes in the measures that aren’t part of the pull request. For example:

Github changeset:

SonarQube:

How can we fix this?

Hi,

Welcome to the community!

We try to keep it to one topic per thread.

Can you provide your analysis log?

 
HTH,
Ann

Hi, thx.

This is a single topic right?

Where do I find the analysis log in Sonarqube?

BR, Tino

Hi,

The analysis log is what’s output from the analysis command. Hopefully the log you provide will include that command as well.

 
Ann

Ah yes. So this is run from Github Actions:

2022-04-03T16:24:02.4413143Z ##[group]Run docker run -v "$(pwd)"/app:/usr/src/app \
2022-04-03T16:24:02.4413571Z e[36;1mdocker run -v "$(pwd)"/app:/usr/src/app \e[0m
2022-04-03T16:24:02.4414246Z e[36;1m  -e SONAR_HOST_URL="${SONAR_HOST_URL}" \e[0m
2022-04-03T16:24:02.4414589Z e[36;1m  -e SONAR_LOGIN="${SONAR_LOGIN}" \e[0m
2022-04-03T16:24:02.4414933Z e[36;1m  sonarsource/sonar-scanner-cli \e[0m
2022-04-03T16:24:02.4415286Z e[36;1m  -Dsonar.projectKey=solarmonkey-app \e[0m
2022-04-03T16:24:02.4415640Z e[36;1m  -Dsonar.sources=/usr/src/app \e[0m
2022-04-03T16:24:02.4415976Z e[36;1m  -Dsonar.sourceEncoding=UTF-8 \e[0m
2022-04-03T16:24:02.4416331Z e[36;1m  -Dsonar.projectVersion="${VERSION}" \e[0m
2022-04-03T16:24:02.4416712Z e[36;1m  -Dsonar.pullrequest.key="${PR_NUMBER}" \e[0m
2022-04-03T16:24:02.4417092Z e[36;1m  -Dsonar.pullrequest.branch="${BRANCH}" \e[0m
2022-04-03T16:24:02.4417466Z e[36;1m  -Dsonar.pullrequest.base=master \e[0m
2022-04-03T16:24:02.4417818Z e[36;1m  -Dsonar.qualitygate.wait=true \e[0m
2022-04-03T16:24:02.4418279Z e[36;1m  -Dsonar.python.coverage.reportPaths=/usr/src/app/coverage.xmle[0m
2022-04-03T16:24:02.4471200Z shell: /usr/bin/bash -e {0}
2022-04-03T16:24:02.4471496Z env:
2022-04-03T16:24:02.4472124Z   SONAR_LOGIN: ***
2022-04-03T16:24:02.4472484Z   SONAR_HOST_URL: https://sonarqube.xxxxx.xxx
2022-04-03T16:24:02.4472859Z   VERSION: 711392f56de163fea715da5afe6e04b882544746
2022-04-03T16:24:02.4473176Z   BRANCH: tino/plan-rename
2022-04-03T16:24:02.4473451Z   PR_NUMBER: 5550
2022-04-03T16:24:02.4473705Z ##[endgroup]
2022-04-03T16:24:02.4909550Z Unable to find image 'sonarsource/sonar-scanner-cli:latest' locally
2022-04-03T16:24:02.7449976Z latest: Pulling from sonarsource/sonar-scanner-cli
2022-04-03T16:24:02.7458095Z cfab2db72209: Pulling fs layer
2022-04-03T16:24:02.7458414Z fef04d1b139f: Pulling fs layer
2022-04-03T16:24:02.7458710Z fb0c0aefeee8: Pulling fs layer
2022-04-03T16:24:02.8007714Z fb0c0aefeee8: Verifying Checksum
2022-04-03T16:24:02.8008127Z fb0c0aefeee8: Download complete
2022-04-03T16:24:02.8359071Z cfab2db72209: Verifying Checksum
2022-04-03T16:24:02.8359445Z cfab2db72209: Download complete
2022-04-03T16:24:03.0585229Z cfab2db72209: Pull complete
2022-04-03T16:24:03.7048155Z fef04d1b139f: Verifying Checksum
2022-04-03T16:24:03.7048535Z fef04d1b139f: Download complete
2022-04-03T16:24:09.2105420Z fef04d1b139f: Pull complete
2022-04-03T16:24:09.2782849Z fb0c0aefeee8: Pull complete
2022-04-03T16:24:09.2827355Z Digest: sha256:e3f57825dd43ad7afa0c388cf0e3bb38e9264c5780fc7f4f81e8169252fdfd03
2022-04-03T16:24:09.2847774Z Status: Downloaded newer image for sonarsource/sonar-scanner-cli:latest
2022-04-03T16:24:09.7262229Z INFO: Scanner configuration file: /opt/sonar-scanner/conf/sonar-scanner.properties
2022-04-03T16:24:09.7269091Z INFO: Project root configuration file: NONE
2022-04-03T16:24:09.7616417Z INFO: SonarScanner 4.7.0.2747
2022-04-03T16:24:09.7617097Z INFO: Java 11.0.14 Alpine (64-bit)
2022-04-03T16:24:09.7621349Z INFO: Linux 5.11.0-1028-azure amd64
2022-04-03T16:24:10.0686633Z INFO: User cache: /opt/sonar-scanner/.sonar/cache
2022-04-03T16:24:11.7608214Z INFO: Scanner configuration file: /opt/sonar-scanner/conf/sonar-scanner.properties
2022-04-03T16:24:11.7612134Z INFO: Project root configuration file: NONE
2022-04-03T16:24:11.7774790Z INFO: Analyzing on SonarQube server 8.9.1
2022-04-03T16:24:11.7777027Z INFO: Default locale: "en_US", source code encoding: "UTF-8"
2022-04-03T16:24:12.1711011Z INFO: Load global settings
2022-04-03T16:24:12.4025100Z INFO: Load global settings (done) | time=232ms
2022-04-03T16:24:12.4081479Z INFO: Server id: 243B8A4D-AXp7x0NjDXvFMB4ptHT8
2022-04-03T16:24:12.4112885Z INFO: User cache: /opt/sonar-scanner/.sonar/cache
2022-04-03T16:24:12.4138874Z INFO: Load/download plugins
2022-04-03T16:24:12.4139175Z INFO: Load plugins index
2022-04-03T16:24:12.5563047Z INFO: Load plugins index (done) | time=142ms
2022-04-03T16:24:20.7049096Z INFO: Load/download plugins (done) | time=8291ms
2022-04-03T16:24:21.2481087Z INFO: Process project properties
2022-04-03T16:24:21.2571795Z INFO: Process project properties (done) | time=9ms
2022-04-03T16:24:21.2580635Z INFO: Execute project builders
2022-04-03T16:24:21.2600634Z INFO: Execute project builders (done) | time=2ms
2022-04-03T16:24:21.2631966Z INFO: Project key: solarmonkey-app
2022-04-03T16:24:21.2638854Z INFO: Base dir: /usr/src
2022-04-03T16:24:21.2645438Z INFO: Working dir: /usr/src/.scannerwork
2022-04-03T16:24:21.3813056Z INFO: Load project settings for component key: 'solarmonkey-app'
2022-04-03T16:24:21.4864653Z INFO: Load project settings for component key: 'solarmonkey-app' (done) | time=105ms
2022-04-03T16:24:21.5147184Z INFO: Load project branches
2022-04-03T16:24:21.6265136Z INFO: Load project branches (done) | time=119ms
2022-04-03T16:24:21.6288294Z INFO: Load project pull requests
2022-04-03T16:24:21.9007305Z INFO: Load project pull requests (done) | time=272ms
2022-04-03T16:24:21.9007709Z INFO: Load branch configuration
2022-04-03T16:24:21.9024191Z INFO: Load branch configuration (done) | time=1ms
2022-04-03T16:24:21.9405289Z INFO: Load quality profiles
2022-04-03T16:24:22.0929358Z INFO: Load quality profiles (done) | time=153ms
2022-04-03T16:24:22.1049898Z INFO: Load active rules
2022-04-03T16:24:24.4632404Z INFO: Load active rules (done) | time=2359ms
2022-04-03T16:24:24.4777738Z INFO: Pull request 5550 for merge into master from tino/plan-rename
2022-04-03T16:24:24.5175338Z INFO: Indexing files...
2022-04-03T16:24:24.5180221Z INFO: Project configuration:
2022-04-03T16:24:24.5188504Z INFO:   Excluded sources: **/migrations/*.py, **/static/admin/**, **/tests/data/**, **/vega_embed.js, **/coverage.xml, **/templates/**, **/static/**, **/coverage/jest/**, **/coverage/mocha/**, **/test_*.py
2022-04-03T16:24:24.5192249Z INFO:   Included tests: **/test_*.py
2022-04-03T16:24:24.9575620Z INFO: 1155 files indexed
2022-04-03T16:24:24.9585890Z INFO: 849 files ignored because of inclusion/exclusion patterns
2022-04-03T16:24:24.9597898Z INFO: Quality profile for py: Sonar way
2022-04-03T16:24:24.9604592Z INFO: ------------- Run sensors on module solarmonkey-app
2022-04-03T16:24:25.0452107Z INFO: Load metrics repository
2022-04-03T16:24:25.1544017Z INFO: Load metrics repository (done) | time=109ms
2022-04-03T16:24:26.0243368Z INFO: Sensor Python Sensor [python]
2022-04-03T16:24:26.0325265Z INFO: Starting global symbols computation
2022-04-03T16:24:26.0445029Z INFO: 868 source files to be analyzed
2022-04-03T16:24:26.0466662Z INFO: Load project repositories
2022-04-03T16:24:26.2437842Z INFO: Load project repositories (done) | time=196ms
2022-04-03T16:24:36.0470820Z INFO: 251/868 files analyzed, current file: app/solarservice/shared/sqlutils/migrate.py
2022-04-03T16:24:42.7132250Z INFO: 868/868 source files have been analyzed
2022-04-03T16:24:42.7132667Z INFO: Starting rules execution
2022-04-03T16:24:42.7306487Z INFO: 868 source files to be analyzed
2022-04-03T16:24:52.7309341Z INFO: 381/868 files analyzed, current file: app/auth/users/apps.py
2022-04-03T16:25:01.2764776Z INFO: 868/868 source files have been analyzed
2022-04-03T16:25:01.2765235Z INFO: Sensor Python Sensor [python] (done) | time=35252ms
2022-04-03T16:25:01.2765625Z INFO: Sensor Cobertura Sensor for Python coverage [python]
2022-04-03T16:25:01.3141301Z INFO: Python test coverage
2022-04-03T16:25:01.3172511Z INFO: Parsing report '/usr/src/app/coverage.xml'
2022-04-03T16:25:01.7522477Z INFO: Sensor Cobertura Sensor for Python coverage [python] (done) | time=475ms
2022-04-03T16:25:01.7526793Z INFO: Sensor PythonXUnitSensor [python]
2022-04-03T16:25:01.7826795Z INFO: Sensor PythonXUnitSensor [python] (done) | time=29ms
2022-04-03T16:25:01.7828954Z INFO: Sensor CSS Rules [cssfamily]
2022-04-03T16:25:01.7877129Z INFO: No CSS, PHP, HTML or VueJS files are found in the project. CSS analysis is skipped.
2022-04-03T16:25:01.7879411Z INFO: Sensor CSS Rules [cssfamily] (done) | time=5ms
2022-04-03T16:25:01.7882670Z INFO: Sensor JaCoCo XML Report Importer [jacoco]
2022-04-03T16:25:01.7935693Z 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
2022-04-03T16:25:01.7945246Z INFO: No report imported, no coverage information will be imported by JaCoCo XML Report Importer
2022-04-03T16:25:01.7948240Z INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=7ms
2022-04-03T16:25:01.7951498Z INFO: Sensor C# Project Type Information [csharp]
2022-04-03T16:25:01.7972554Z INFO: Sensor C# Project Type Information [csharp] (done) | time=2ms
2022-04-03T16:25:01.7975571Z INFO: Sensor C# Properties [csharp]
2022-04-03T16:25:01.7987813Z INFO: Sensor C# Properties [csharp] (done) | time=1ms
2022-04-03T16:25:01.7990687Z INFO: Sensor JavaXmlSensor [java]
2022-04-03T16:25:01.8057309Z INFO: Sensor JavaXmlSensor [java] (done) | time=7ms
2022-04-03T16:25:01.8059859Z INFO: Sensor HTML [web]
2022-04-03T16:25:01.8114214Z INFO: Sensor HTML [web] (done) | time=5ms
2022-04-03T16:25:01.8117108Z INFO: Sensor VB.NET Project Type Information [vbnet]
2022-04-03T16:25:01.8141364Z INFO: Sensor VB.NET Project Type Information [vbnet] (done) | time=2ms
2022-04-03T16:25:01.8144301Z INFO: Sensor VB.NET Properties [vbnet]
2022-04-03T16:25:01.8155381Z INFO: Sensor VB.NET Properties [vbnet] (done) | time=1ms
2022-04-03T16:25:01.8158526Z INFO: Sensor com.github.mc1arke.sonarqube.plugin.scanner.ScannerPullRequestPropertySensor
2022-04-03T16:25:01.8186731Z INFO: Sensor com.github.mc1arke.sonarqube.plugin.scanner.ScannerPullRequestPropertySensor (done) | time=3ms
2022-04-03T16:25:01.8236233Z INFO: ------------- Run sensors on project
2022-04-03T16:25:01.8394413Z INFO: Sensor Zero Coverage Sensor
2022-04-03T16:25:01.8551100Z INFO: Sensor Zero Coverage Sensor (done) | time=16ms
2022-04-03T16:25:01.8565428Z INFO: SCM Publisher is disabled
2022-04-03T16:25:02.0234558Z INFO: CPD Executor 260 files had no CPD blocks
2022-04-03T16:25:02.0237605Z INFO: CPD Executor Calculating CPD for 608 files
2022-04-03T16:25:02.2324117Z INFO: CPD Executor CPD calculation finished (done) | time=208ms
2022-04-03T16:25:02.3993545Z INFO: Analysis report generated in 120ms, dir size=1 MB
2022-04-03T16:25:03.3427076Z INFO: Analysis report compressed in 942ms, zip size=929 KB
2022-04-03T16:25:03.8108065Z INFO: Analysis report uploaded in 468ms
2022-04-03T16:25:03.8123338Z INFO: ------------- Check Quality Gate status
2022-04-03T16:25:03.8125996Z INFO: Waiting for the analysis report to be processed (max 300s)
2022-04-03T16:25:09.1166108Z INFO: QUALITY GATE STATUS: PASSED - View details on https://sonarqube.xxxxx.xxx/dashboard?id=solarmonkey-app&pullRequest=5550
2022-04-03T16:25:09.2150125Z INFO: Analysis total time: 48.369 s
2022-04-03T16:25:09.2179522Z INFO: ------------------------------------------------------------------------
2022-04-03T16:25:09.2179982Z INFO: EXECUTION SUCCESS
2022-04-03T16:25:09.2180478Z INFO: ------------------------------------------------------------------------
2022-04-03T16:25:09.2191439Z INFO: Total time: 59.493s
2022-04-03T16:25:09.3191720Z INFO: Final Memory: 9M/37M
2022-04-03T16:25:09.3198170Z INFO: ------------------------------------------------------------------------

Hi,

Here’s the problem:

Without SCM data, how can SonarQube know what PR to decorate?

 
:smiley:
Ann

Right, I turned it off because it said somewhere that could interfere :sweat_smile:.

I managed to fix it, by also making sure the .git directory was present in the docker container, and setting the -Dsonar.projectBaseDir= to the git root directory.

It seems to be working now, thanks!

1 Like