do not pass POD types by reference (based on clazy `function-args-by-value` check) (#5388)

This commit is contained in:
Oliver Stöneberg 2023-09-11 20:40:39 +02:00 committed by GitHub
parent e7dd490fed
commit 02b836baad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 32 additions and 30 deletions

View File

@ -32,16 +32,17 @@ CodeEditorStyle::CodeEditorStyle(
// cppcheck-suppress naming-varname - TODO: fix this // cppcheck-suppress naming-varname - TODO: fix this
QColor LnNumFGColor, QColor LnNumBGColor, QColor LnNumFGColor, QColor LnNumBGColor,
// cppcheck-suppress naming-varname - TODO: fix this // cppcheck-suppress naming-varname - TODO: fix this
QColor KeyWdFGColor, const QFont::Weight& KeyWdWeight, QColor KeyWdFGColor, QFont::Weight KeyWdWeight,
// cppcheck-suppress naming-varname - TODO: fix this // cppcheck-suppress naming-varname - TODO: fix this
QColor ClsFGColor, const QFont::Weight& ClsWeight, QColor ClsFGColor, QFont::Weight ClsWeight,
// cppcheck-suppress naming-varname - TODO: fix this // cppcheck-suppress naming-varname - TODO: fix this
QColor QteFGColor, const QFont::Weight& QteWeight, QColor QteFGColor, QFont::Weight QteWeight,
// cppcheck-suppress naming-varname - TODO: fix this // cppcheck-suppress naming-varname - TODO: fix this
QColor CmtFGColor, const QFont::Weight& CmtWeight, QColor CmtFGColor, QFont::Weight CmtWeight,
// cppcheck-suppress naming-varname - TODO: fix this // cppcheck-suppress naming-varname - TODO: fix this
QColor SymbFGColor, QColor SymbBGColor, QColor SymbFGColor, QColor SymbBGColor,
const QFont::Weight& SymbWeight) : // cppcheck-suppress naming-varname - TODO: fix this
QFont::Weight SymbWeight) :
widgetFGColor(std::move(CtrlFGColor)), widgetFGColor(std::move(CtrlFGColor)),
widgetBGColor(std::move(CtrlBGColor)), widgetBGColor(std::move(CtrlBGColor)),
highlightBGColor(std::move(HiLiBGColor)), highlightBGColor(std::move(HiLiBGColor)),

View File

@ -58,16 +58,17 @@ public:
// cppcheck-suppress naming-varname - TODO: fix this // cppcheck-suppress naming-varname - TODO: fix this
QColor LnNumFGColor, QColor LnNumBGColor, QColor LnNumFGColor, QColor LnNumBGColor,
// cppcheck-suppress naming-varname - TODO: fix this // cppcheck-suppress naming-varname - TODO: fix this
QColor KeyWdFGColor, const QFont::Weight& KeyWdWeight, QColor KeyWdFGColor, QFont::Weight KeyWdWeight,
// cppcheck-suppress naming-varname - TODO: fix this // cppcheck-suppress naming-varname - TODO: fix this
QColor ClsFGColor, const QFont::Weight& ClsWeight, QColor ClsFGColor, QFont::Weight ClsWeight,
// cppcheck-suppress naming-varname - TODO: fix this // cppcheck-suppress naming-varname - TODO: fix this
QColor QteFGColor, const QFont::Weight& QteWeight, QColor QteFGColor, QFont::Weight QteWeight,
// cppcheck-suppress naming-varname - TODO: fix this // cppcheck-suppress naming-varname - TODO: fix this
QColor CmtFGColor, const QFont::Weight& CmtWeight, QColor CmtFGColor, QFont::Weight CmtWeight,
// cppcheck-suppress naming-varname - TODO: fix this // cppcheck-suppress naming-varname - TODO: fix this
QColor SymbFGColor, QColor SymbBGColor, QColor SymbFGColor, QColor SymbBGColor,
const QFont::Weight& SymbWeight); // cppcheck-suppress naming-varname - TODO: fix this
QFont::Weight SymbWeight);
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

@ -113,7 +113,7 @@ void SelectFontWeightCombo::changeWeight(int index)
} }
} }
void SelectFontWeightCombo::setWeight(const QFont::Weight& weight) void SelectFontWeightCombo::setWeight(QFont::Weight weight)
{ {
mWeight = weight; mWeight = weight;
updateWeight(); updateWeight();

View File

@ -57,12 +57,12 @@ class SelectFontWeightCombo : public QComboBox {
public: public:
explicit SelectFontWeightCombo(QWidget* parent); explicit SelectFontWeightCombo(QWidget* parent);
void setWeight(const QFont::Weight& weight); void setWeight(QFont::Weight weight);
const QFont::Weight& getWeight(); const QFont::Weight& getWeight();
signals: signals:
// NOLINTNEXTLINE(readability-inconsistent-declaration-parameter-name) - caused by generated MOC code // NOLINTNEXTLINE(readability-inconsistent-declaration-parameter-name) - caused by generated MOC code
void weightChanged(const QFont::Weight& newWeight); void weightChanged(QFont::Weight newWeight);
public slots: public slots:
void updateWeight(); void updateWeight();

View File

@ -296,7 +296,7 @@ void StyleEditDialog::colorChangedKeywordFG(const QColor& newColor)
updateStyle(); updateStyle();
} }
void StyleEditDialog::weightChangedKeyword(const QFont::Weight& newWeight) void StyleEditDialog::weightChangedKeyword(QFont::Weight newWeight)
{ {
mStyleOutgoing.keywordWeight = newWeight; mStyleOutgoing.keywordWeight = newWeight;
updateStyle(); updateStyle();
@ -308,7 +308,7 @@ void StyleEditDialog::colorChangedClassFG(const QColor& newColor)
updateStyle(); updateStyle();
} }
void StyleEditDialog::weightChangedClass(const QFont::Weight& newWeight) void StyleEditDialog::weightChangedClass(QFont::Weight newWeight)
{ {
mStyleOutgoing.classWeight = newWeight; mStyleOutgoing.classWeight = newWeight;
updateStyle(); updateStyle();
@ -320,7 +320,7 @@ void StyleEditDialog::colorChangedQuoteFG(const QColor& newColor)
updateStyle(); updateStyle();
} }
void StyleEditDialog::weightChangedQuote(const QFont::Weight& newWeight) void StyleEditDialog::weightChangedQuote(QFont::Weight newWeight)
{ {
mStyleOutgoing.quoteWeight = newWeight; mStyleOutgoing.quoteWeight = newWeight;
updateStyle(); updateStyle();
@ -332,7 +332,7 @@ void StyleEditDialog::colorChangedCommentFG(const QColor& newColor)
updateStyle(); updateStyle();
} }
void StyleEditDialog::weightChangedComment(const QFont::Weight& newWeight) void StyleEditDialog::weightChangedComment(QFont::Weight newWeight)
{ {
mStyleOutgoing.commentWeight = newWeight; mStyleOutgoing.commentWeight = newWeight;
updateStyle(); updateStyle();
@ -350,7 +350,7 @@ void StyleEditDialog::colorChangedSymbolBG(const QColor& newColor)
updateStyle(); updateStyle();
} }
void StyleEditDialog::weightChangedSymbol(const QFont::Weight& newWeight) void StyleEditDialog::weightChangedSymbol(QFont::Weight newWeight)
{ {
mStyleOutgoing.symbolWeight = newWeight; mStyleOutgoing.symbolWeight = newWeight;
updateStyle(); updateStyle();

View File

@ -59,16 +59,16 @@ public slots:
void colorChangedLineNumFG(const QColor& newColor); void colorChangedLineNumFG(const QColor& newColor);
void colorChangedLineNumBG(const QColor& newColor); void colorChangedLineNumBG(const QColor& newColor);
void colorChangedKeywordFG(const QColor& newColor); void colorChangedKeywordFG(const QColor& newColor);
void weightChangedKeyword(const QFont::Weight& newWeight); void weightChangedKeyword(QFont::Weight newWeight);
void colorChangedClassFG(const QColor& newColor); void colorChangedClassFG(const QColor& newColor);
void weightChangedClass(const QFont::Weight& newWeight); void weightChangedClass(QFont::Weight newWeight);
void colorChangedQuoteFG(const QColor& newColor); void colorChangedQuoteFG(const QColor& newColor);
void weightChangedQuote(const QFont::Weight& newWeight); void weightChangedQuote(QFont::Weight newWeight);
void colorChangedCommentFG(const QColor& newColor); void colorChangedCommentFG(const QColor& newColor);
void weightChangedComment(const QFont::Weight& newWeight); void weightChangedComment(QFont::Weight newWeight);
void colorChangedSymbolFG(const QColor& newColor); void colorChangedSymbolFG(const QColor& newColor);
void colorChangedSymbolBG(const QColor& newColor); void colorChangedSymbolBG(const QColor& newColor);
void weightChangedSymbol(const QFont::Weight& newWeight); void weightChangedSymbol(QFont::Weight newWeight);
private: private:
CodeEditorStyle mStyleIncoming; CodeEditorStyle mStyleIncoming;

View File

@ -65,7 +65,7 @@ static const struct CWE CWE825(825U); // Expired Pointer Dereference
static const struct CWE CWE833(833U); // Deadlock static const struct CWE CWE833(833U); // Deadlock
static const struct CWE CWE834(834U); // Excessive Iteration static const struct CWE CWE834(834U); // Excessive Iteration
static bool isElementAccessYield(const Library::Container::Yield& yield) static bool isElementAccessYield(Library::Container::Yield yield)
{ {
return contains({Library::Container::Yield::ITEM, Library::Container::Yield::AT_INDEX}, yield); return contains({Library::Container::Yield::ITEM, Library::Container::Yield::AT_INDEX}, yield);
} }

View File

@ -40,7 +40,7 @@ static bool isStreamATty(const std::ostream & os)
} }
#endif #endif
std::ostream& operator<<(std::ostream & os, const Color& c) std::ostream& operator<<(std::ostream & os, Color c)
{ {
#ifndef _WIN32 #ifndef _WIN32
if (!gDisableColors && isStreamATty(os)) if (!gDisableColors && isStreamATty(os))
@ -51,7 +51,7 @@ std::ostream& operator<<(std::ostream & os, const Color& c)
return os; return os;
} }
std::string toString(const Color& c) std::string toString(Color c)
{ {
#ifndef _WIN32 #ifndef _WIN32
std::stringstream ss; std::stringstream ss;

View File

@ -34,9 +34,9 @@ enum class Color {
FgMagenta = 35, FgMagenta = 35,
FgDefault = 39 FgDefault = 39
}; };
CPPCHECKLIB std::ostream& operator<<(std::ostream& os, const Color& c); CPPCHECKLIB std::ostream& operator<<(std::ostream& os, Color c);
CPPCHECKLIB std::string toString(const Color& c); CPPCHECKLIB std::string toString(Color c);
extern CPPCHECKLIB bool gDisableColors; // for testing extern CPPCHECKLIB bool gDisableColors; // for testing

View File

@ -3662,7 +3662,7 @@ static std::ostream & operator << (std::ostream & s, Scope::ScopeType type)
return s; return s;
} }
static std::string accessControlToString(const AccessControl& access) static std::string accessControlToString(AccessControl access)
{ {
switch (access) { switch (access) {
case AccessControl::Public: case AccessControl::Public:

View File

@ -7965,7 +7965,7 @@ void Tokenizer::unhandledCharLiteral(const Token *tok, const std::string& msg) c
* @param floatConstant the string with stringified float constant to check against * @param floatConstant the string with stringified float constant to check against
* @return true in case s is equal to X or X.0 and false otherwise. * @return true in case s is equal to X or X.0 and false otherwise.
*/ */
static bool isNumberOneOf(const std::string &s, const MathLib::bigint& intConstant, const char* floatConstant) static bool isNumberOneOf(const std::string &s, MathLib::bigint intConstant, const char* floatConstant)
{ {
if (MathLib::isInt(s)) { if (MathLib::isInt(s)) {
if (MathLib::toLongNumber(s) == intConstant) if (MathLib::toLongNumber(s) == intConstant)