diff --git a/cppcheck.supp b/cppcheck.supp index afc934164..54e4dec21 100644 --- a/cppcheck.supp +++ b/cppcheck.supp @@ -14,8 +14,35 @@ useStlAlgorithm // Internal errors cppcheckError -// Ignore style issues in g2clib +// g2clib variableScope:src/plugins/weatherdata/gfs/g2clib/*.c +knownConditionTrueFalse:src/plugins/weatherdata/gfs/g2clib/*.c +redundantAssignment:src/plugins/weatherdata/gfs/g2clib/*.c +unreadVariable:src/plugins/weatherdata/gfs/g2clib/*.c +invalidFunctionArg:src/plugins/weatherdata/gfs/g2clib/*.c // Ignore unusedFunction as it has too many false positives (especially in tests) unusedFunction + +// Conflicts with CppCoreGuidelines ES.20 Always initialize an object +redundantInitialization + +// Perf samples +redundantAssignment:samples/blackmisc/samplesperformance.* +unreadVariable:samples/blackmisc/samplesperformance.* + +// Benign +duplicateCondition:src/xswiftbus/libxplanemp/src/XPMPPlaneRenderer.cpp + +// Unused file +unknownMacro:src/xswiftbus/libxplanemp/src/BitmapUtils.cpp + +// False positives +returnDanglingLifetime:src/blackmisc/iterator.h +unreadVariable:tests/blackcore/testreaders/testreaders.cpp +unknownMacro:src/blackmisc/aviation/altitude.h +unknownMacro:src/blackmisc/geo/elevationplane.h +ctuArrayIndex:src/xswiftbus/libxplanemp/src/XPMPPlaneRenderer.cpp + +// False positive memory leaks due to Qt parent/child relationship +unsafeClassCanLeak diff --git a/samples/blackmisc/samplesperformance.cpp b/samples/blackmisc/samplesperformance.cpp index 9e70c68ca..037f6a585 100644 --- a/samples/blackmisc/samplesperformance.cpp +++ b/samples/blackmisc/samplesperformance.cpp @@ -797,17 +797,6 @@ namespace BlackSample return set; } - const CAircraftSituationList CSamplesPerformance::situations(const CCallsignSet &callsigns) - { - CAircraftSituationList situations; - for (const CCallsign &cs : callsigns) - { - const CAircraftSituation s(cs); - situations.push_back(s); - } - return situations; - } - const QMap CSamplesPerformance::situationsMap(const CCallsignSet &callsigns) { QMap situations; diff --git a/samples/blackmisc/samplesperformance.h b/samples/blackmisc/samplesperformance.h index f68f429cd..533bbc7b5 100644 --- a/samples/blackmisc/samplesperformance.h +++ b/samples/blackmisc/samplesperformance.h @@ -94,9 +94,6 @@ namespace BlackSample //! Get n callsigns static BlackMisc::Aviation::CCallsignSet callsigns(int number); - //! Situations - static const BlackMisc::Aviation::CAircraftSituationList situations(const BlackMisc::Aviation::CCallsignSet &callsigns); - //! Situations map static const QMap situationsMap(const BlackMisc::Aviation::CCallsignSet &callsigns); diff --git a/samples/blackmiscsim/samplesfsuipc.cpp b/samples/blackmiscsim/samplesfsuipc.cpp index 3d827b000..18d9fe4da 100644 --- a/samples/blackmiscsim/samplesfsuipc.cpp +++ b/samples/blackmiscsim/samplesfsuipc.cpp @@ -52,9 +52,8 @@ namespace BlackSample } #else - void CSamplesFsuipc::samplesFsuipc(QTextStream &streamOut) + void CSamplesFsuipc::samplesFsuipc(QTextStream &) { - Q_UNUSED(streamOut); } #endif diff --git a/samples/blackmiscsim/samplesvpilotrules.cpp b/samples/blackmiscsim/samplesvpilotrules.cpp index 657839467..17bda1791 100644 --- a/samples/blackmiscsim/samplesvpilotrules.cpp +++ b/samples/blackmiscsim/samplesvpilotrules.cpp @@ -30,7 +30,7 @@ namespace BlackSample /* * Samples */ - void CSamplesVPilotRules::samples(QTextStream &streamOut, QTextStream &streamIn) + void CSamplesVPilotRules::samples(QTextStream &streamOut, const QTextStream &streamIn) { BlackMisc::registerMetadata(); QScopedPointer vPilotReader(new CVPilotRulesReader()); diff --git a/samples/blackmiscsim/samplesvpilotrules.h b/samples/blackmiscsim/samplesvpilotrules.h index 29ce3e843..bf83ea1d5 100644 --- a/samples/blackmiscsim/samplesvpilotrules.h +++ b/samples/blackmiscsim/samplesvpilotrules.h @@ -21,7 +21,7 @@ namespace BlackSample { public: //! Run the samples - static void samples(QTextStream &streamOut, QTextStream &streamIn); + static void samples(QTextStream &streamOut, const QTextStream &streamIn); }; } // namespace diff --git a/src/blackcore/afv/clients/afvclient.cpp b/src/blackcore/afv/clients/afvclient.cpp index f952e13cc..3c9822846 100644 --- a/src/blackcore/afv/clients/afvclient.cpp +++ b/src/blackcore/afv/clients/afvclient.cpp @@ -204,7 +204,7 @@ namespace BlackCore // restart timer, normally it should be started already, paranoia // as I run in "my thread" starting timer should be OK { - QMutexLocker lock(&m_mutex); + QMutexLocker lock2(&m_mutex); if (m_voiceServerTimer) { m_voiceServerTimer->start(PositionUpdatesMs); } } m_retryConnectAttempt = 0; @@ -498,21 +498,21 @@ namespace BlackCore quint32 roundedFrequencyHz = static_cast(qRound(frequencyHz / 1000.0)) * 1000; roundedFrequencyHz = this->getAliasFrequencyHz(roundedFrequencyHz); - bool updateTransceivers = false; + bool update = false; { QMutexLocker lockTransceivers(&m_mutexTransceivers); if (m_transceivers.size() >= id + 1) { if (m_transceivers[id].frequencyHz != roundedFrequencyHz) { - updateTransceivers = true; + update = true; m_transceivers[id].frequencyHz = roundedFrequencyHz; } } } // outside lock to avoid deadlock - if (updateTransceivers) + if (update) { this->updateTransceivers(false); // no frequency update } diff --git a/src/blackcore/afv/connection/apiserverconnection.cpp b/src/blackcore/afv/connection/apiserverconnection.cpp index eda6585f9..e9e96e616 100644 --- a/src/blackcore/afv/connection/apiserverconnection.cpp +++ b/src/blackcore/afv/connection/apiserverconnection.cpp @@ -71,7 +71,7 @@ namespace BlackCore request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json"); // posted in QAM thread, reply is nullptr if called from another thread - QNetworkReply *reply = sApp->postToNetwork(request, CApplication::NoLogRequestId, QJsonDocument(obj).toJson(), + sApp->postToNetwork(request, CApplication::NoLogRequestId, QJsonDocument(obj).toJson(), { this, [ = ](QNetworkReply * nwReply) { @@ -125,7 +125,6 @@ namespace BlackCore callback(m_isAuthenticated); } }); - Q_UNUSED(reply) } PostCallsignResponseDto CApiServerConnection::addCallsign(const QString &callsign) @@ -176,7 +175,7 @@ namespace BlackCore QByteArray receivedData; // posted in QAM thread, reply is nullptr if called from another thread - QNetworkReply *reply = sApp->getFromNetwork(request, + sApp->getFromNetwork(request, { this, [ =, &receivedData ](QNetworkReply * nwReply) { @@ -198,7 +197,6 @@ namespace BlackCore if (loop) { loop->exit(); } } }); - Q_UNUSED(reply) if (loop) { loop->exec(); } return receivedData; @@ -212,7 +210,7 @@ namespace BlackCore QByteArray receivedData; // posted in QAM thread, reply is nullptr if called from another thread - QNetworkReply *reply = sApp->postToNetwork(request, CApplication::NoLogRequestId, data, + sApp->postToNetwork(request, CApplication::NoLogRequestId, data, { this, [ =, &receivedData ](QNetworkReply * nwReply) { @@ -234,7 +232,6 @@ namespace BlackCore if (loop) { loop->exit(); } } }); - Q_UNUSED(reply) if (loop) { loop->exec(); } return receivedData; diff --git a/src/blackcore/afv/connection/clientconnection.cpp b/src/blackcore/afv/connection/clientconnection.cpp index 9c418e816..1224cc841 100644 --- a/src/blackcore/afv/connection/clientconnection.cpp +++ b/src/blackcore/afv/connection/clientconnection.cpp @@ -61,15 +61,15 @@ namespace BlackCore if (authenticated) { - const QString callsign = m_connection.getCallsign(); - m_connection.setTokens(m_apiServerConnection->addCallsign(callsign)); + const QString cs = m_connection.getCallsign(); + m_connection.setTokens(m_apiServerConnection->addCallsign(cs)); m_connection.setTsAuthenticatedToNow(); m_connection.createCryptoChannels(); m_connection.setTsHeartbeatToNow(); this->connectToVoiceServer(); // taskServerConnectionCheck.Start(); - CLogMessage(this).info(u"Connected: '%1' to voice server, socket open: %2") << callsign << boolToYesNo(m_udpSocket->isOpen()); + CLogMessage(this).info(u"Connected: '%1' to voice server, socket open: %2") << cs << boolToYesNo(m_udpSocket->isOpen()); } else { diff --git a/src/blackcore/afv/crypto/cryptodtoserializer.h b/src/blackcore/afv/crypto/cryptodtoserializer.h index 773b9c645..0d1427191 100644 --- a/src/blackcore/afv/crypto/cryptodtoserializer.h +++ b/src/blackcore/afv/crypto/cryptodtoserializer.h @@ -52,7 +52,6 @@ namespace BlackCore headerBuffer.close(); const quint16 headerLength = static_cast(headerBuffer.buffer().size()); - const QByteArray dtoNameBuffer = T::getDtoName(); const QByteArray dtoShortName = T::getShortDtoName(); const quint16 dtoNameLength = static_cast(dtoShortName.size()); diff --git a/src/blackcore/aircraftmatcher.cpp b/src/blackcore/aircraftmatcher.cpp index d7cc848b3..6ffe57d47 100644 --- a/src/blackcore/aircraftmatcher.cpp +++ b/src/blackcore/aircraftmatcher.cpp @@ -523,7 +523,7 @@ namespace BlackCore return rv; } - MatchingScriptReturnValues CAircraftMatcher::matchingScript(const QString &js, const CAircraftModel &inModel, const CAircraftModel &matchedModel, const CAircraftMatcherSetup &setup, const CAircraftModelList &modelSet, MatchingScript ms, CStatusMessageList *log) + MatchingScriptReturnValues CAircraftMatcher::matchingScript(const QString &js, const CAircraftModel &inModel, const CAircraftModel &matchedModel, const CAircraftMatcherSetup &setup, const CAircraftModelList &modelSet, MatchingScript script, CStatusMessageList *log) { MatchingScriptReturnValues rv(inModel); QString logMessage; @@ -536,14 +536,14 @@ namespace BlackCore rv.runScript = true; // matching script - const bool msReverse = (ms == ReverseLookup); + const bool msReverse = (script == ReverseLookup); const QString lf = msReverse ? setup.getMsReverseLookupFile() : setup.getMsMatchingStageFile(); static const QString logFileR = CFileUtils::appendFilePaths(CDirectoryUtils::logDirectory(), "logMatchingScriptReverseLookup.log"); static const QString logFileM = CFileUtils::appendFilePaths(CDirectoryUtils::logDirectory(), "logMatchingScriptMatchingStage.log"); if (log) { - CLogUtilities::addLogDetailsToList(log, callsign, QStringLiteral("Matching script (%1): '%2'").arg(msToString(ms), lf)); + CLogUtilities::addLogDetailsToList(log, callsign, QStringLiteral("Matching script (%1): '%2'").arg(msToString(script), lf)); CLogUtilities::addLogDetailsToList(log, callsign, QStringLiteral("Matching script input model (%1): '%2'").arg(inModel.toQString(true))); CLogUtilities::addLogDetailsToList(log, callsign, QStringLiteral("Matching script models: %1").arg(modelSet.coverageSummary())); } diff --git a/src/blackcore/airspacemonitor.cpp b/src/blackcore/airspacemonitor.cpp index 53adbd77a..959d1579e 100644 --- a/src/blackcore/airspacemonitor.cpp +++ b/src/blackcore/airspacemonitor.cpp @@ -1436,18 +1436,16 @@ namespace BlackCore bool canLikelySkipNearGround = correctedSituation.canLikelySkipNearGroundInterpolation(); do { - if (canLikelySkipNearGround || correctedSituation.hasGroundElevation()) { break; } - - // set a defined state - correctedSituation.resetGroundElevation(); - // Check if we can bail out and ignore all elevation handling // // rational: // a) elevation handling is expensive, and might even requests elevation from sim. // b) elevations not needed pollute the cache with "useless" values // - if (canLikelySkipNearGround) { break; } + if (canLikelySkipNearGround || correctedSituation.hasGroundElevation()) { break; } + + // set a defined state + correctedSituation.resetGroundElevation(); // Guessing gives better values, also for smaller planes // and avoids unnecessary elevation fetching for low flying smaller GA aircraft diff --git a/src/blackcore/context/contextsimulatorimpl.cpp b/src/blackcore/context/contextsimulatorimpl.cpp index 457046dcf..8204a8c89 100644 --- a/src/blackcore/context/contextsimulatorimpl.cpp +++ b/src/blackcore/context/contextsimulatorimpl.cpp @@ -862,7 +862,6 @@ namespace BlackCore const CAircraftMatcherSetup setup = m_aircraftMatcher.getSetup(); if (setup.doModelAddFailover()) { - const CCallsign cs = remoteAircraft.getCallsign(); const int trial = m_failoverAddingCounts.value(cs, 0); if (trial < MaxModelAddedFailoverTrials) { diff --git a/src/blackcore/fsd/clientresponse.cpp b/src/blackcore/fsd/clientresponse.cpp index e6d4e6a7d..035e61e05 100644 --- a/src/blackcore/fsd/clientresponse.cpp +++ b/src/blackcore/fsd/clientresponse.cpp @@ -15,7 +15,7 @@ namespace BlackCore { namespace Fsd { - ClientResponse::ClientResponse() : MessageBase() + ClientResponse::ClientResponse() { } ClientResponse::ClientResponse(const QString &sender, const QString &receiver, ClientQueryType queryType, const QStringList &responseData) diff --git a/src/blackcore/fsd/clientresponse.h b/src/blackcore/fsd/clientresponse.h index eef680478..283c2bc77 100644 --- a/src/blackcore/fsd/clientresponse.h +++ b/src/blackcore/fsd/clientresponse.h @@ -38,7 +38,7 @@ namespace BlackCore static QString pdu() { return "$CR"; } //! Properties @{ - ClientQueryType m_queryType; + ClientQueryType m_queryType {}; QStringList m_responseData; //! @} diff --git a/src/blackcore/fsd/flightplan.cpp b/src/blackcore/fsd/flightplan.cpp index dd8b91875..38dfa1dc1 100644 --- a/src/blackcore/fsd/flightplan.cpp +++ b/src/blackcore/fsd/flightplan.cpp @@ -15,7 +15,7 @@ namespace BlackCore { namespace Fsd { - FlightPlan::FlightPlan() : MessageBase() { } + FlightPlan::FlightPlan() { } FlightPlan::FlightPlan(const QString &sender, const QString &receiver, FlightType flightType, const QString &aircraftIcaoType, int trueCruisingSpeed, const QString &depAirport, int estimatedDepTime, int actualDepTime, const QString &cruiseAlt, diff --git a/src/blackcore/fsd/flightplan.h b/src/blackcore/fsd/flightplan.h index f6b5c8642..d68e73528 100644 --- a/src/blackcore/fsd/flightplan.h +++ b/src/blackcore/fsd/flightplan.h @@ -38,7 +38,7 @@ namespace BlackCore static QString pdu() { return "$FP"; } //! Properties @{ - FlightType m_flightType; + FlightType m_flightType {}; QString m_aircraftIcaoType; int m_trueCruisingSpeed = 0; QString m_depAirport; diff --git a/src/blackcore/fsd/revbclientparts.h b/src/blackcore/fsd/revbclientparts.h index cccd6095b..1cd930f8d 100644 --- a/src/blackcore/fsd/revbclientparts.h +++ b/src/blackcore/fsd/revbclientparts.h @@ -25,7 +25,7 @@ namespace BlackCore { public: //! Constructor - RevBClientParts(const QString &sender, const QString &partsval1, const QString &partsval3, const QString &partsval2); + RevBClientParts(const QString &sender, const QString &partsval1, const QString &partsval2, const QString &partsval3); //! Message converted to tokens diff --git a/src/blackcore/fsd/servererror.cpp b/src/blackcore/fsd/servererror.cpp index 84ee18a8c..891ce5aed 100644 --- a/src/blackcore/fsd/servererror.cpp +++ b/src/blackcore/fsd/servererror.cpp @@ -15,7 +15,7 @@ namespace BlackCore { namespace Fsd { - ServerError::ServerError() : MessageBase() + ServerError::ServerError() { } ServerError::ServerError(const QString &sender, const QString &receiver, ServerErrorCode errorCode, const QString &causingParameter, const QString &description) diff --git a/src/blackcore/fsd/servererror.h b/src/blackcore/fsd/servererror.h index 8804d0425..06bd8ac3f 100644 --- a/src/blackcore/fsd/servererror.h +++ b/src/blackcore/fsd/servererror.h @@ -43,7 +43,7 @@ namespace BlackCore //! @} //! Properties @{ - ServerErrorCode m_errorNumber; + ServerErrorCode m_errorNumber {}; QString m_causingParameter; QString m_description; //! @} diff --git a/src/blackcore/setupreader.cpp b/src/blackcore/setupreader.cpp index 0b14b5a20..5832bd5f3 100644 --- a/src/blackcore/setupreader.cpp +++ b/src/blackcore/setupreader.cpp @@ -431,8 +431,8 @@ namespace BlackCore { // no issue with cache m_updateInfoUrls = loadedSetup.getSwiftUpdateInfoFileUrls(); - const CStatusMessage m = CLogMessage(this).info(u"Loaded setup from '%1'") << urlString; - emit this->setupLoadingMessages(m); + const CStatusMessage m2 = CLogMessage(this).info(u"Loaded setup from '%1'") << urlString; + emit this->setupLoadingMessages(m2); CLogMessage(this).info(u"Setup: Updated data cache in '%1'") << m_setup.getFilename(); { QWriteLocker l(&m_lockSetup); diff --git a/src/blackgui/components/dblogincomponent.cpp b/src/blackgui/components/dblogincomponent.cpp index 621ecd976..1a98950a8 100644 --- a/src/blackgui/components/dblogincomponent.cpp +++ b/src/blackgui/components/dblogincomponent.cpp @@ -49,8 +49,7 @@ namespace BlackGui Q_ASSERT_X(sGui, Q_FUNC_INFO, "Missing sGui"); ui->setupUi(this); this->setModeLogin(true); - const CUrl url(sGui->getGlobalSetup().getDbHomePageUrl()); - const QString urlString = asHyperlink(url.getFullUrl()); + const QString urlString = asHyperlink(sGui->getGlobalSetup().getDbHomePageUrl().getFullUrl()); QString html = ui->tbr_InfoAndHints->toHtml(); html = html.replace("##swiftDB##", urlString, Qt::CaseInsensitive); html = html.replace("##swiftEnableSSO##", urlString, Qt::CaseInsensitive); diff --git a/src/blackgui/components/flightplancomponent.cpp b/src/blackgui/components/flightplancomponent.cpp index f5bc02daa..72ddb2d63 100644 --- a/src/blackgui/components/flightplancomponent.cpp +++ b/src/blackgui/components/flightplancomponent.cpp @@ -1015,7 +1015,6 @@ namespace BlackGui void CFlightPlanComponent::setRemarksUIValues(const QString &remarks) { if (remarks.isEmpty()) { return; } - const QString r = remarks.toUpper(); if (remarks.contains("/V")) { diff --git a/src/blackgui/components/loginadvcomponent.cpp b/src/blackgui/components/loginadvcomponent.cpp index 9ae346ca9..3359cd916 100644 --- a/src/blackgui/components/loginadvcomponent.cpp +++ b/src/blackgui/components/loginadvcomponent.cpp @@ -310,11 +310,7 @@ namespace BlackGui void CLoginAdvComponent::setGuiLoginAsValues(const CSimulatedAircraft &ownAircraft) { - const QString ac( - ownAircraft.getAircraftIcaoCodeDesignator() % - (ownAircraft.hasAirlineDesignator() ? (u' ' % ownAircraft.getAirlineIcaoCodeDesignator()) : QString()) % - (ownAircraft.hasModelString() ? (u' ' % ownAircraft.getModelString()) : QString()) - ); + Q_UNUSED(ownAircraft) } CServer CLoginAdvComponent::getCurrentVatsimServer() const @@ -382,7 +378,6 @@ namespace BlackGui // in any case override if connected ui->comp_OwnAircraft->setOwnModelAndIcaoValues(); - const CServer server = nwc->getConnectedServer(); ui->comp_NetworkDetails->setLoginMode(nwc->getLoginMode()); const CSimulatedAircraft ownAircraft = sGui->getIContextOwnAircraft()->getOwnAircraft(); this->setGuiLoginAsValues(ownAircraft); diff --git a/src/blackgui/components/modelmatchercomponent.cpp b/src/blackgui/components/modelmatchercomponent.cpp index 0b52c8617..7a6616fd2 100644 --- a/src/blackgui/components/modelmatchercomponent.cpp +++ b/src/blackgui/components/modelmatchercomponent.cpp @@ -133,8 +133,8 @@ namespace BlackGui ui->tvp_ResultMessages->insert(m); return; } - CSimulatorInfo simulator = models.simulatorsWithMaxEntries(); - m_matcher.setModelSet(models, simulator, true); + CSimulatorInfo si = models.simulatorsWithMaxEntries(); + m_matcher.setModelSet(models, si, true); } else { @@ -150,7 +150,7 @@ namespace BlackGui this->onSimulatorChanged(ui->comp_SimulatorSelector->getValue()); } - void CModelMatcherComponent::onCacheChanged(CSimulatorInfo &simulator) + void CModelMatcherComponent::onCacheChanged(const CSimulatorInfo &simulator) { Q_UNUSED(simulator); this->redisplay(); diff --git a/src/blackgui/components/modelmatchercomponent.h b/src/blackgui/components/modelmatchercomponent.h index fad7d28b4..fef942a6c 100644 --- a/src/blackgui/components/modelmatchercomponent.h +++ b/src/blackgui/components/modelmatchercomponent.h @@ -61,7 +61,7 @@ namespace BlackGui void onWorkbenchToggled(bool checked); //! Cache changed - void onCacheChanged(BlackMisc::Simulation::CSimulatorInfo &simulator); + void onCacheChanged(const BlackMisc::Simulation::CSimulatorInfo &simulator); //! Web data have been read void onWebDataRead(BlackMisc::Network::CEntityFlags::Entity entity, BlackMisc::Network::CEntityFlags::ReadState state, int number, const QUrl &url); diff --git a/src/blackgui/components/networkdetailscomponent.cpp b/src/blackgui/components/networkdetailscomponent.cpp index e93d2bba2..b532cb477 100644 --- a/src/blackgui/components/networkdetailscomponent.cpp +++ b/src/blackgui/components/networkdetailscomponent.cpp @@ -179,8 +179,6 @@ namespace BlackGui void CNetworkDetailsComponent::onSelectedServerChanged(const CServer &server) { if (!m_updatePilotOnServerChanges) { return; } - const bool vatsim = this->isVatsimServerSelected(); - const CUser user = vatsim ? this->getCurrentVatsimServer().getUser() : server.getUser(); emit this->overridePilot(server.getUser()); } diff --git a/src/blackgui/components/radarcomponent.cpp b/src/blackgui/components/radarcomponent.cpp index bd91c3a9d..230ba7148 100644 --- a/src/blackgui/components/radarcomponent.cpp +++ b/src/blackgui/components/radarcomponent.cpp @@ -295,7 +295,7 @@ namespace BlackGui // in which North=(1,0) and East=(-1,0) // but we want North=(0,-1) and East=(0,1) // (QGraphicsView y axis increases downwards) - qSwap(p.rx(), p.ry()); + std::swap(p.rx(), p.ry()); p.setX(-p.x()); p.setY(-p.y()); return p; diff --git a/src/blackgui/components/settingsfontcomponent.cpp b/src/blackgui/components/settingsfontcomponent.cpp index 946aec3f2..3ad0a2dae 100644 --- a/src/blackgui/components/settingsfontcomponent.cpp +++ b/src/blackgui/components/settingsfontcomponent.cpp @@ -98,7 +98,6 @@ namespace BlackGui const QString fontFamily = ui->cb_SettingsGuiFont->currentFont().family(); const QString fontStyleCombined = ui->cb_SettingsGuiFontStyle->currentText(); - const QStringList familySizeStyle = this->getFamilySizeStyle(); QString fontColor = m_selectedColor.name(); if (!m_selectedColor.isValid() || m_selectedColor.name().isEmpty()) { diff --git a/src/blackgui/components/settingsnetworkserverscomponent.cpp b/src/blackgui/components/settingsnetworkserverscomponent.cpp index fee275339..a9d4f0c4e 100644 --- a/src/blackgui/components/settingsnetworkserverscomponent.cpp +++ b/src/blackgui/components/settingsnetworkserverscomponent.cpp @@ -101,6 +101,7 @@ namespace BlackGui else { qFatal("Wrong sender"); + // cppcheck-suppress duplicateBreak return; } diff --git a/src/blackgui/views/aircraftcategorytreeview.cpp b/src/blackgui/views/aircraftcategorytreeview.cpp index a79716073..8ff86c70b 100644 --- a/src/blackgui/views/aircraftcategorytreeview.cpp +++ b/src/blackgui/views/aircraftcategorytreeview.cpp @@ -88,8 +88,6 @@ namespace BlackGui CAircraftCategory CAircraftCategoryTreeView::selectedObject() const { - const QModelIndex index = this->currentIndex(); - const QVariant data = this->model()->data(index.siblingAtColumn(0)); const CAircraftCategoryTreeModel *model = this->categoryModel(); if (!model) { return CAircraftCategory(); } return model->container().frontOrDefault(); diff --git a/src/blackgui/views/viewbase.h b/src/blackgui/views/viewbase.h index 2d3fd1b5a..4aa7ac002 100644 --- a/src/blackgui/views/viewbase.h +++ b/src/blackgui/views/viewbase.h @@ -706,10 +706,10 @@ namespace BlackGui int removeIf(K0 k0, V0 v0, KeysValues... keysValues) { if (this->rowCount() < 1) { return 0; } - ContainerType copy(container()); - int r = copy.removeIf(k0, v0, keysValues...); + ContainerType cp(container()); + int r = cp.removeIf(k0, v0, keysValues...); if (r < 1) { return 0; } - this->updateContainerMaybeAsync(copy); + this->updateContainerMaybeAsync(cp); return r; } @@ -717,9 +717,9 @@ namespace BlackGui template void replaceOrAdd(K1 key1, V1 value1, const ObjectType &replacement) { - ContainerType copy(container()); - copy.replaceOrAdd(key1, value1, replacement); - this->updateContainerMaybeAsync(copy); + ContainerType cp(container()); + cp.replaceOrAdd(key1, value1, replacement); + this->updateContainerMaybeAsync(cp); } //! \name Slot overrides from base class diff --git a/src/blackinput/win/keyboardwindows.cpp b/src/blackinput/win/keyboardwindows.cpp index 7fb99478a..de1894d23 100644 --- a/src/blackinput/win/keyboardwindows.cpp +++ b/src/blackinput/win/keyboardwindows.cpp @@ -112,6 +112,7 @@ namespace BlackInput bool CKeyboardWindows::init() { + // cppcheck-suppress knownConditionTrueFalse if (useWindowsHook) { Q_ASSERT_X(g_keyboardWindows == nullptr, "CKeyboardWindows::init", "Windows supports only one keyboard instance. Cannot initialize a second one!"); diff --git a/src/blackmisc/algorithm.h b/src/blackmisc/algorithm.h index c407181b3..ef85ae7cd 100644 --- a/src/blackmisc/algorithm.h +++ b/src/blackmisc/algorithm.h @@ -175,6 +175,7 @@ namespace BlackMisc static_cast(std::initializer_list { //! \fixme C-style cast is needed due to a clang bug: https://bugs.llvm.org/show_bug.cgi?id=39375 + // cppcheck-suppress accessForwarded ((void)(std::forward(visitor)(std::get(std::forward(tuple)), std::get(std::forward(tuple)))), 0)... }); } diff --git a/src/blackmisc/aviation/airlineicaocode.cpp b/src/blackmisc/aviation/airlineicaocode.cpp index 5d8e4adca..95742e97d 100644 --- a/src/blackmisc/aviation/airlineicaocode.cpp +++ b/src/blackmisc/aviation/airlineicaocode.cpp @@ -495,11 +495,10 @@ namespace BlackMisc QSet ids; dir.setFilter(QDir::Files | QDir::NoSymLinks); dir.setSorting(QDir::Name); - bool ok = false; for (const QFileInfo &fileInfo : dir.entryInfoList()) { const QString fn(fileInfo.fileName()); - ok = fn.size() > 5; + bool ok = fn.size() > 5; if (!ok) { continue; } BLACK_VERIFY_X(ok, Q_FUNC_INFO, "wrong file name"); const int id = fn.leftRef(5).toInt(&ok); diff --git a/src/blackmisc/datacache.cpp b/src/blackmisc/datacache.cpp index 22112836e..40979dd1a 100644 --- a/src/blackmisc/datacache.cpp +++ b/src/blackmisc/datacache.cpp @@ -233,7 +233,7 @@ namespace BlackMisc { QMutexLocker lock(&m_mutex); decltype(m_queue) queue; - qSwap(m_queue, queue); + std::swap(m_queue, queue); lock.unlock(); for (const auto &pair : BlackMisc::as_const(queue)) @@ -391,13 +391,13 @@ namespace BlackMisc { m_originalTimestamps = fromJson(json.value("timestamps").toObject()); - QUuid uuid(json.value("uuid").toString()); - if (uuid == m_uuid && m_admittedQueue.isEmpty()) + QUuid id(json.value("uuid").toString()); + if (id == m_uuid && m_admittedQueue.isEmpty()) { if (m_pendingWrite) { return guard; } return {}; } - if (updateUuid) { m_uuid = uuid; } + if (updateUuid) { m_uuid = id; } auto timesToLive = fromJson(json.value("ttl").toObject()); for (auto it = m_originalTimestamps.cbegin(); it != m_originalTimestamps.cend(); ++it) @@ -807,19 +807,19 @@ namespace BlackMisc return; } auto json = QJsonDocument::fromJson(file.readAll()).object(); - QUuid uuid(json.value("uuid").toString()); + QUuid id(json.value("uuid").toString()); CSequence apps; auto status = apps.convertFromJsonNoThrow(json.value("apps").toObject(), this, QStringLiteral("Error in %1 apps object").arg(m_filename)); apps.removeIf([](const CProcessInfo & pi) { return ! pi.exists(); }); - if (apps.isEmpty()) { uuid = CIdentifier().toUuid(); } - m_uuid = uuid; + if (apps.isEmpty()) { id = CIdentifier().toUuid(); } + m_uuid = id; CProcessInfo currentProcess = CProcessInfo::currentProcess(); Q_ASSERT(currentProcess.exists()); apps.replaceOrAdd(currentProcess); json.insert("apps", apps.toJson()); - json.insert("uuid", uuid.toString()); + json.insert("uuid", m_uuid.toString()); if (file.seek(0) && file.resize(0) && file.write(QJsonDocument(json).toJson())) { if (!file.checkedClose()) diff --git a/src/blackmisc/geo/coordinategeodetic.cpp b/src/blackmisc/geo/coordinategeodetic.cpp index f9c186ec6..352ce6a61 100644 --- a/src/blackmisc/geo/coordinategeodetic.cpp +++ b/src/blackmisc/geo/coordinategeodetic.cpp @@ -474,6 +474,7 @@ namespace BlackMisc default: const QString m = QString("no property, index ").append(index.toQString()); Q_ASSERT_X(false, Q_FUNC_INFO, m.toLocal8Bit().constData()); + Q_UNUSED(m) break; } } diff --git a/src/blackmisc/json.cpp b/src/blackmisc/json.cpp index 214c0d4f2..e84a18111 100644 --- a/src/blackmisc/json.cpp +++ b/src/blackmisc/json.cpp @@ -544,7 +544,6 @@ namespace BlackMisc QJsonObject unwrapCache(const QJsonObject &object) { if (object.size() != 1) { return object; } // no cache format - const QString key = object.constBegin().key(); const QJsonObject cacheObject = object.constBegin()->toObject(); if (cacheObject.contains("type") && cacheObject.contains("value")) { diff --git a/src/blackmisc/network/textmessage.cpp b/src/blackmisc/network/textmessage.cpp index e809bc159..ad56cb732 100644 --- a/src/blackmisc/network/textmessage.cpp +++ b/src/blackmisc/network/textmessage.cpp @@ -252,7 +252,7 @@ namespace BlackMisc void CTextMessage::toggleSenderRecipient() { - qSwap(m_senderCallsign, m_recipientCallsign); + std::swap(m_senderCallsign, m_recipientCallsign); } bool CTextMessage::isSelcalMessage() const diff --git a/src/blackmisc/network/textmessagelist.cpp b/src/blackmisc/network/textmessagelist.cpp index b1bedc8ec..17ecf0179 100644 --- a/src/blackmisc/network/textmessagelist.cpp +++ b/src/blackmisc/network/textmessagelist.cpp @@ -48,7 +48,7 @@ namespace BlackMisc this->push_back(message); } - CTextMessageList::CTextMessageList(const QString &message, const QList &frequencies, const BlackMisc::Aviation::CCallsign &fromCallsign) + CTextMessageList::CTextMessageList(const QString &message, const QList &frequencies, const CCallsign &fromCallsign) { if (frequencies.isEmpty()) return; for (const CFrequency &frequency : frequencies) diff --git a/src/blackmisc/network/textmessagelist.h b/src/blackmisc/network/textmessagelist.h index b5e9f6b52..a8083b24d 100644 --- a/src/blackmisc/network/textmessagelist.h +++ b/src/blackmisc/network/textmessagelist.h @@ -50,13 +50,13 @@ namespace BlackMisc CTextMessageList(const QString &message, const Aviation::CCallsign &senderCallsign, const Aviation::CCallsign &recipientCallsign); //! Constructor, single radio message - CTextMessageList(const QString &message, const PhysicalQuantities::CFrequency &frequency, const Aviation::CCallsign &senderCallsign = Aviation::CCallsign()); + CTextMessageList(const QString &message, const PhysicalQuantities::CFrequency &frequency, const Aviation::CCallsign &senderCallsign = {}); //! Constructor, single message CTextMessageList(const CTextMessage &message); //! Constructor, multi-frequency radio messages - CTextMessageList(const QString &message, const QList &frequencies, const Aviation::CCallsign &sender = Aviation::CCallsign()); + CTextMessageList(const QString &message, const QList &frequencies, const Aviation::CCallsign &fromCallsign = {}); //! Construct from a base class object. CTextMessageList(const CSequence &other); diff --git a/src/blackmisc/simulation/fscommon/fscommonutil.cpp b/src/blackmisc/simulation/fscommon/fscommonutil.cpp index bd56ed11d..0cdc9ee18 100644 --- a/src/blackmisc/simulation/fscommon/fscommonutil.cpp +++ b/src/blackmisc/simulation/fscommon/fscommonutil.cpp @@ -633,15 +633,15 @@ namespace BlackMisc // make absolute if (!soPath.left(3).contains(':')) { soPath = CFileUtils::appendFilePaths(relPath, soPath); } - const QDir p(soPath); // always absolute path now - if (checked && !p.exists()) + const QDir dir(soPath); // always absolute path now + if (checked && !dir.exists()) { // skip, not existing - if (logConfigPathReading()) { CLogMessage(getLogCategories()).info(u"FSX SimObjects path skipped, not existing: '%1' in '%2'") << p.absolutePath() << fsxFile; } + if (logConfigPathReading()) { CLogMessage(getLogCategories()).info(u"FSX SimObjects path skipped, not existing: '%1' in '%2'") << dir.absolutePath() << fsxFile; } continue; } - const QString afp = p.absolutePath().toLower(); + const QString afp = dir.absolutePath().toLower(); if (!CDirectoryUtils::containsFileInDir(afp, airFileFilter(), true)) { if (logConfigPathReading()) { CLogMessage(getLogCategories()).info(u"FSX SimObjects path: Skipping '%1' from '%2', no '%3' file") << afp << fsxFile << airFileFilter(); } diff --git a/src/blackmisc/simulation/interpolator.cpp b/src/blackmisc/simulation/interpolator.cpp index 100e4c6f8..7660d5841 100644 --- a/src/blackmisc/simulation/interpolator.cpp +++ b/src/blackmisc/simulation/interpolator.cpp @@ -302,7 +302,7 @@ namespace BlackMisc } else { - const qint64 diff = noSituation ? -1 : m_currentTimeMsSinceEpoch - currentSituation.getAdjustedMSecsSinceEpoch(); + const qint64 diff = m_currentTimeMsSinceEpoch - currentSituation.getAdjustedMSecsSinceEpoch(); m = CStatusMessage(this).warning(u"Invalid situation, diff. %1ms #%2 for interpolation reported for '%3' (Interpolant: %4 interpolation: %5)") << diff << m_invalidSituations << m_callsign.asString() << boolToTrueFalse(isValidInterpolant) << boolToTrueFalse(isValidInterpolation); } @@ -609,10 +609,10 @@ namespace BlackMisc } else { - CAircraftModel model = this->getAircraftInRangeForCallsign(m_callsign).getModel(); - if (model.hasModelString()) + CAircraftModel foundModel = this->getAircraftInRangeForCallsign(m_callsign).getModel(); + if (foundModel.hasModelString()) { - m_model = model; + m_model = foundModel; } } this->getAndFetchModelCG(model.getCG()); diff --git a/src/blackmisc/simulation/settings/simulatorsettings.cpp b/src/blackmisc/simulation/settings/simulatorsettings.cpp index 2c0b2097e..8e7f8dfbe 100644 --- a/src/blackmisc/simulation/settings/simulatorsettings.cpp +++ b/src/blackmisc/simulation/settings/simulatorsettings.cpp @@ -126,7 +126,7 @@ namespace BlackMisc return true; } - bool CSimulatorSettings::setRecordedGndRadius(CLength &radius) + bool CSimulatorSettings::setRecordedGndRadius(const CLength &radius) { if (radius == m_recordedGndRadius) { return false; } m_recordedGndRadius = radius; diff --git a/src/blackmisc/simulation/settings/simulatorsettings.h b/src/blackmisc/simulation/settings/simulatorsettings.h index c9fb3295a..ea78291f4 100644 --- a/src/blackmisc/simulation/settings/simulatorsettings.h +++ b/src/blackmisc/simulation/settings/simulatorsettings.h @@ -124,7 +124,7 @@ namespace BlackMisc BlackMisc::PhysicalQuantities::CLength getRecordedGndRadius() const { return m_recordedGndRadius; } //! Record GND values with radius - bool setRecordedGndRadius(BlackMisc::PhysicalQuantities::CLength &radius); + bool setRecordedGndRadius(const BlackMisc::PhysicalQuantities::CLength &radius); //! Reset the paths void resetPaths(); diff --git a/src/blackmisc/simulation/xplane/aircraftmodelloaderxplane.cpp b/src/blackmisc/simulation/xplane/aircraftmodelloaderxplane.cpp index 6caa7beb2..3d18b2d51 100644 --- a/src/blackmisc/simulation/xplane/aircraftmodelloaderxplane.cpp +++ b/src/blackmisc/simulation/xplane/aircraftmodelloaderxplane.cpp @@ -575,15 +575,15 @@ namespace BlackMisc return false; } - QFileInfo fileInfo(absoluteTexPath); - if (!fileInfo.exists()) + QFileInfo texFileInfo(absoluteTexPath); + if (!texFileInfo.exists()) { const CStatusMessage m = CStatusMessage(this).error(u"%1/xsb_aircraft.txt Line %2 : Texture '%3' does not exist.") << path << lineNum << absoluteTexPath; m_loadingMessages.push_back(m); return false; } - package.planes.back().textureName = fileInfo.completeBaseName(); + package.planes.back().textureName = texFileInfo.completeBaseName(); } return true; } diff --git a/src/blacksound/audioutilities.cpp b/src/blacksound/audioutilities.cpp index fcd930d78..a99c230ff 100644 --- a/src/blacksound/audioutilities.cpp +++ b/src/blacksound/audioutilities.cpp @@ -19,7 +19,7 @@ using namespace BlackMisc::Audio; namespace BlackSound { - QVector convertBytesTo32BitFloatPCM(const QByteArray input) + QVector convertBytesTo32BitFloatPCM(const QByteArray &input) { int inputSamples = input.size() / 2; // 16 bit input, so 2 bytes per sample QVector output; @@ -33,7 +33,7 @@ namespace BlackSound return output; } - QVector convertBytesTo16BitPCM(const QByteArray input) + QVector convertBytesTo16BitPCM(const QByteArray &input) { const int inputSamples = input.size() / 2; // 16 bit input, so 2 bytes per sample QVector output; @@ -45,7 +45,7 @@ namespace BlackSound return output; } - QVector convertFloatBytesTo16BitPCM(const QByteArray input) + QVector convertFloatBytesTo16BitPCM(const QByteArray &input) { Q_UNUSED(input) // qFatal("Not implemented"); diff --git a/src/blacksound/audioutilities.h b/src/blacksound/audioutilities.h index 431b49e6f..798b72484 100644 --- a/src/blacksound/audioutilities.h +++ b/src/blacksound/audioutilities.h @@ -21,9 +21,9 @@ namespace BlackSound { //! Conversion functions @{ - BLACKSOUND_EXPORT QVector convertBytesTo32BitFloatPCM(const QByteArray input); - BLACKSOUND_EXPORT QVector convertBytesTo16BitPCM(const QByteArray input); - BLACKSOUND_EXPORT QVector convertFloatBytesTo16BitPCM(const QByteArray input); + BLACKSOUND_EXPORT QVector convertBytesTo32BitFloatPCM(const QByteArray &input); + BLACKSOUND_EXPORT QVector convertBytesTo16BitPCM(const QByteArray &input); + BLACKSOUND_EXPORT QVector convertFloatBytesTo16BitPCM(const QByteArray &input); BLACKSOUND_EXPORT QVector convertFromMonoToStereo(const QVector &mono); BLACKSOUND_EXPORT QVector convertFromStereoToMono(const QVector &stereo); BLACKSOUND_EXPORT QVector convertFromShortToFloat(const QVector &input); diff --git a/src/blacksound/codecs/opusdecoder.cpp b/src/blacksound/codecs/opusdecoder.cpp index 4b686e16c..f86ec2c45 100644 --- a/src/blacksound/codecs/opusdecoder.cpp +++ b/src/blacksound/codecs/opusdecoder.cpp @@ -31,7 +31,7 @@ namespace BlackSound return bufferSize / bytesPerSample; } - QVector COpusDecoder::decode(const QByteArray opusData, int dataLength, int *decodedLength) + QVector COpusDecoder::decode(const QByteArray &opusData, int dataLength, int *decodedLength) { QVector decoded(MaxDataBytes, 0); int count = frameCount(MaxDataBytes); diff --git a/src/blacksound/codecs/opusdecoder.h b/src/blacksound/codecs/opusdecoder.h index 9db72449a..107c38d91 100644 --- a/src/blacksound/codecs/opusdecoder.h +++ b/src/blacksound/codecs/opusdecoder.h @@ -39,7 +39,7 @@ namespace BlackSound int frameCount(int bufferSize); //! Decode - QVector decode(const QByteArray opusData, int dataLength, int *decodedLength); + QVector decode(const QByteArray &opusData, int dataLength, int *decodedLength); //! Reset void resetState(); diff --git a/src/blacksound/codecs/opusencoder.cpp b/src/blacksound/codecs/opusencoder.cpp index 5efbdfb6f..0b3bb137d 100644 --- a/src/blacksound/codecs/opusencoder.cpp +++ b/src/blacksound/codecs/opusencoder.cpp @@ -12,9 +12,7 @@ namespace BlackSound { namespace Codecs { - COpusEncoder::COpusEncoder(int sampleRate, int channels, int application) : - m_sampleRate(sampleRate), - m_channels(channels) + COpusEncoder::COpusEncoder(int sampleRate, int channels, int application) { int error; opusEncoder = opus_encoder_create(sampleRate, channels, application, &error); @@ -30,7 +28,7 @@ namespace BlackSound opus_encoder_ctl(opusEncoder, OPUS_SET_BITRATE(bitRate)); } - QByteArray COpusEncoder::encode(const QVector pcmSamples, int samplesLength, int *encodedLength) + QByteArray COpusEncoder::encode(const QVector &pcmSamples, int samplesLength, int *encodedLength) { QByteArray encoded(maxDataBytes, 0); int length = opus_encode(opusEncoder, reinterpret_cast(pcmSamples.data()), samplesLength, reinterpret_cast(encoded.data()), maxDataBytes); diff --git a/src/blacksound/codecs/opusencoder.h b/src/blacksound/codecs/opusencoder.h index 19006b6ef..f4753c60f 100644 --- a/src/blacksound/codecs/opusencoder.h +++ b/src/blacksound/codecs/opusencoder.h @@ -40,20 +40,11 @@ namespace BlackSound //! Bit rate void setBitRate(int bitRate); - //! \param frameCount Number of audio samples per frame - //! \returns the size of an audio frame in bytes - int frameByteCount(int frameCount); - - //! Frame count - int frameCount(const QVector pcmSamples); - //! Encode - QByteArray encode(const QVector pcmSamples, int samplesLength, int *encodedLength); + QByteArray encode(const QVector &pcmSamples, int samplesLength, int *encodedLength); private: OpusEncoder *opusEncoder = nullptr; - int m_sampleRate; - int m_channels; static constexpr int maxDataBytes = 4000; }; diff --git a/src/plugins/simulator/emulated/simulatoremulated.cpp b/src/plugins/simulator/emulated/simulatoremulated.cpp index 47fb288fb..8ca3bf926 100644 --- a/src/plugins/simulator/emulated/simulatoremulated.cpp +++ b/src/plugins/simulator/emulated/simulatoremulated.cpp @@ -581,7 +581,6 @@ namespace BlackSimPlugin { if (!m_isWeatherActivated) { return false; } - const CWeatherScenario s = m_weatherScenarioSettings.get(); this->getOwnAircraftPosition(); const CCoordinateGeodetic currentPosition = this->getOwnAircraftPosition(); this->requestWeatherGrid(currentPosition, this->identifier()); diff --git a/src/plugins/simulator/fs9/multiplayerpacketparser.h b/src/plugins/simulator/fs9/multiplayerpacketparser.h index 6612286cd..e563752b8 100644 --- a/src/plugins/simulator/fs9/multiplayerpacketparser.h +++ b/src/plugins/simulator/fs9/multiplayerpacketparser.h @@ -61,7 +61,7 @@ namespace BlackSimPlugin struct Serializer { static const QByteArray &read(const QByteArray &data, MsgTuple &) { return data; } - static QByteArray write(QByteArray &data, const MsgTuple &) { return data; } + static QByteArray write(const QByteArray &data, const MsgTuple &) { return data; } }; template< typename MessageTuple, quint32 Size > diff --git a/src/plugins/simulator/fscommon/fsuipcdummy.cpp b/src/plugins/simulator/fscommon/fsuipcdummy.cpp index 7429e4fc3..8174b3f8f 100644 --- a/src/plugins/simulator/fscommon/fsuipcdummy.cpp +++ b/src/plugins/simulator/fscommon/fsuipcdummy.cpp @@ -78,6 +78,7 @@ namespace BlackSimPlugin return QStringLiteral("N/A"); } + // cppcheck-suppress constParameter bool CFsuipc::read(CSimulatedAircraft &aircraft, bool cockpit, bool situation, bool aircraftParts) { Q_UNUSED(aircraft); diff --git a/src/plugins/simulator/fscommon/fsuipcimpl.cpp b/src/plugins/simulator/fscommon/fsuipcimpl.cpp index c0b638b5c..0f95993de 100644 --- a/src/plugins/simulator/fscommon/fsuipcimpl.cpp +++ b/src/plugins/simulator/fscommon/fsuipcimpl.cpp @@ -453,9 +453,6 @@ namespace BlackSimPlugin { read = true; - // time, basically as a heartbeat - QString fsTime = QString::asprintf("%02d:%02d:%02d", localFsTimeRaw[0], localFsTimeRaw[1], localFsTimeRaw[2]); - if (cockpit) { // COMs @@ -491,6 +488,7 @@ namespace BlackSimPlugin // position const double latCorrectionFactor = 90.0 / (10001750.0 * 65536.0 * 65536.0); const double lonCorrectionFactor = 360.0 / (65536.0 * 65536.0 * 65536.0 * 65536.0); + // cppcheck-suppress shadowArgument CAircraftSituation situation = aircraft.getSituation(); CCoordinateGeodetic position = situation.getPosition(); CLatitude lat(latitudeRaw * latCorrectionFactor, CAngleUnit::deg()); diff --git a/src/plugins/simulator/fsxcommon/simulatorfsxcommon.cpp b/src/plugins/simulator/fsxcommon/simulatorfsxcommon.cpp index ffb226aa1..52029c5aa 100644 --- a/src/plugins/simulator/fsxcommon/simulatorfsxcommon.cpp +++ b/src/plugins/simulator/fsxcommon/simulatorfsxcommon.cpp @@ -1106,7 +1106,6 @@ namespace BlackSimPlugin CAircraftModel model = simObject.getAircraftModel(); const CSpecializedSimulatorSettings settings = this->getSimulatorSettings(); - const QStringList modelDirectories = settings.getModelDirectoriesFromSimulatorDirectoryOrDefault(); const bool fileExists = CFsCommonUtil::adjustFileDirectory(model, settings.getModelDirectoriesOrDefault()); bool canBeUsed = true; @@ -1586,7 +1585,6 @@ namespace BlackSimPlugin if (situations.isEmpty()) { CLogMessage(this).warning(u"No valid situations for '%1', will be added as pending") << callsign.asString(); - canAdd = false; } else { @@ -1596,11 +1594,10 @@ namespace BlackSimPlugin } // still invalid? - const bool invalidSituation = situation.isPositionOrAltitudeNull(); - canAdd = invalidSituation; + canAdd = situation.isPositionOrAltitudeNull(); if (CBuildConfig::isLocalDeveloperDebugBuild()) { - BLACK_VERIFY_X(invalidSituation, Q_FUNC_INFO, "Expect valid situation"); + BLACK_VERIFY_X(canAdd, Q_FUNC_INFO, "Expect valid situation"); CLogMessage(this).warning(u"Invalid situation for '%1'") << callsign; } } diff --git a/src/swiftguistandard/swiftguistdmenus.cpp b/src/swiftguistandard/swiftguistdmenus.cpp index 9086c82aa..3a492a192 100644 --- a/src/swiftguistandard/swiftguistdmenus.cpp +++ b/src/swiftguistandard/swiftguistdmenus.cpp @@ -156,9 +156,9 @@ void SwiftGuiStd::initMenus() if (CBuildConfig::isLocalDeveloperDebugBuild() && ui->menu_File && ui->menu_File->actions().size() > 5) { - QAction *a = new QAction(CIcons::swift16(), "Copy XSwiftBus dialog"); - ui->menu_File->insertAction(ui->menu_File->actions().at(5), a); - c = connect(a, &QAction::triggered, this, [ = ] + QAction *act = new QAction(CIcons::swift16(), "Copy XSwiftBus dialog"); + ui->menu_File->insertAction(ui->menu_File->actions().at(5), act); + c = connect(act, &QAction::triggered, this, [ = ] { this->copyXSwiftBusDialog(false); }, Qt::QueuedConnection); diff --git a/src/xswiftbus/traffic.cpp b/src/xswiftbus/traffic.cpp index 538648428..7f4139b80 100644 --- a/src/xswiftbus/traffic.cpp +++ b/src/xswiftbus/traffic.cpp @@ -980,6 +980,7 @@ namespace XSwiftBus // fixme: In a future update, change the orbit only while right mouse button is pressed. XPLMGetScreenSize(&w, &h); XPLMGetMouseLocation(&x, &y); + // cppcheck-suppress knownConditionTrueFalse if (DEBUG) { DEBUG_LOG("Follow aircraft coordinates w,h,x,y: " + std::to_string(w) + " " + std::to_string(h) + " " + std::to_string(x) + " " + std::to_string(y)); } if (traffic->m_lastMouseX == x && traffic->m_lastMouseY == y && traffic->m_lastMouseX >= 0 && traffic->m_lastMouseY >= 0) { @@ -1104,12 +1105,13 @@ namespace XSwiftBus return 0; } - // Return 1 to indicate we want to keep controlling the camera. + // cppcheck-suppress knownConditionTrueFalse if (DEBUG) { DEBUG_LOG("Camera: " + pos2String(cameraPosition)); DEBUG_LOG("Follow aircraft " + traffic->m_followPlaneViewCallsign + " " + modelName); } + // Return 1 to indicate we want to keep controlling the camera. return 1; } diff --git a/tests/blackmisc/simulation/testinterpolatorlinear/testinterpolatorlinear.cpp b/tests/blackmisc/simulation/testinterpolatorlinear/testinterpolatorlinear.cpp index c5ce58aab..3e159867b 100644 --- a/tests/blackmisc/simulation/testinterpolatorlinear/testinterpolatorlinear.cpp +++ b/tests/blackmisc/simulation/testinterpolatorlinear/testinterpolatorlinear.cpp @@ -192,12 +192,11 @@ namespace BlackMiscTest const int steps = 10; const double tfStep = 1.0 / steps; - double timeFraction = 0; double lastDeg = 0; for (int i = 0; i < steps; i++) { - timeFraction = tfStep * i; + double timeFraction = tfStep * i; pbh.setTimeFraction(timeFraction); const CHeading heading = pbh.getHeading(); const double h = heading.value(CAngleUnit::deg()); @@ -215,7 +214,7 @@ namespace BlackMiscTest for (int i = 0; i < steps; i++) { - timeFraction = tfStep * i; + double timeFraction = tfStep * i; pbh.setTimeFraction(timeFraction); const CHeading heading = pbh.getHeading(); const double h = heading.value(CAngleUnit::deg()); @@ -233,7 +232,7 @@ namespace BlackMiscTest for (int i = 0; i < steps; i++) { - timeFraction = tfStep * i; + double timeFraction = tfStep * i; pbh.setTimeFraction(timeFraction); const CHeading heading = pbh.getHeading(); const double h = CAngle::normalizeDegrees360(heading.value(CAngleUnit::deg())); @@ -253,7 +252,7 @@ namespace BlackMiscTest for (int i = 0; i < steps; i++) { - timeFraction = tfStep * i; + double timeFraction = tfStep * i; pbh.setTimeFraction(timeFraction); const CAngle bank = pbh.getBank(); const double b = bank.value(CAngleUnit::deg()); @@ -271,7 +270,7 @@ namespace BlackMiscTest for (int i = 0; i < steps; i++) { - timeFraction = tfStep * i; + double timeFraction = tfStep * i; pbh.setTimeFraction(timeFraction); const CAngle bank = pbh.getBank(); const double b = CAngle::normalizeDegrees360(bank.value(CAngleUnit::deg())); @@ -291,7 +290,7 @@ namespace BlackMiscTest for (int i = 0; i < steps; i++) { - timeFraction = tfStep * i; + double timeFraction = tfStep * i; pbh.setTimeFraction(timeFraction); const CAngle pitch = pbh.getPitch(); const double p = pitch.value(CAngleUnit::deg()); @@ -311,7 +310,7 @@ namespace BlackMiscTest for (int i = 0; i < steps; i++) { - timeFraction = tfStep * i; + double timeFraction = tfStep * i; pbh.setTimeFraction(timeFraction); const CAngle pitch = pbh.getPitch(); const double p = pitch.value(CAngleUnit::deg()); diff --git a/tests/blackmisc/testcontainers/testcontainers.cpp b/tests/blackmisc/testcontainers/testcontainers.cpp index 4f8e06436..f27256480 100644 --- a/tests/blackmisc/testcontainers/testcontainers.cpp +++ b/tests/blackmisc/testcontainers/testcontainers.cpp @@ -375,7 +375,6 @@ namespace BlackMiscTest qint64 ts = 1000000; int no = 10; const int max = 6; - int dt = 0; for (int i = 0; i < no; ++i) { @@ -386,16 +385,15 @@ namespace BlackMiscTest if (CMathUtils::randomBool()) { - dt = CMathUtils::randomInteger(4500, 5500); + ts += CMathUtils::randomInteger(4500, 5500); s.setTimeOffsetMs(6000); } else { - dt = CMathUtils::randomInteger(900, 1100); + ts += CMathUtils::randomInteger(900, 1100); s.setTimeOffsetMs(2000); } - ts += dt; situations.push_frontKeepLatestFirstAdjustOffset(s, true, max); QVERIFY2(situations.size() <= max, "Wrong size");