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

Support SonarQube 10.x #2616

Closed
wants to merge 10 commits into from
Closed

Conversation

agebert
Copy link
Contributor

@agebert agebert commented Jan 22, 2024

The goal is to support SonarQube 10.x. It is based on #2613 and supersedes #2612.

With these changes you can use 10.x version of org.sonarsource.sonarqube:sonar-plugin-api-impl and
org.sonarsource.api.plugin:sonar-plugin-api .

I fixed all compile issues for new plug-in https://sonarsource.atlassian.net/browse/SONARTEXT-57 and Java 17.

I did not test the result.

Sorry for creating a new PR, but I wanted to rebase on top of #2613 and do not know how-to do this with an existing #2612.


This change is Reviewable

guwirth and others added 8 commits January 19, 2024 15:16
- CI is testing with SQ 9.9 LTS and SQ 10.3 with Java 17
  - use SonarQube 10.3.0.82913 for testing
  - use SonarScanner 5.0.1.3006 for testing
- pom.xml: use Java 17 as default (Java 11 no more supported)
….15.0.435

Refactor the code to use new artifact sonar-plugin-api-test-fixtures.
Get rid of deprecated LoggerLevel.
…0.3.0.1951

And bump also org.sonarsource.api.plugin:sonar-plugin-api-test-fixtures

Some classes move to org.sonar.api.testfixtures.measure package.
… to 10.3.0.82913

And bump org.sonarsource.sonarqube:sonar-testing-harness
@guwirth
Copy link
Collaborator

guwirth commented Jan 22, 2024

Hi @agebert,

thanks a lot.

The CI is failing with SQ 10.3:
https://github.com/SonarOpenCommunity/sonar-cxx/actions/runs/7610795834
https://github.com/SonarOpenCommunity/sonar-cxx/actions/runs/7610795834/job/20725141097

Failing scenarios:
integration-tests/features/smoketest.feature:6 Smoketest UTF-8 (without BOM)
integration-tests/features/smoketest.feature:71 Smoketest UTF-8 (with BOM)
integration-tests/features/smoketest.feature:136 Smoketest UTF-16LE (with BOM)
integration-tests/features/smoketest.feature:201 Project using Bullseye coverage, xUnit, Cppcheck, Rats, Vera++

I have to look deeper into it what the reason is.

Regards,

@guwirth
Copy link
Collaborator

guwirth commented Jan 22, 2024

@agebert small question: are you using the plugin in your SQ 10.3 environment successful?

@agebert
Copy link
Contributor Author

agebert commented Jan 22, 2024

@guwirth no, I did not test it at all. I only run the "mvn verify".

We are new to SonarQube and picked SonarQube 10.x because it is faster than SonarQube 9.x for our setup. With SonarQube 10.3 we failed to use sonar-cxx 2.1 as explained on Compatibility-Matrix. On the other hand we downgraded to SonarQube 10.0, and this works with sonar-cxx 2.1.

Thank you and all contributes for this project.

It is fun to work with you @guwirth.

@guwirth guwirth self-requested a review January 24, 2024 15:18
@guwirth
Copy link
Collaborator

guwirth commented Jan 25, 2024

Seems to be changes in the WebApi so that tests are no more running.

@agebert
Copy link
Contributor Author

agebert commented Jan 27, 2024

Can I help with something?

@guwirth
Copy link
Collaborator

guwirth commented Jan 30, 2024

Hi @agebert,

below the failing API requests:

Get measures with query : /api/measures/component?component=smoketest_project&metricKeys=ncloc,lines,statements,classes,files,directories,functions,comment_lines_density,comment_lines,duplicated_lines_density,duplicated_lines,duplicated_blocks,duplicated_files,complexity,cognitive_complexity,file_complexity,violations,lines_to_cover,coverage,line_coverage,branch_coverage,uncovered_conditions,uncovered_lines,tests,test_failures,test_errors,skipped_tests,test_execution_time,test_success_density,false_positive_issues,open_issues,confirmed_issues,reopened_issues,code_smells,sqale_index,sqale_debt_ratio,bugs,reliability_remediation_effort,vulnerabilities,security_remediation_effort,security_hotspots
      Assertion Failed: error web_api_get: http://localhost:9000/api/measures/component?component=smoketest_project&metricKeys=ncloc,lines,statements,classes,files,directories,functions,comment_lines_density,comment_lines,duplicated_lines_density,duplicated_lines,duplicated_blocks,duplicated_files,complexity,cognitive_complexity,file_complexity,violations,lines_to_cover,coverage,line_coverage,branch_coverage,uncovered_conditions,uncovered_lines,tests,test_failures,test_errors,skipped_tests,test_execution_time,test_success_density,false_positive_issues,open_issues,confirmed_issues,reopened_issues,code_smells,sqale_index,sqale_debt_ratio,bugs,reliability_remediation_effort,vulnerabilities,security_remediation_effort,security_hotspots -> 404 Client Error:  for url: http://localhost:9000/api/measures/component?component=smoketest_project&metricKeys=ncloc,lines,statements,classes,files,directories,functions,comment_lines_density,comment_lines,duplicated_lines_density,duplicated_lines,duplicated_blocks,duplicated_files,complexity,cognitive_complexity,file_complexity,violations,lines_to_cover,coverage,line_coverage,branch_coverage,uncovered_conditions,uncovered_lines,tests,test_failures,test_errors,skipped_tests,test_execution_time,test_success_density,false_positive_issues,open_issues,confirmed_issues,reopened_issues,code_smells,sqale_index,sqale_debt_ratio,bugs,reliability_remediation_effort,vulnerabilities,security_remediation_effort,security_hotspots
      
Get measures with query : /api/measures/component?component=smoketest_project_utf8_bom&metricKeys=ncloc,lines,statements,classes,files,directories,functions,comment_lines_density,comment_lines,duplicated_lines_density,duplicated_lines,duplicated_blocks,duplicated_files,complexity,cognitive_complexity,file_complexity,violations,lines_to_cover,coverage,line_coverage,branch_coverage,uncovered_conditions,uncovered_lines,tests,test_failures,test_errors,skipped_tests,test_execution_time,test_success_density,false_positive_issues,open_issues,confirmed_issues,reopened_issues,code_smells,sqale_index,sqale_debt_ratio,bugs,reliability_remediation_effort,vulnerabilities,security_remediation_effort,security_hotspots
      Assertion Failed: error web_api_get: http://localhost:9000/api/measures/component?component=smoketest_project_utf8_bom&metricKeys=ncloc,lines,statements,classes,files,directories,functions,comment_lines_density,comment_lines,duplicated_lines_density,duplicated_lines,duplicated_blocks,duplicated_files,complexity,cognitive_complexity,file_complexity,violations,lines_to_cover,coverage,line_coverage,branch_coverage,uncovered_conditions,uncovered_lines,tests,test_failures,test_errors,skipped_tests,test_execution_time,test_success_density,false_positive_issues,open_issues,confirmed_issues,reopened_issues,code_smells,sqale_index,sqale_debt_ratio,bugs,reliability_remediation_effort,vulnerabilities,security_remediation_effort,security_hotspots -> 404 Client Error:  for url: http://localhost:9000/api/measures/component?component=smoketest_project_utf8_bom&metricKeys=ncloc,lines,statements,classes,files,directories,functions,comment_lines_density,comment_lines,duplicated_lines_density,duplicated_lines,duplicated_blocks,duplicated_files,complexity,cognitive_complexity,file_complexity,violations,lines_to_cover,coverage,line_coverage,branch_coverage,uncovered_conditions,uncovered_lines,tests,test_failures,test_errors,skipped_tests,test_execution_time,test_success_density,false_positive_issues,open_issues,confirmed_issues,reopened_issues,code_smells,sqale_index,sqale_debt_ratio,bugs,reliability_remediation_effort,vulnerabilities,security_remediation_effort,security_hotspots
      
Get measures with query : /api/measures/component?component=smoketest_project_utf16&metricKeys=ncloc,lines,statements,classes,files,directories,functions,comment_lines_density,comment_lines,duplicated_lines_density,duplicated_lines,duplicated_blocks,duplicated_files,complexity,cognitive_complexity,file_complexity,violations,lines_to_cover,coverage,line_coverage,branch_coverage,uncovered_conditions,uncovered_lines,tests,test_failures,test_errors,skipped_tests,test_execution_time,test_success_density,false_positive_issues,open_issues,confirmed_issues,reopened_issues,code_smells,sqale_index,sqale_debt_ratio,bugs,reliability_remediation_effort,vulnerabilities,security_remediation_effort,security_hotspots
      Assertion Failed: error web_api_get: http://localhost:9000/api/measures/component?component=smoketest_project_utf16&metricKeys=ncloc,lines,statements,classes,files,directories,functions,comment_lines_density,comment_lines,duplicated_lines_density,duplicated_lines,duplicated_blocks,duplicated_files,complexity,cognitive_complexity,file_complexity,violations,lines_to_cover,coverage,line_coverage,branch_coverage,uncovered_conditions,uncovered_lines,tests,test_failures,test_errors,skipped_tests,test_execution_time,test_success_density,false_positive_issues,open_issues,confirmed_issues,reopened_issues,code_smells,sqale_index,sqale_debt_ratio,bugs,reliability_remediation_effort,vulnerabilities,security_remediation_effort,security_hotspots -> 404 Client Error:  for url: http://localhost:9000/api/measures/component?component=smoketest_project_utf16&metricKeys=ncloc,lines,statements,classes,files,directories,functions,comment_lines_density,comment_lines,duplicated_lines_density,duplicated_lines,duplicated_blocks,duplicated_files,complexity,cognitive_complexity,file_complexity,violations,lines_to_cover,coverage,line_coverage,branch_coverage,uncovered_conditions,uncovered_lines,tests,test_failures,test_errors,skipped_tests,test_execution_time,test_success_density,false_positive_issues,open_issues,confirmed_issues,reopened_issues,code_smells,sqale_index,sqale_debt_ratio,bugs,reliability_remediation_effort,vulnerabilities,security_remediation_effort,security_hotspots

Assertion Failed: error web_api_set: http://localhost:9000/api/rules/create {'custom_key': 'cpplint_legal_copyright_0', 'html_description': 'nodesc', 'name': 'cpplint_legal_copyright_0', 'severity': 'MAJOR', 'template_key': 'other:CustomRuleTemplate', 'markdown_description': 'nodesc'} -> 400 Client Error:  for url: http://localhost:9000/api/rules/create, {"errors":[{"msg":"The \u0027customKey\u0027 parameter is missing"}]}

These two API calls are failing:

  • /api/measures/component
  • /api/rules/create

Maybe API does no more exist or they changed the parameters? If you have time you can look into the documentation if you find something.

Regards,

The call /api/measures/component does no longer support query paramter metricKeys=directoriesi.

This request
  curl 'http://localhost:9000/api/measures/component?component=smoketest_project&metricKeys=ncloc,lines,statements,classes,files,directories,functions,comment_lines_density,comment_lines,duplicated_lines_density,duplicated_lines,duplicated_blocks,duplicated_files,complexity,cognitive_complexity,file_complexity,violations,lines_to_cover,coverage,line_coverage,branch_coverage,uncovered_conditions,uncovered_lines,tests,test_failures,test_errors,skipped_tests,test_execution_time,test_success_density,false_positive_issues,open_issues,confirmed_issues,reopened_issues,code_smells,sqale_index,sqale_debt_ratio,bugs,reliability_remediation_effort,vulnerabilities,security_remediation_effort,security_hotspots'

returned error 404 with body:
  {"errors":[{"msg":"The following metric keys are not found: directories"}]}
Change in SonarQube 10.0 for /api/rules/create:
  Drop deprecated keys: 'custom_key', 'template_key', 'markdown_description', 'prevent_reactivation'

The parameter names changed.
  custom_key -> customKey
  template_key -> templateKey
  markdown_description -> markdownDescription

We got for example this error:
 {"errors":[{"msg":"The markdownDescription parameter is missing"}]}
@agebert
Copy link
Contributor Author

agebert commented Feb 2, 2024

I fixed the failing tests:

  integration-tests/features/smoketest.feature:6 Smoketest UTF-8 (without BOM)
  integration-tests/features/smoketest.feature:71 Smoketest UTF-8 (with BOM)
  integration-tests/features/smoketest.feature:136 Smoketest UTF-16LE (with BOM)
  integration-tests/features/smoketest.feature:201 Project using Bullseye coverage, xUnit, Cppcheck, Rats, Vera++

If I run it local I get this result:

Failing scenarios:
  integration-tests/features/compiler.feature:5  Import a VisualStudio LOG file with warnings

11 features passed, 1 failed, 0 skipped
36 scenarios passed, 1 failed, 2 skipped
321 steps passed, 1 failed, 12 skipped, 0 undefined
Took 12m16.770s

Details of the failed test

Feature: Importing compiler reports
  As a CXX plug-in user, I want to import LOG files from compilers into SonarQube
  Scenario: Import a VisualStudio LOG file with warnings
    Given the project "vs_project"
    And rule "compiler-vc:C4189" is activated
    And rule "compiler-vc:C4457" is activated
    And platform is "Windows"
    When I run sonar-scanner with "-X"
    Then the analysis finishes successfully
    And the analysis in server has completed
    And the server log (if locatable) contains no error/warning messages
    And the number of violations fed is 2
      Assertion Failed:
        violations is actually 0 [expected: 2.0]
      Captured stdout:
          Read Log : _vs_project_1.log
           Get Analysis In Background : http://localhost:9000/api/ce/task?id=AY1r9aNqECRYjJoRquI9
           CURRENT STATUS : IN_PROGRESS
           CURRENT STATUS : IN_PROGRESS
           CURRENT STATUS : SUCCESS

      Get measures with query : /api/measures/component?component=vs_project&metricKeys=violations

I don't know how-to fix this.

@guwirth
Copy link
Collaborator

guwirth commented Feb 3, 2024

Hi @agebert,

thanks for fixing the integration test.

violations is actually 0 [expected: 2.0]

Looks like the two rules are not activated on your local machine?

And rule "compiler-vc:C4189" is activated
And rule "compiler-vc:C4457" is activated

Do you have the corresponding rights on the server to change rule settings?

Regards,

@guwirth
Copy link
Collaborator

guwirth commented Feb 3, 2024

Hi @agebert,

build is running on CI
https://github.com/SonarOpenCommunity/sonar-cxx/actions/runs/7762444267
Resulting JAR
https://github.com/SonarOpenCommunity/sonar-cxx/actions/runs/7762444267/artifacts/1217094897

There is still a problem with CodeQL using the wrong Java version. actions/setup-java missing in https://github.com/SonarOpenCommunity/sonar-cxx/blob/master/.github/workflows/codeql-analysis.yml.

I will add the JAR files to the Releases as a beta so that others also can use it with SQ 10.

Regards,

@guwirth guwirth mentioned this pull request Feb 7, 2024
@guwirth guwirth added this to the 2.2.0 milestone Feb 7, 2024
@guwirth
Copy link
Collaborator

guwirth commented Feb 7, 2024

merged into branch SQ-10 and release as a first V2.2-beta

@guwirth guwirth closed this Feb 7, 2024
@agebert
Copy link
Contributor Author

agebert commented Feb 8, 2024

@guwirth thank you for merging and creating a beta version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants