From e459762bcdc49245e22b71b574744060baabb06c Mon Sep 17 00:00:00 2001 From: Scott Furry Date: Sun, 30 Jun 2019 13:43:25 -0600 Subject: [PATCH] Suppress Code semantic and syntax warnings (#1936) Sources were built with Clang but with increased verbosity of error detection. A number of syntax and semantic warnings were encountered. Commit adds changes to correct these warnings. Some changes involve removing extra, and unncessary, semi-colons at EOL (e.g. at end of switch clause). Project astyle settings are not currently setup to detect if a file is to have an extra carriage return after the last line of data. Two files were altered to ensure an extra carriage return. An advisory to enhance code was encountered in triage code. Clang advisory on a for-loop interation value suggested that: `use reference type 'const QString &' to prevent copying` --- gui/codeeditorstyle.h | 2 +- gui/codeeditstylecontrols.h | 5 +++-- gui/codeeditstyledialog.h | 5 +++-- gui/settingsdialog.cpp | 3 ++- gui/translationhandler.cpp | 1 + lib/errorlogger.h | 2 +- lib/token.h | 2 +- lib/valueflow.h | 2 +- tools/triage/mainwindow.cpp | 2 +- 9 files changed, 14 insertions(+), 10 deletions(-) diff --git a/gui/codeeditorstyle.h b/gui/codeeditorstyle.h index 8288af033..d9e1d4761 100644 --- a/gui/codeeditorstyle.h +++ b/gui/codeeditorstyle.h @@ -59,7 +59,7 @@ public: const QColor& CmtFGColor, const QFont::Weight& CmtWeight, const QColor& SymbFGColor, const QColor& SymbBGColor, const QFont::Weight& SymbWeight); - ~CodeEditorStyle() {}; + ~CodeEditorStyle() {} bool operator==(const CodeEditorStyle& rhs) const; bool operator!=(const CodeEditorStyle& rhs) const; diff --git a/gui/codeeditstylecontrols.h b/gui/codeeditstylecontrols.h index 38f76dd65..e91ea168d 100644 --- a/gui/codeeditstylecontrols.h +++ b/gui/codeeditstylecontrols.h @@ -31,7 +31,7 @@ class SelectColorButton : public QPushButton { Q_OBJECT public: explicit SelectColorButton(QWidget* parent); - virtual ~SelectColorButton() {}; + virtual ~SelectColorButton() {} void setColor(const QColor& color); const QColor& getColor(); @@ -68,4 +68,5 @@ private: QFont::Weight mWeight; }; -#endif //CODEEDITORSTYLECONTROLS_H \ No newline at end of file +#endif //CODEEDITORSTYLECONTROLS_H + diff --git a/gui/codeeditstyledialog.h b/gui/codeeditstyledialog.h index 2e2c9c9ee..a9c6066d3 100644 --- a/gui/codeeditstyledialog.h +++ b/gui/codeeditstyledialog.h @@ -30,7 +30,7 @@ class StyleEditDialog : public QDialog { public: explicit StyleEditDialog(const CodeEditorStyle& newStyle, QWidget *parent = nullptr); - virtual ~StyleEditDialog() {}; + virtual ~StyleEditDialog() {} CodeEditorStyle getStyle(); @@ -90,4 +90,5 @@ private: static const int mErrLineNum; }; -#endif //CODEEDITSTYLEDIALOG_H \ No newline at end of file +#endif //CODEEDITSTYLEDIALOG_H + diff --git a/gui/settingsdialog.cpp b/gui/settingsdialog.cpp index fc4ed23c3..3707bcaef 100644 --- a/gui/settingsdialog.cpp +++ b/gui/settingsdialog.cpp @@ -365,4 +365,5 @@ void SettingsDialog::manageStyleControls() mUI.choiceDark->setChecked(!isDefaultLight && isDefaultDark); mUI.choiceCustom->setChecked(!isDefaultLight && !isDefaultDark); mUI.btnEditCustom->setEnabled(!isDefaultLight && !isDefaultDark); -} \ No newline at end of file +} + diff --git a/gui/translationhandler.cpp b/gui/translationhandler.cpp index 4c8eb6609..0f17dcd68 100644 --- a/gui/translationhandler.cpp +++ b/gui/translationhandler.cpp @@ -29,6 +29,7 @@ // Provide own translations for standard buttons. This (garbage) code is needed to enforce them to appear in .ts files even after "lupdate gui.pro" static void unused() { +// NOTE: Keeping semi-colons at end of macro for style preference #if ((QT_VERSION >= 0x040000)&&(QT_VERSION < 0x050000)) Q_UNUSED(QT_TRANSLATE_NOOP("QDialogButtonBox", "OK")); Q_UNUSED(QT_TRANSLATE_NOOP("QDialogButtonBox", "Cancel")); diff --git a/lib/errorlogger.h b/lib/errorlogger.h index d14e58c5e..9304da47c 100644 --- a/lib/errorlogger.h +++ b/lib/errorlogger.h @@ -138,7 +138,7 @@ public: return "information"; case debug: return "debug"; - }; + } throw InternalError(nullptr, "Unknown severity"); } static SeverityType fromString(const std::string &severity) { diff --git a/lib/token.h b/lib/token.h index ef290dcb8..626c43e1f 100644 --- a/lib/token.h +++ b/lib/token.h @@ -976,7 +976,7 @@ public: const auto it = std::find_if(mImpl->mValues->begin(), mImpl->mValues->end(), [=](const ValueFlow::Value &value) { return value.isContainerSizeValue() && value.intvalue == val; }); - return it == mImpl->mValues->end() ? nullptr : &*it;; + return it == mImpl->mValues->end() ? nullptr : &*it; } const Token *getValueTokenMaxStrLength() const; diff --git a/lib/valueflow.h b/lib/valueflow.h index 062c94d4c..93b040ca8 100644 --- a/lib/valueflow.h +++ b/lib/valueflow.h @@ -91,7 +91,7 @@ namespace ValueFlow { case LIFETIME: if (tokvalue != rhs.tokvalue) return false; - }; + } return varvalue == rhs.varvalue && condition == rhs.condition && diff --git a/tools/triage/mainwindow.cpp b/tools/triage/mainwindow.cpp index 9a4fc94c4..944a274ce 100644 --- a/tools/triage/mainwindow.cpp +++ b/tools/triage/mainwindow.cpp @@ -103,7 +103,7 @@ void MainWindow::filter(QString filter) { QStringList allErrors; - for (const QString errorItem : mAllErrors) { + for (const QString &errorItem : mAllErrors) { if (filter.isEmpty()) { allErrors << errorItem; continue;