From 09a3c32d0c5f2ff014d961060d4b6eecb79bce7d Mon Sep 17 00:00:00 2001 From: Evgeniy Alekseev Date: Wed, 17 May 2023 18:55:16 +0300 Subject: [PATCH] fix some found warning --- sources/.clang-format | 4 ++-- sources/awesome-widget/plugin/awabstractpairhelper.cpp | 2 +- sources/awesome-widget/plugin/awbugreporter.h | 2 +- sources/awesome-widget/plugin/awcustomkeyshelper.cpp | 2 +- .../awesome-widget/plugin/awdataengineaggregator.cpp | 1 - sources/awesome-widget/plugin/awdbusadaptor.cpp | 2 +- sources/awesome-widget/plugin/awdbusadaptor.h | 10 +++++----- sources/awesome-widget/plugin/awformatterhelper.cpp | 2 +- sources/awesome-widget/plugin/awkeyoperations.cpp | 1 - sources/awesome-widget/plugin/awkeys.h | 2 +- sources/awesomewidgets/abstractextitem.h | 2 +- sources/awesomewidgets/abstractextitemaggregator.h | 2 +- sources/awesomewidgets/abstractweatherprovider.h | 2 +- sources/awesomewidgets/awabstractformatter.h | 2 +- sources/awesomewidgets/extupgrade.cpp | 1 - sources/awesomewidgets/graphicalitem.cpp | 8 ++++---- sources/awesomewidgets/graphicalitem.h | 2 +- sources/awesomewidgets/qcronscheduler.cpp | 2 +- sources/awesomewidgets/yahooweatherprovider.cpp | 2 +- sources/changelog.cmake | 7 ++++--- sources/checkgit.cmake | 10 +++++----- sources/extsysmonsources/desktopsource.cpp | 2 +- sources/test/testjsonformatter.h | 2 +- 23 files changed, 35 insertions(+), 37 deletions(-) diff --git a/sources/.clang-format b/sources/.clang-format index 5c60523..e6adf16 100644 --- a/sources/.clang-format +++ b/sources/.clang-format @@ -2,11 +2,11 @@ Language: Cpp AccessModifierOffset: -4 AlignAfterOpenBracket: Align -AlignConsecutiveAssignments: false +AlignConsecutiveAssignments: None AlignOperands: true AlignTrailingComments: true AllowAllParametersOfDeclarationOnNextLine: true -AllowShortBlocksOnASingleLine: false +AllowShortBlocksOnASingleLine: Never AllowShortCaseLabelsOnASingleLine: false AllowShortFunctionsOnASingleLine: Inline AllowShortIfStatementsOnASingleLine: Never diff --git a/sources/awesome-widget/plugin/awabstractpairhelper.cpp b/sources/awesome-widget/plugin/awabstractpairhelper.cpp index a111030..26be8f4 100644 --- a/sources/awesome-widget/plugin/awabstractpairhelper.cpp +++ b/sources/awesome-widget/plugin/awabstractpairhelper.cpp @@ -61,7 +61,7 @@ QStringList AWAbstractPairHelper::values() const QSet AWAbstractPairHelper::valuesSet() const { auto values = m_pairs.values(); - return QSet(values.cbegin(), values.cend()); + return {values.cbegin(), values.cend()}; } diff --git a/sources/awesome-widget/plugin/awbugreporter.h b/sources/awesome-widget/plugin/awbugreporter.h index fa89fde..39e9c97 100644 --- a/sources/awesome-widget/plugin/awbugreporter.h +++ b/sources/awesome-widget/plugin/awbugreporter.h @@ -38,7 +38,7 @@ public: Q_INVOKABLE void sendBugReport(const QString &_title, const QString &_body); signals: - void replyReceived(const int _number, const QString &_url); + void replyReceived(int _number, const QString &_url); private slots: void issueReplyRecieved(QNetworkReply *_reply); diff --git a/sources/awesome-widget/plugin/awcustomkeyshelper.cpp b/sources/awesome-widget/plugin/awcustomkeyshelper.cpp index 0be9c4d..04ed21f 100644 --- a/sources/awesome-widget/plugin/awcustomkeyshelper.cpp +++ b/sources/awesome-widget/plugin/awcustomkeyshelper.cpp @@ -74,5 +74,5 @@ QStringList AWCustomKeysHelper::leftKeys() QStringList AWCustomKeysHelper::rightKeys() { - return QStringList(); + return {}; } diff --git a/sources/awesome-widget/plugin/awdataengineaggregator.cpp b/sources/awesome-widget/plugin/awdataengineaggregator.cpp index 1d46774..431c20d 100644 --- a/sources/awesome-widget/plugin/awdataengineaggregator.cpp +++ b/sources/awesome-widget/plugin/awdataengineaggregator.cpp @@ -20,7 +20,6 @@ #include #include "awdebug.h" -#include "awkeys.h" AWDataEngineAggregator::AWDataEngineAggregator(QObject *_parent) diff --git a/sources/awesome-widget/plugin/awdbusadaptor.cpp b/sources/awesome-widget/plugin/awdbusadaptor.cpp index 362f48c..0e294af 100644 --- a/sources/awesome-widget/plugin/awdbusadaptor.cpp +++ b/sources/awesome-widget/plugin/awdbusadaptor.cpp @@ -38,7 +38,7 @@ AWDBusAdaptor::~AWDBusAdaptor() } -QStringList AWDBusAdaptor::ActiveServices() const +QStringList AWDBusAdaptor::ActiveServices() { QDBusMessage listServices = QDBusConnection::sessionBus().interface()->call(QDBus::BlockWithGui, "ListNames"); if (listServices.arguments().isEmpty()) { diff --git a/sources/awesome-widget/plugin/awdbusadaptor.h b/sources/awesome-widget/plugin/awdbusadaptor.h index 464451e..5495a34 100644 --- a/sources/awesome-widget/plugin/awdbusadaptor.h +++ b/sources/awesome-widget/plugin/awdbusadaptor.h @@ -37,11 +37,11 @@ public: public slots: // get methods - QStringList ActiveServices() const; - QString Info(const QString &key) const; - QStringList Keys(const QString ®exp) const; - QString Value(const QString &key) const; - qlonglong WhoAmI() const; + [[nodiscard]] static QStringList ActiveServices(); + [[nodiscard]] QString Info(const QString &key) const; + [[nodiscard]] QStringList Keys(const QString ®exp) const; + [[nodiscard]] QString Value(const QString &key) const; + [[nodiscard]] qlonglong WhoAmI() const; // set methods void SetLogLevel(const QString &what, int level); void SetLogLevel(const QString &what, const QString &level, bool enabled); diff --git a/sources/awesome-widget/plugin/awformatterhelper.cpp b/sources/awesome-widget/plugin/awformatterhelper.cpp index 29a7a94..b857673 100644 --- a/sources/awesome-widget/plugin/awformatterhelper.cpp +++ b/sources/awesome-widget/plugin/awformatterhelper.cpp @@ -102,7 +102,7 @@ void AWFormatterHelper::editPairs() QStringList AWFormatterHelper::leftKeys() { - return QStringList(); + return {}; } diff --git a/sources/awesome-widget/plugin/awkeyoperations.cpp b/sources/awesome-widget/plugin/awkeyoperations.cpp index 21880cb..b7ec39a 100644 --- a/sources/awesome-widget/plugin/awkeyoperations.cpp +++ b/sources/awesome-widget/plugin/awkeyoperations.cpp @@ -18,7 +18,6 @@ #include "awkeyoperations.h" #include -#include #include #include diff --git a/sources/awesome-widget/plugin/awkeys.h b/sources/awesome-widget/plugin/awkeys.h index 747dd36..8ebf222 100644 --- a/sources/awesome-widget/plugin/awkeys.h +++ b/sources/awesome-widget/plugin/awkeys.h @@ -58,7 +58,7 @@ public: public slots: void dataUpdated(const QString &_sourceName, const Plasma::DataEngine::Data &_data); // dummy method required by DataEngine connections - static void modelChanged(QString, QAbstractItemModel *){}; + static void modelChanged(const QString &, QAbstractItemModel *){}; signals: void dropSourceFromDataengine(const QString &_source); diff --git a/sources/awesomewidgets/abstractextitem.h b/sources/awesomewidgets/abstractextitem.h index e01fe25..91fe620 100644 --- a/sources/awesomewidgets/abstractextitem.h +++ b/sources/awesomewidgets/abstractextitem.h @@ -79,7 +79,7 @@ public slots: virtual void readConfiguration(); virtual QVariantHash run() = 0; virtual int showConfiguration(const QVariant &_args) = 0; - virtual bool tryDelete() const; + [[nodiscard]] virtual bool tryDelete() const; virtual void writeConfiguration() const; private slots: diff --git a/sources/awesomewidgets/abstractextitemaggregator.h b/sources/awesomewidgets/abstractextitemaggregator.h index e65e08b..7c767b8 100644 --- a/sources/awesomewidgets/abstractextitemaggregator.h +++ b/sources/awesomewidgets/abstractextitemaggregator.h @@ -67,7 +67,7 @@ public: void editItem(); QString getName(); virtual void initItems() = 0; - AbstractExtItem *itemFromWidget() const; + [[nodiscard]] AbstractExtItem *itemFromWidget() const; void repaintList() const; [[nodiscard]] int uniqNumber() const; // get methods diff --git a/sources/awesomewidgets/abstractweatherprovider.h b/sources/awesomewidgets/abstractweatherprovider.h index ac9d96b..f0b9ec1 100644 --- a/sources/awesomewidgets/abstractweatherprovider.h +++ b/sources/awesomewidgets/abstractweatherprovider.h @@ -38,7 +38,7 @@ public: { return dynamic_cast(parent())->tag(_type); }; - virtual QUrl url() const = 0; + [[nodiscard]] virtual QUrl url() const = 0; }; diff --git a/sources/awesomewidgets/awabstractformatter.h b/sources/awesomewidgets/awabstractformatter.h index 214acec..4da1bfc 100644 --- a/sources/awesomewidgets/awabstractformatter.h +++ b/sources/awesomewidgets/awabstractformatter.h @@ -43,7 +43,7 @@ public: public slots: void readConfiguration() override; - QVariantHash run() override { return QVariantHash(); }; + QVariantHash run() override { return {}; }; void writeConfiguration() const override; private: diff --git a/sources/awesomewidgets/extupgrade.cpp b/sources/awesomewidgets/extupgrade.cpp index 05b20ac..433ec14 100644 --- a/sources/awesomewidgets/extupgrade.cpp +++ b/sources/awesomewidgets/extupgrade.cpp @@ -20,7 +20,6 @@ #include -#include #include #include diff --git a/sources/awesomewidgets/graphicalitem.cpp b/sources/awesomewidgets/graphicalitem.cpp index 22bba1f..fa87f05 100644 --- a/sources/awesomewidgets/graphicalitem.cpp +++ b/sources/awesomewidgets/graphicalitem.cpp @@ -100,7 +100,7 @@ QString GraphicalItem::image(const QVariant &value) m_scene->clear(); int scale[2] = {1, 1}; - float converted = m_helper->getPercents(value.toFloat(), minValue(), maxValue()); + float converted = GraphicalItemHelper::getPercents(value.toFloat(), minValue(), maxValue()); // paint switch (m_type) { @@ -457,12 +457,12 @@ int GraphicalItem::showConfiguration(const QVariant &_args) ui->doubleSpinBox_max->setValue(maxValue()); ui->doubleSpinBox_min->setValue(minValue()); ui->spinBox_count->setValue(count()); - if (m_helper->isColor(activeColor())) + if (GraphicalItemHelper::isColor(activeColor())) ui->comboBox_activeImageType->setCurrentIndex(0); else ui->comboBox_activeImageType->setCurrentIndex(1); ui->lineEdit_activeColor->setText(activeColor()); - if (m_helper->isColor(inactiveColor())) + if (GraphicalItemHelper::isColor(inactiveColor())) ui->comboBox_inactiveImageType->setCurrentIndex(0); else ui->comboBox_inactiveImageType->setCurrentIndex(1); @@ -539,7 +539,7 @@ void GraphicalItem::changeColor() QString outputColor; if (state == 0) { - QColor color = m_helper->stringToColor(lineEdit->text()); + QColor color = GraphicalItemHelper::stringToColor(lineEdit->text()); QColor newColor = QColorDialog::getColor(color, this, i18n("Select color"), QColorDialog::ShowAlphaChannel); if (!newColor.isValid()) return; diff --git a/sources/awesomewidgets/graphicalitem.h b/sources/awesomewidgets/graphicalitem.h index b7409b1..f9d6492 100644 --- a/sources/awesomewidgets/graphicalitem.h +++ b/sources/awesomewidgets/graphicalitem.h @@ -91,7 +91,7 @@ public: public slots: void readConfiguration() override; - QVariantHash run() override { return QVariantHash(); }; + QVariantHash run() override { return {}; }; int showConfiguration(const QVariant &_args) override; void writeConfiguration() const override; diff --git a/sources/awesomewidgets/qcronscheduler.cpp b/sources/awesomewidgets/qcronscheduler.cpp index c85adee..8e778aa 100644 --- a/sources/awesomewidgets/qcronscheduler.cpp +++ b/sources/awesomewidgets/qcronscheduler.cpp @@ -135,7 +135,7 @@ QList QCronScheduler::QCronField::toList() { // error checking if ((minValue == -1) || (maxValue == -1)) - return QList(); + return {}; QList output; for (auto &i = minValue; i <= maxValue; ++i) { diff --git a/sources/awesomewidgets/yahooweatherprovider.cpp b/sources/awesomewidgets/yahooweatherprovider.cpp index 07a2b5b..7fd52fe 100644 --- a/sources/awesomewidgets/yahooweatherprovider.cpp +++ b/sources/awesomewidgets/yahooweatherprovider.cpp @@ -57,7 +57,7 @@ QVariantHash YahooWeatherProvider::parse(const QVariantMap &_json) const QVariantMap jsonMap = _json["query"].toMap(); if (jsonMap["count"].toInt() != 1) { qCWarning(LOG_LIB) << "Found data count" << _json["count"].toInt() << "is not 1"; - return QVariantHash(); + return {}; } QVariantMap results = jsonMap["results"].toMap()["channel"].toMap(); QVariantMap item = results["item"].toMap(); diff --git a/sources/changelog.cmake b/sources/changelog.cmake index 134c8bd..49a2b19 100644 --- a/sources/changelog.cmake +++ b/sources/changelog.cmake @@ -1,5 +1,6 @@ -exec_program( - "sed -n '1,/^Ver/ p' CHANGELOG 2> /dev/null | grep -v '^Ver' | tr '\n' '@'" - ${CMAKE_CURRENT_SOURCE_DIR} +execute_process( + COMMAND "sed -n '1,/^Ver/ p' CHANGELOG 2> /dev/null | grep -v '^Ver' | tr '\n' '@'" + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} OUTPUT_VARIABLE PROJECT_CHANGELOG + OUTPUT_STRIP_TRAILING_WHITESPACE ) diff --git a/sources/checkgit.cmake b/sources/checkgit.cmake index a485e5f..94b688e 100644 --- a/sources/checkgit.cmake +++ b/sources/checkgit.cmake @@ -1,9 +1,9 @@ -exec_program( - "git" - ${CMAKE_CURRENT_SOURCE_DIR} - ARGS "log" "-1" "--format=\"%h\"" +execute_process( + COMMAND git log -1 --format=%h + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} OUTPUT_VARIABLE COMMIT_SHA - RETURN_VALUE GIT_RETURN + RESULT_VARIABLE GIT_RETURN + OUTPUT_STRIP_TRAILING_WHITESPACE ) if (${GIT_RETURN} EQUAL "0") diff --git a/sources/extsysmonsources/desktopsource.cpp b/sources/extsysmonsources/desktopsource.cpp index adddf5a..a4dc824 100644 --- a/sources/extsysmonsources/desktopsource.cpp +++ b/sources/extsysmonsources/desktopsource.cpp @@ -59,7 +59,7 @@ QVariant DesktopSource::data(const QString &_source) return m_vdi->numberOfDesktops(); } - return QVariant(); + return {}; } diff --git a/sources/test/testjsonformatter.h b/sources/test/testjsonformatter.h index 12ec8a6..ab9b324 100644 --- a/sources/test/testjsonformatter.h +++ b/sources/test/testjsonformatter.h @@ -47,4 +47,4 @@ private: }; -#endif /* TESTJSONFORMATTER_Hl */ +#endif /* TESTJSONFORMATTER_H */