Skip to content

Instantly share code, notes, and snippets.

@LegalizeAdulthood
Created May 8, 2019 21:55
Show Gist options
  • Save LegalizeAdulthood/f581e5008c82c6930dc51549a2500e0e to your computer and use it in GitHub Desktop.
Save LegalizeAdulthood/f581e5008c82c6930dc51549a2500e0e to your computer and use it in GitHub Desktop.
SonarQube Configuration for C++ Projects

SonarQube Configuration for C++ Projects

  1. Download SonarQube from SonarQube.org.
  2. Unpack the distribution.
  3. Download the C++ community plugin.
  4. Install the plugin using these instructions.
  5. Run bin\windows-x86-64\StartSonar.bat to start the server.
  6. Wait for the server to output the message SonarQube is up.
  7. Browse to http://localhost:9000 and login with admin/admin.
  8. Create a project by following the built-in tutorial.
  9. Configure the scanner for C++
    1. Project properties
      • Login credentials
      • C++ Language
    2. build log reports
    3. cppcheck reports
      1. Configure cppcheck to output XML version 2 report (--xml-version=2)
    4. Activate Quality Rules
      1. Make a copy of the "C++ (Community) Sonar way" Quality Profile and name it for your project
      2. Activate rules in the new quality profile
        • cppcheck rules
        • MSVC compiler rules
        • clang-tidy rules
  10. Run an analysis.
    1. Perform a build
      1. /analyze for MSVC static analyzer
      2. scan-build for clang static analyzer
      3. cppcheck
    2. Run sonar-scanner
  11. Browse the results.
  12. Iterate by enabling or disabling checks in your quality profile and re-running sonar-scanner
  13. Integrate to your CI build to track trends
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment