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`
This commit is contained in:
Scott Furry 2019-06-30 13:43:25 -06:00 committed by Daniel Marjamäki
parent a195477470
commit e459762bcd
9 changed files with 14 additions and 10 deletions

View File

@ -59,7 +59,7 @@ public:
const QColor& CmtFGColor, const QFont::Weight& CmtWeight, const QColor& CmtFGColor, const QFont::Weight& CmtWeight,
const QColor& SymbFGColor, const QColor& SymbBGColor, const QColor& SymbFGColor, const QColor& SymbBGColor,
const QFont::Weight& SymbWeight); const QFont::Weight& SymbWeight);
~CodeEditorStyle() {}; ~CodeEditorStyle() {}
bool operator==(const CodeEditorStyle& rhs) const; bool operator==(const CodeEditorStyle& rhs) const;
bool operator!=(const CodeEditorStyle& rhs) const; bool operator!=(const CodeEditorStyle& rhs) const;

View File

@ -31,7 +31,7 @@ class SelectColorButton : public QPushButton {
Q_OBJECT Q_OBJECT
public: public:
explicit SelectColorButton(QWidget* parent); explicit SelectColorButton(QWidget* parent);
virtual ~SelectColorButton() {}; virtual ~SelectColorButton() {}
void setColor(const QColor& color); void setColor(const QColor& color);
const QColor& getColor(); const QColor& getColor();
@ -68,4 +68,5 @@ private:
QFont::Weight mWeight; QFont::Weight mWeight;
}; };
#endif //CODEEDITORSTYLECONTROLS_H #endif //CODEEDITORSTYLECONTROLS_H

View File

@ -30,7 +30,7 @@ class StyleEditDialog : public QDialog {
public: public:
explicit StyleEditDialog(const CodeEditorStyle& newStyle, explicit StyleEditDialog(const CodeEditorStyle& newStyle,
QWidget *parent = nullptr); QWidget *parent = nullptr);
virtual ~StyleEditDialog() {}; virtual ~StyleEditDialog() {}
CodeEditorStyle getStyle(); CodeEditorStyle getStyle();
@ -90,4 +90,5 @@ private:
static const int mErrLineNum; static const int mErrLineNum;
}; };
#endif //CODEEDITSTYLEDIALOG_H #endif //CODEEDITSTYLEDIALOG_H

View File

@ -365,4 +365,5 @@ void SettingsDialog::manageStyleControls()
mUI.choiceDark->setChecked(!isDefaultLight && isDefaultDark); mUI.choiceDark->setChecked(!isDefaultLight && isDefaultDark);
mUI.choiceCustom->setChecked(!isDefaultLight && !isDefaultDark); mUI.choiceCustom->setChecked(!isDefaultLight && !isDefaultDark);
mUI.btnEditCustom->setEnabled(!isDefaultLight && !isDefaultDark); mUI.btnEditCustom->setEnabled(!isDefaultLight && !isDefaultDark);
} }

View File

@ -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" // 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() static void unused()
{ {
// NOTE: Keeping semi-colons at end of macro for style preference
#if ((QT_VERSION >= 0x040000)&&(QT_VERSION < 0x050000)) #if ((QT_VERSION >= 0x040000)&&(QT_VERSION < 0x050000))
Q_UNUSED(QT_TRANSLATE_NOOP("QDialogButtonBox", "OK")); Q_UNUSED(QT_TRANSLATE_NOOP("QDialogButtonBox", "OK"));
Q_UNUSED(QT_TRANSLATE_NOOP("QDialogButtonBox", "Cancel")); Q_UNUSED(QT_TRANSLATE_NOOP("QDialogButtonBox", "Cancel"));

View File

@ -138,7 +138,7 @@ public:
return "information"; return "information";
case debug: case debug:
return "debug"; return "debug";
}; }
throw InternalError(nullptr, "Unknown severity"); throw InternalError(nullptr, "Unknown severity");
} }
static SeverityType fromString(const std::string &severity) { static SeverityType fromString(const std::string &severity) {

View File

@ -976,7 +976,7 @@ public:
const auto it = std::find_if(mImpl->mValues->begin(), mImpl->mValues->end(), [=](const ValueFlow::Value &value) { const auto it = std::find_if(mImpl->mValues->begin(), mImpl->mValues->end(), [=](const ValueFlow::Value &value) {
return value.isContainerSizeValue() && value.intvalue == val; return value.isContainerSizeValue() && value.intvalue == val;
}); });
return it == mImpl->mValues->end() ? nullptr : &*it;; return it == mImpl->mValues->end() ? nullptr : &*it;
} }
const Token *getValueTokenMaxStrLength() const; const Token *getValueTokenMaxStrLength() const;

View File

@ -91,7 +91,7 @@ namespace ValueFlow {
case LIFETIME: case LIFETIME:
if (tokvalue != rhs.tokvalue) if (tokvalue != rhs.tokvalue)
return false; return false;
}; }
return varvalue == rhs.varvalue && return varvalue == rhs.varvalue &&
condition == rhs.condition && condition == rhs.condition &&

View File

@ -103,7 +103,7 @@ void MainWindow::filter(QString filter)
{ {
QStringList allErrors; QStringList allErrors;
for (const QString errorItem : mAllErrors) { for (const QString &errorItem : mAllErrors) {
if (filter.isEmpty()) { if (filter.isEmpty()) {
allErrors << errorItem; allErrors << errorItem;
continue; continue;