Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes bullseye conditions to be shown in SQ UI #1237

Merged

Conversation

tomassdepakin
Copy link

@tomassdepakin tomassdepakin commented Sep 22, 2017

Hi. Fixing bug, when bullseye conditions are not shown in SonarQube UI.
Tested with 6.3

Removing unneeded CoverageType from CoverageMeasure. It successfully contains line hits and conditions simultaneously.

Here comes my paint madskillz:
bullseye_before


This change is Reviewable

@Bertk
Copy link
Contributor

Bertk commented Sep 23, 2017

👍 Thanks for this improvement. Did you also check it for SQ 5.6?
I could not find until now any reason why this should not work with SQ 5.6.
http://javadocs.sonarsource.org/5.6/apidocs/org/sonar/api/batch/sensor/coverage/NewCoverage.html

We missed this information (https://docs.sonarqube.org/display/DEV/API+Changes):

DEPRECATED NewCoverage::ofType is deprecated and ignored. It is possible to feed as many coverage reports as you want for the same file. They will be merged without keeping any distinction of their "type".

import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;
import java.util.*;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

squid:S2208 Wildcard imports should not be used

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

try {
if(type == CoverageMeasure.CoverageType.CONDITION) {
newCoverage.lineHits(measure.getLine(), measure.getHits());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

squid:IndentationCheck Make this line start at column 7

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@Bertk
Copy link
Contributor

Bertk commented Sep 23, 2017

The integration tests failed because the coverage values for SQ 5.6 changed (Travis and AppVeyor).

Feature: Importing coverage data
  @SqApi56
  Scenario: Importing coverage reports
      Assertion Failed: 
        overall_line_coverage is actually 28.2 [expected: 20.0]
        line_coverage is actually 17.6 [expected: 12.5]
        it_line_coverage is actually 36.4 [expected: 26.3]
        coverage is actually 23.8 [expected: 20.0]
        overall_coverage is actually 34.0 [expected: 28.6]
        it_coverage is actually 40.6 [expected: 34.5]
        
  @SqApi56
  Scenario: Importing coverage reports zeroing coverage for untouched files 
      Assertion Failed: 
        overall_line_coverage is actually 20.0 [expected: 13.7]
        line_coverage is actually 7.3 [expected: 5.0]
        it_line_coverage is actually 19.0 [expected: 12.8]
        coverage is actually 11.1 [expected: 9.1]
        overall_coverage is actually 26.1 [expected: 21.5]
        it_coverage is actually 25.0 [expected: 20.4]
        

Feature: Smoketest
  @SqApi56
  Scenario: Smoketest
      Assertion Failed: 
        overall_coverage is actually 84.0 [expected: 81.8]
        it_coverage is actually 84.0 [expected: 81.8]
        coverage is actually 84.0 [expected: 81.8]

I found a comment in test_create_rules_and_bullseye_import.feature which documents a reduced coverage after SonarQube update.

jump from 88.9 to 83 in sonar 5.x. enable once 5.x LTS is here

@guwirth guwirth added the bug label Sep 23, 2017
@guwirth guwirth added this to the 0.9.8 milestone Sep 23, 2017
@guwirth
Copy link
Collaborator

guwirth commented Sep 23, 2017

@tomassdepakin thsnks for the fix.

In general looks good. Coverage is increased after your fix. It's always hard to say if coverage values are correct or not because every tool is doing/counting it al little bit different. Can you compare the numbers of our integration tests with the values shown in Bullseye please. Are they better/same/worse?

@Bertk
Copy link
Contributor

Bertk commented Sep 25, 2017

@tomassdepakin The integration tests still fail and you have to adapt the values within the scenarios for the Sonarqube 5.6 tests to pass the checks.

https://github.com/SonarOpenCommunity/sonar-cxx/blob/master/integration-tests/features/importing_coverage.feature
https://github.com/SonarOpenCommunity/sonar-cxx/blob/master/integration-tests/features/smoketest.feature

Feature: Importing coverage data
  @SqApi56
  Scenario: Importing coverage reports
      Assertion Failed: 
        overall_line_coverage is actually 28.2 [expected: 20.0]
        line_coverage is actually 17.6 [expected: 12.5]
        it_line_coverage is actually 36.4 [expected: 26.3]
        coverage is actually 23.8 [expected: 20.0]
        overall_coverage is actually 34.0 [expected: 28.6]
        it_coverage is actually 40.6 [expected: 34.5]
        
  @SqApi56
  Scenario: Importing coverage reports zeroing coverage for untouched files 
      Assertion Failed: 
        overall_line_coverage is actually 20.0 [expected: 13.7]
        line_coverage is actually 7.3 [expected: 5.0]
        it_line_coverage is actually 19.0 [expected: 12.8]
        coverage is actually 11.1 [expected: 9.1]
        overall_coverage is actually 26.1 [expected: 21.5]
        it_coverage is actually 25.0 [expected: 20.4]
        

Feature: Smoketest
  @SqApi56
  Scenario: Smoketest
      Assertion Failed: 
        overall_coverage is actually 84.0 [expected: 81.8]
        it_coverage is actually 84.0 [expected: 81.8]
        coverage is actually 84.0 [expected: 81.8]

@tomassdepakin
Copy link
Author

Yep, I want to make more tests on coverage computing, and also with SQ5.6

@tomassdepakin
Copy link
Author

tomassdepakin commented Sep 26, 2017

Bullseye counts "for-loop", "try", "catch", "switch" as 1 decision, but we counted each of them as 2.
Fixed to treat such statements as 1 condition.
Simplified condition\decision probes to be treated in same way. In the end SQ has only conditions.
Fixed uncovered functions to be laso shown in UI (previously weren't, see first post image L114).
After applying all fixes, uncovered conditions count in SQ UI is same as in bullseye reports.

fixes
Same with try, catch, switch blocks
Integration tests still to be fixed.

@tomassdepakin
Copy link
Author

Checked with SQ 5.6 - UI and measures are same as in SQ 6.3
6.3:
6 3_measures_src_libraries_common_errors

5.6:
5 6_measures_src_libraries_common_errors

Overall coverage measures are very close to those in bullseye reports. In our project there is 1-5% difference per file.
Only difference left is line coverage. The more uncovered conditions - the more difference in overall coverage, because we mark them as "lineHits = 0" and SQ says to cover them not only as condition, but also as line.

@Bertk
Copy link
Contributor

Bertk commented Sep 26, 2017

The coverage values for SQ6.2 and newer have now to be adopted as well.

  @SqApi62
  Scenario: Importing coverage reports
      	line_coverage is actually 25.0 [expected: 17.5]
      	coverage is actually 31.0 [expected: 25.9]
  @SqApi62
  Scenario: Smoketest 
      	coverage is actually 53.8 [expected: 50.0]
      	line_coverage is actually 54.8 [expected: 50.0]

@guwirth
Copy link
Collaborator

guwirth commented Sep 26, 2017

@tomassdepakin please rebase

@tomassdepakin
Copy link
Author

@guwirth done

@guwirth guwirth self-requested a review September 27, 2017 15:57
@guwirth
Copy link
Collaborator

guwirth commented Sep 27, 2017

@Bertk is final version also ok for you?

@guwirth guwirth requested a review from Bertk September 27, 2017 15:59
@guwirth
Copy link
Collaborator

guwirth commented Sep 27, 2017

@tomassdepakin looks good to me. Thanks for providing this PR.

Copy link
Contributor

@Bertk Bertk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Great job. Thanks for fixing the coverage indication in SQ source code UI.

@tomassdepakin
Copy link
Author

Thank YOU guys for developing this plugin) My pleasure to participate.

@guwirth guwirth merged commit 0f1ccc1 into SonarOpenCommunity:master Sep 28, 2017
@tomassdepakin tomassdepakin deleted the bugfix/bullseye_coverage branch September 28, 2017 10:12
@guwirth guwirth mentioned this pull request Oct 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

3 participants