Description / Features
This plugin adds basic support of C++ language into Sonar.
Current feature list:
- Basic size metrics:
- Files (number of)
- Lines of comments
- Lines of code
- Lines of commented out code
- Static code checking via virtually any static analyser tool. And possibility of extension of their coding rules.
- Dynamic checking for memory management problems via Valgrind
- Cyclomatic (McCabe) complexity metrics including:
- Projects complexity
- Average function/method complexity
- Average file complexity
- Complexity distributions
- Code coverage metrics including:
- Line coverage
- Branch coverage
- IT line coverage
- Overall branch coverage
- Unit test execution metrics including:
- Successfully executed tests
- Failed tests
- Skipped tests
- Execution time
- Recognition of code duplication
- Basic highlighting mode for C++ in Sonar UI
The Cxx-Plugin has an obligatory dependency on Java (of course... the plugin itself and all runners are Java programs).
Moreover, there are optional dependencies on:
- Various external code analyzers:
- Cppcheck. Detects a wide range of problems ranging from performance issues and resource leakage to undefined behaviour. Binary packets are available on/for various platforms. Using the latest release pays off in general; compile from source if in doubt.
- RATS. Detects (potential) security problems in code, sensible for code bases with increased security requirements. Use binary packages or compile from source.
- Vera++. Focuses on code style issues. There's a binary package for Windows, users of other platforms are likely to compile themselves.
- Valgrind (memcheck). Detects various memory management problems at runtime. Basically Linux only; just use the packages from your distribution.
- CppNcss. Provides cyclomatic (McCabe) complexity measures. This is a Java program distributed as a zip archive. Just unpack and make sure the "bin" directory is in PATH.
- Pc-Lint. Static analyser from Gimpel
- GCC, gcov, gcovr, Bullseye and Python for coverage determination. Install Python and place the script somewhere on the PATH.
- Via Update Center
- Or copy the jar-archive into <sonar home>
- Restart the Sonar web server
Quick Configuration Guide
Cxx plugin uses the following properties during analysis. See here for the ways how to pass them to the plugin.
|sonar.cxx.suffixes.sources||System- and/or project-wide||cxx,cpp,cc,c||.C,.h|
Comma separated list of file name extension to be considered as C++ source files during analysis.
|sonar.cxx.suffixes.headers||System- and/or project-wide||hxx,hpp,hh,h||Comma separated list of file name extension to be considered as C++ source files during analysis.|
Ant pattern describing the path to Cppcheck reports, relative to projects root.
|sonar.cxx.cppncss.reportPath||Project-wide||cppncss-reports/cppncss-result-*.xml||cppncss-report-*.xml||Ant pattern describing the path to CppNcss reports, relative to projects root.|
|sonar.cxx.gcovr.reportPath (<0.2)||Project-wide||gcovr-reports/gcovr-result-*.xml||gcovr-report-*.xml||Ant pattern describing the path to gcovr reports, relative to projects root.|
|sonar.cxx.rats.reportPath||Project-wide||rats-reports/rats-result-*.xml||rats-report-*.xml||Ant pattern describing the path to RATS reports, relative to projects root.|
|sonar.cxx.valgrind.reportPath||Project-wide||valgrind-reports/valgrind-result-*.xml||valgrind-report-*.xml||Ant pattern describing the path to Valgrind reports, relative to projects root.|
|sonar.cxx.vera.reportPath||Project-wide||vera++-reports/vera++-result-*.xml||vera-report-*.xml||Ant pattern describing the path to Vera++ reports, relative to projects root.|
|sonar.cxx.xunit.reportPath||Project-wide||xunit-reports/xunit-result-*.xml||xunit-report-*.xml||Ant pattern describing the path to unit test execution reports, relative to projects root.|
|sonar.cxx.externalrules.reportPath||Project-wide||externalrules-result/externalrules-result-*.xml||externalrules-result-*.xml||Ant pattern describing the path to unit test execution reports, relative to projects root.|
A name of a built in XSLT-file or an URL to an external one. Available builtins:
|sonar.cxx.coverage.reportPath (>=0.2)||Project-wide||coverage-reports/coverage-*.xml||coverage-*.xml||Ant pattern describing the path of unit test coverage reports, relative to projects root.|
|sonar.cxx.coverage.itReportPath (>=0.2)||Project-wide||coverage-reports/it-coverage-*.xml||it-coverage-*.xml||Ant pattern describing the path of integration test coverage reports, relative to projects root.|
|sonar.cxx.coverage.overallReportPath (>=0.2)||Project-wide||coverage-reports/overall-coverage-*.xml||overall-coverage-*.xml||Ant pattern describing the path of overall test coverage reports, relative to projects root.|
Note: Report paths are always relative to projects path.
- Some analyzers (RATS, most notably) may have issues and crash occasionally.
- Valgrind is only available on a subset of UNIX platforms.
Following items are in the queue (more or less...):
- Use SSLR technology
- Integrate compiler warnings
Implement the dependency analysis (package tangle index metric)