Skip to content

Troubleshooting Configuration

guwirth edited this page Jun 11, 2021 · 7 revisions

In the SonarQube documentation you will find general information about Analysis Parameters. In addition, the following instructions must be observed.

Invalid Configuration Parameters

If the scanning of a project fails, the .LOG file should be checked first. It is recommended to switch on the debug information. Look for ERROR and WARN entries, these usually already give hints on what needs to be changed in the configuration.

When upgrading to a newer version of the cxx plugin it can happen that the names of configuration parameters have changed. The cxx plugin checks if you are using deprecated configuration parameters and displays corresponding error messages in the .LOG file.

10 WARN CXX property 'sonar.cxx.forceZeroCoverage' is no longer supported.
11 WARN CXX property 'sonar.cxx.cppcheck.reportPath' is no longer supported. Use 'sonar.cxx.cppcheck.reportPaths' instead.

In addition, SonarQube UI displays warnings in the project overview:

Scan Source Code

File Indexing

Make sure that your source files are read (indexed).

The first thing to do is to make sure that the file extensions are mapped correctly (see sonar.cxx.file.suffixes). The entries under Declared extensions list the file extensions assigned to a programming language. Each file extension must be uniquely assigned to one programming language.

17 DEBUG: Declared extensions of language CXX were converted to sonar.lang.patterns.cxx : **/*.cxx,**/*.cpp,**/*.cc,**/*.c,**/*.hxx,**/*.hpp,**/*.hh,**/*.h

The first step in the analysis of a project is always the Indexing files. Here the files are assigned to a programming language on the basis of the file extensions. Files that are not listed here are not displayed in the SonarQube UI. A description of how the files are filtered can be found at Narrowing the Focus.

19 INFO: Indexing files...
20 INFO: Project configuration:
21 DEBUG: 'src/component1.cc' indexed with language 'cxx'
...
24 INFO: 3 files indexed

File Path Issues

When setting up the cxx plugin and build chain, in the beginning the most common problems are file path issues. Using different tools and build chains, differences in operating systems and SonarQube versions do not make things easier. On this page you will find some hints to get your system up and running.

General configuration file hints

  • The location of your configuration file sonar-project.properties defines the project base directory . All other files and folders should be on root level or in a subfolder.

    Hint: Only exception is sonar.cxx.includeDirectories where you can define additional include directories outside of root.

  • Use always slashes (/) in the configuration file sonar-project.properties as path separator.

    Hint: It is also possible to use backslashes but you have to escape it with another backslash (\ => \\) which is hard to read.

  • Relative paths defined in configuration file are always relative to the project base directory.

Sample:

root (folder with sonar-project.properties)
|-- src (folder with source files)
|-- tests
|     |-- unittests (folder with unit test results)
|-- build (folder with reports)

resulting sonar-project.properties:

sonar.sources=src
sonar.tests=tests/unittests
sonar.cxx.cppcheck.reportPath=build/cppcheck.xml

Ant-style pattern

Following matchFilePattern rules are applied:

? matches single character
* matches zero or more characters
** matches zero or more 'directories'
use always '/' as a directory separator
there must always be a root directory

Some examples of path patterns:

/**/*.cpp - matches all .cpp files in all directories (you have to define the root directory '/'), e.g. org/Foo.cpp or org/foo/Bar.cpp or org/foo/bar/Baz.cpp
/**/test/**/Foo.cpp - matches all 'Foo.cpp' files in directories with one 'test' directory in the path, e.g. org/test/Foo.cpp or org/bar/test/bar/Foo.cpp
org/T?st.cpp - matches org/Test.cpp and also org/Tost.cpp
org/*.cpp - matches all .cpp files in the org directory, e.g. org/Foo.cpp or org/Bar.cpp
org/** - matches all files underneath the org directory, e.g. org/Foo.cpp or org/foo/bar.jsp
org/**/Test.cpp - matches all Test.cpp files underneath the org directory, e.g. org/Test.cpp or org/foo/Test.cpp or org/foo/bar/Test.cpp
org/**/*.cpp - matches all .cpp files underneath the org directory, e.g. org/Foo.cpp or org/foo/Bar.cpp or org/foo/bar/Baz.cpp
Clone this wiki locally