diff --git a/Jenkinsfile b/Jenkinsfile index f26daacf4..a163c3ccf 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -26,7 +26,7 @@ builders['Build swift Linux'] = { } stage('Linux Checks') { - sh 'cppcheck --xml --xml-version=2 --inline-suppr --std=c++11 -ibuild --enable=style,unusedFunction -i externals ' + + sh 'cppcheck --xml --xml-version=2 --inline-suppr --std=c++14 -ibuild --enable=style,unusedFunction -i externals ' + '--suppressions-list=cppcheck.supp --library=qt.cfg --library=posix.cfg . 2> cppcheck.xml' publishCppcheck allowNoReport: true, pattern: 'cppcheck.xml' diff --git a/cppcheck.supp b/cppcheck.supp index 373eda7eb..afc934164 100644 --- a/cppcheck.supp +++ b/cppcheck.supp @@ -5,33 +5,17 @@ // [error id]:[filename2] // [error id] -// False positive caused by missing support for C++11 feature -unusedPrivateFunction:src/blackmisc/lockfree.h - // Ignore noExplicitConstructor for now. noExplicitConstructor +// Ignore useStlAlgorithm for now (consider designing our own useBlackMiscAlgorithm checks) +useStlAlgorithm + +// Internal errors +cppcheckError + // Ignore style issues in g2clib variableScope:src/plugins/weatherdata/gfs/g2clib/*.c -// Shared pointers should be passed by value -passedByValue:src/blackmisc/lockfree.h - -// Passing std::function by value is acceptable -passedByValue:src/xswiftbus/libxplanemp/src/ResourceManager.h -passedByValue:tests/blackcore/vatsim/testnetwork/expect.h -passedByValue:src/xswiftbus/command.h - -// Unique pointers should be passed by value -passedByValue:src/xswiftbus/menus.h -passedByValue:src/xswiftbus/menus.cpp - -// cppcheck cannot handle the advanced workaround in use -operatorEqRetRefThis:src/blackmisc/iterator.h - // Ignore unusedFunction as it has too many false positives (especially in tests) unusedFunction - -// Return value of those functions is not required. -ignoredReturnValue:src/blackmisc/dbusserver.cpp -ignoredReturnValue:src/blackmisc/simplecommandparser.cpp \ No newline at end of file diff --git a/src/blackgui/components/settingssimulatorbasicscomponent.cpp b/src/blackgui/components/settingssimulatorbasicscomponent.cpp index f83377893..cb6f4e90b 100644 --- a/src/blackgui/components/settingssimulatorbasicscomponent.cpp +++ b/src/blackgui/components/settingssimulatorbasicscomponent.cpp @@ -318,6 +318,7 @@ namespace BlackGui ui->le_SimulatorDirectory->setPlaceholderText(simDir.isEmpty() ? "Simulator directory" : simDir); //! \fixme correct version when Qt multiline placeholder is fixed https://bugreports.qt.io/browse/QTBUG-43817 + // cppcheck-suppress knownConditionTrueFalse constexpr bool BrokenMultilinePlaceholder = true; // last checked with Qt 5.10 // we take the settings and update to latest sim.directory @@ -332,6 +333,7 @@ namespace BlackGui else { const QString ms = m.join("
"); + // cppcheck-suppress knownConditionTrueFalse if (BrokenMultilinePlaceholder && m.size() > 1) { ui->pte_ModelDirectories->setToolTip(unwrappedTooltip(ms)); diff --git a/src/blackmisc/dbusserver.cpp b/src/blackmisc/dbusserver.cpp index 332a1e2bd..70cbc1713 100644 --- a/src/blackmisc/dbusserver.cpp +++ b/src/blackmisc/dbusserver.cpp @@ -367,6 +367,7 @@ namespace BlackMisc QString p = port.toLower().trimmed(); if (!p.isEmpty()) { + // cppcheck-suppress ignoredReturnValue p.toShort(&ok); if (!ok) { diff --git a/src/blackmisc/iterator.h b/src/blackmisc/iterator.h index 9c392ce76..0136b15fc 100644 --- a/src/blackmisc/iterator.h +++ b/src/blackmisc/iterator.h @@ -55,7 +55,8 @@ namespace BlackMisc { // Work around lambda's deleted copy assignment operator this->~OutputIterator(); - return *new (this) OutputIterator(other); + new (this) OutputIterator(other); + return *this; } //! Destructor. diff --git a/src/blackmisc/json.h b/src/blackmisc/json.h index dcc040f54..d6d388701 100644 --- a/src/blackmisc/json.h +++ b/src/blackmisc/json.h @@ -431,6 +431,7 @@ namespace BlackMisc if (value.isUndefined()) { constexpr bool required = false; //! \fixme add RequiredForJson flag in metaclass system + // cppcheck-suppress knownConditionTrueFalse if (required) { throw CJsonException(QStringLiteral("Missing required member '%1'").arg(member.latin1Name())); } } else diff --git a/src/blackmisc/simplecommandparser.cpp b/src/blackmisc/simplecommandparser.cpp index ad0693473..9b2393ec6 100644 --- a/src/blackmisc/simplecommandparser.cpp +++ b/src/blackmisc/simplecommandparser.cpp @@ -87,6 +87,7 @@ namespace BlackMisc const QString p = this->part(index); if (p.isEmpty()) { return false; } bool ok = false; + // cppcheck-suppress ignoredReturnValue p.toInt(&ok); return ok; } diff --git a/src/plugins/simulator/fsxcommon/simulatorfsxcommon.cpp b/src/plugins/simulator/fsxcommon/simulatorfsxcommon.cpp index edf3de37f..4d4fc2787 100644 --- a/src/plugins/simulator/fsxcommon/simulatorfsxcommon.cpp +++ b/src/plugins/simulator/fsxcommon/simulatorfsxcommon.cpp @@ -2391,6 +2391,7 @@ namespace BlackSimPlugin void CSimulatorFsxCommon::traceSendId(const CSimConnectObject &simObject, const QString &functionName, const QString &details, bool forceTrace) { if (!forceTrace && !this->isTracingSendId()) { return; } + // cppcheck-suppress knownConditionTrueFalse if (MaxSendIdTraces < 1) { return; } DWORD dwLastId = 0; const HRESULT hr = SimConnect_GetLastSentPacketID(m_hSimConnect, &dwLastId); diff --git a/src/xswiftbus/dbusconnection.cpp b/src/xswiftbus/dbusconnection.cpp index 59e6a0657..d990e76c5 100644 --- a/src/xswiftbus/dbusconnection.cpp +++ b/src/xswiftbus/dbusconnection.cpp @@ -36,7 +36,7 @@ namespace XSwiftBus CDBusConnection::~CDBusConnection() { close(); - if (m_connection) { dispatch(); } + if (m_connection) { dispatch(); } // dispatch is virtual, but safe to call in dtor, as it's declared final if (m_dispatcher) { m_dispatcher->remove(this); } } diff --git a/src/xswiftbus/dbusconnection.h b/src/xswiftbus/dbusconnection.h index c71747007..64eb0be33 100644 --- a/src/xswiftbus/dbusconnection.h +++ b/src/xswiftbus/dbusconnection.h @@ -85,7 +85,8 @@ namespace XSwiftBus CDBusError lastError() const { return m_lastError; } protected: - virtual void dispatch() override; + // cppcheck-suppress virtualCallInConstructor + virtual void dispatch() override final; private: void setDispatchStatus(DBusConnection *connection, DBusDispatchStatus status);