I am novice user of SonarQube. I was tried to analyze some source CPP files through SonarQube (with sonar-cxx plugin), these (source) files are contains of some QT code pieces (inheritance from QSharedData & a few QT macro), but in result I give a strange errors from SonarQube Runner:
08:28:13.903 WARN - [D:\src\GrainBlitter\modules\CEDualString.h:3]: cannot find the sources for '#include <QSharedData>'
08:28:13.907 WARN - [D:\src\GrainBlitter\modules\CEDualString.h:4]: cannot find the sources for '#include <QtGlobal>'
08:28:13.930 ERROR - Unable to parse file: D:\src\GrainBlitter\modules\CEDualString.cpp
08:28:13.933 ERROR - Parse error at line 3 column 39:
--> __classCCEDualString::CCEDualStringData: __publicQSharedData
4: {
5: __public:
6: CCEDualStringData() {}
7: CCEDualStringData( const CCEDualStringData& other ) : QSharedData( other ), m_ascii( other.m_ascii )
08:28:13.964 WARN - [D:\src\GrainBlitter\modules\CEDualString.h:3]: cannot find the sources for '#include <QSharedData>'
08:28:13.969 WARN - [D:\src\GrainBlitter\modules\CEDualString.h:4]: cannot find the sources for '#include <QtGlobal>'
08:28:13.987 ERROR - Unable to parse file: D:\src\GrainBlitter\modules\CEDualString.h
08:28:13.990 ERROR - Parse error at line 50 column 0:
47: inline bool operator == ( const QString& l, const CCEDualString& r ) { return l == r.unicode(); }
48:
49: Q_DECLARE_METATYPE( CCEDualString )
--> Q_DECLARE_METATYPE( CCEDualStringsList )EOF
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 5.571s
Final Memory: 9M/118M
INFO: ------------------------------------------------------------------------
ERROR: Error during Sonar runner execution
ERROR: Unable to execute Sonar
ERROR: Caused by: COMMENT_BLANK_LINES
Properties file (sonar-project.properties) looks like:
# Required metadata
sonar.projectKey=GrainBlitter
sonar.projectName=GrainBlitter 0x01
sonar.projectVersion=0.0.xx
# Comma-separated paths to directories with sources (required)
sonar.sources=modules
#sonar.tests=UnitTests
# Language, needed for SonarQube < 4.2
sonar.language=c++
# Path to included files
sonar.cxx.include_directories=C:/Program Files (x86)/Microsoft Visual Studio 11.0/VC/include,D:/Qt/qt-5.3.1-x64-msvc2012-opengl/qt-5.3.1-x64-msvc2012-opengl/include/,D:/Qt/qt-5.3.1-x64-msvc2012-opengl/qt-5.3.1-x64-msvc2012-opengl/include/QtCore
sonar.cxx.cppcheck.path=C:/Program Files (x86)/Cppcheck/cppcheck.exe
# Encoding of the source files
sonar.sourceEncoding=UTF-8
# exclude qt created files
sonar.exclusions=**/ui_*.h
I specify QT include dir in [sonar.cxx.include_directories] variable, may be isn't correct? Please give me example of sonar-project.properties file with correct linkage to QT library. Thanks! P.S. QSharedData header are included in my headers
This is very likely due to the extension that qt made to the C++ language (which if I recall goes further than a few macros).
I don't know if sonar can handle this natively (or if there is a plugin) but as a first approach maybe you can run the analysis on the sources after they have been transformed by qt's preprocessor (moc).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With