Skip to content

Commit 02b836b

Browse files
authored
do not pass POD types by reference (based on clazy function-args-by-value check) (#5388)
1 parent e7dd490 commit 02b836b

11 files changed

Lines changed: 32 additions & 30 deletions

gui/codeeditorstyle.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,17 @@ CodeEditorStyle::CodeEditorStyle(
3232
// cppcheck-suppress naming-varname - TODO: fix this
3333
QColor LnNumFGColor, QColor LnNumBGColor,
3434
// cppcheck-suppress naming-varname - TODO: fix this
35-
QColor KeyWdFGColor, const QFont::Weight& KeyWdWeight,
35+
QColor KeyWdFGColor, QFont::Weight KeyWdWeight,
3636
// cppcheck-suppress naming-varname - TODO: fix this
37-
QColor ClsFGColor, const QFont::Weight& ClsWeight,
37+
QColor ClsFGColor, QFont::Weight ClsWeight,
3838
// cppcheck-suppress naming-varname - TODO: fix this
39-
QColor QteFGColor, const QFont::Weight& QteWeight,
39+
QColor QteFGColor, QFont::Weight QteWeight,
4040
// cppcheck-suppress naming-varname - TODO: fix this
41-
QColor CmtFGColor, const QFont::Weight& CmtWeight,
41+
QColor CmtFGColor, QFont::Weight CmtWeight,
4242
// cppcheck-suppress naming-varname - TODO: fix this
4343
QColor SymbFGColor, QColor SymbBGColor,
44-
const QFont::Weight& SymbWeight) :
44+
// cppcheck-suppress naming-varname - TODO: fix this
45+
QFont::Weight SymbWeight) :
4546
widgetFGColor(std::move(CtrlFGColor)),
4647
widgetBGColor(std::move(CtrlBGColor)),
4748
highlightBGColor(std::move(HiLiBGColor)),

gui/codeeditorstyle.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,17 @@ class CodeEditorStyle {
5858
// cppcheck-suppress naming-varname - TODO: fix this
5959
QColor LnNumFGColor, QColor LnNumBGColor,
6060
// cppcheck-suppress naming-varname - TODO: fix this
61-
QColor KeyWdFGColor, const QFont::Weight& KeyWdWeight,
61+
QColor KeyWdFGColor, QFont::Weight KeyWdWeight,
6262
// cppcheck-suppress naming-varname - TODO: fix this
63-
QColor ClsFGColor, const QFont::Weight& ClsWeight,
63+
QColor ClsFGColor, QFont::Weight ClsWeight,
6464
// cppcheck-suppress naming-varname - TODO: fix this
65-
QColor QteFGColor, const QFont::Weight& QteWeight,
65+
QColor QteFGColor, QFont::Weight QteWeight,
6666
// cppcheck-suppress naming-varname - TODO: fix this
67-
QColor CmtFGColor, const QFont::Weight& CmtWeight,
67+
QColor CmtFGColor, QFont::Weight CmtWeight,
6868
// cppcheck-suppress naming-varname - TODO: fix this
6969
QColor SymbFGColor, QColor SymbBGColor,
70-
const QFont::Weight& SymbWeight);
70+
// cppcheck-suppress naming-varname - TODO: fix this
71+
QFont::Weight SymbWeight);
7172

7273
bool operator==(const CodeEditorStyle& rhs) const;
7374
bool operator!=(const CodeEditorStyle& rhs) const;

gui/codeeditstylecontrols.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ void SelectFontWeightCombo::changeWeight(int index)
113113
}
114114
}
115115

116-
void SelectFontWeightCombo::setWeight(const QFont::Weight& weight)
116+
void SelectFontWeightCombo::setWeight(QFont::Weight weight)
117117
{
118118
mWeight = weight;
119119
updateWeight();

gui/codeeditstylecontrols.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ class SelectFontWeightCombo : public QComboBox {
5757
public:
5858
explicit SelectFontWeightCombo(QWidget* parent);
5959

60-
void setWeight(const QFont::Weight& weight);
60+
void setWeight(QFont::Weight weight);
6161
const QFont::Weight& getWeight();
6262

6363
signals:
6464
// NOLINTNEXTLINE(readability-inconsistent-declaration-parameter-name) - caused by generated MOC code
65-
void weightChanged(const QFont::Weight& newWeight);
65+
void weightChanged(QFont::Weight newWeight);
6666

6767
public slots:
6868
void updateWeight();

gui/codeeditstyledialog.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ void StyleEditDialog::colorChangedKeywordFG(const QColor& newColor)
296296
updateStyle();
297297
}
298298

299-
void StyleEditDialog::weightChangedKeyword(const QFont::Weight& newWeight)
299+
void StyleEditDialog::weightChangedKeyword(QFont::Weight newWeight)
300300
{
301301
mStyleOutgoing.keywordWeight = newWeight;
302302
updateStyle();
@@ -308,7 +308,7 @@ void StyleEditDialog::colorChangedClassFG(const QColor& newColor)
308308
updateStyle();
309309
}
310310

311-
void StyleEditDialog::weightChangedClass(const QFont::Weight& newWeight)
311+
void StyleEditDialog::weightChangedClass(QFont::Weight newWeight)
312312
{
313313
mStyleOutgoing.classWeight = newWeight;
314314
updateStyle();
@@ -320,7 +320,7 @@ void StyleEditDialog::colorChangedQuoteFG(const QColor& newColor)
320320
updateStyle();
321321
}
322322

323-
void StyleEditDialog::weightChangedQuote(const QFont::Weight& newWeight)
323+
void StyleEditDialog::weightChangedQuote(QFont::Weight newWeight)
324324
{
325325
mStyleOutgoing.quoteWeight = newWeight;
326326
updateStyle();
@@ -332,7 +332,7 @@ void StyleEditDialog::colorChangedCommentFG(const QColor& newColor)
332332
updateStyle();
333333
}
334334

335-
void StyleEditDialog::weightChangedComment(const QFont::Weight& newWeight)
335+
void StyleEditDialog::weightChangedComment(QFont::Weight newWeight)
336336
{
337337
mStyleOutgoing.commentWeight = newWeight;
338338
updateStyle();
@@ -350,7 +350,7 @@ void StyleEditDialog::colorChangedSymbolBG(const QColor& newColor)
350350
updateStyle();
351351
}
352352

353-
void StyleEditDialog::weightChangedSymbol(const QFont::Weight& newWeight)
353+
void StyleEditDialog::weightChangedSymbol(QFont::Weight newWeight)
354354
{
355355
mStyleOutgoing.symbolWeight = newWeight;
356356
updateStyle();

gui/codeeditstyledialog.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,16 @@ public slots:
5959
void colorChangedLineNumFG(const QColor& newColor);
6060
void colorChangedLineNumBG(const QColor& newColor);
6161
void colorChangedKeywordFG(const QColor& newColor);
62-
void weightChangedKeyword(const QFont::Weight& newWeight);
62+
void weightChangedKeyword(QFont::Weight newWeight);
6363
void colorChangedClassFG(const QColor& newColor);
64-
void weightChangedClass(const QFont::Weight& newWeight);
64+
void weightChangedClass(QFont::Weight newWeight);
6565
void colorChangedQuoteFG(const QColor& newColor);
66-
void weightChangedQuote(const QFont::Weight& newWeight);
66+
void weightChangedQuote(QFont::Weight newWeight);
6767
void colorChangedCommentFG(const QColor& newColor);
68-
void weightChangedComment(const QFont::Weight& newWeight);
68+
void weightChangedComment(QFont::Weight newWeight);
6969
void colorChangedSymbolFG(const QColor& newColor);
7070
void colorChangedSymbolBG(const QColor& newColor);
71-
void weightChangedSymbol(const QFont::Weight& newWeight);
71+
void weightChangedSymbol(QFont::Weight newWeight);
7272

7373
private:
7474
CodeEditorStyle mStyleIncoming;

lib/checkstl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ static const struct CWE CWE825(825U); // Expired Pointer Dereference
6565
static const struct CWE CWE833(833U); // Deadlock
6666
static const struct CWE CWE834(834U); // Excessive Iteration
6767

68-
static bool isElementAccessYield(const Library::Container::Yield& yield)
68+
static bool isElementAccessYield(Library::Container::Yield yield)
6969
{
7070
return contains({Library::Container::Yield::ITEM, Library::Container::Yield::AT_INDEX}, yield);
7171
}

lib/color.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ static bool isStreamATty(const std::ostream & os)
4040
}
4141
#endif
4242

43-
std::ostream& operator<<(std::ostream & os, const Color& c)
43+
std::ostream& operator<<(std::ostream & os, Color c)
4444
{
4545
#ifndef _WIN32
4646
if (!gDisableColors && isStreamATty(os))
@@ -51,7 +51,7 @@ std::ostream& operator<<(std::ostream & os, const Color& c)
5151
return os;
5252
}
5353

54-
std::string toString(const Color& c)
54+
std::string toString(Color c)
5555
{
5656
#ifndef _WIN32
5757
std::stringstream ss;

lib/color.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ enum class Color {
3434
FgMagenta = 35,
3535
FgDefault = 39
3636
};
37-
CPPCHECKLIB std::ostream& operator<<(std::ostream& os, const Color& c);
37+
CPPCHECKLIB std::ostream& operator<<(std::ostream& os, Color c);
3838

39-
CPPCHECKLIB std::string toString(const Color& c);
39+
CPPCHECKLIB std::string toString(Color c);
4040

4141
extern CPPCHECKLIB bool gDisableColors; // for testing
4242

lib/symboldatabase.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3662,7 +3662,7 @@ static std::ostream & operator << (std::ostream & s, Scope::ScopeType type)
36623662
return s;
36633663
}
36643664

3665-
static std::string accessControlToString(const AccessControl& access)
3665+
static std::string accessControlToString(AccessControl access)
36663666
{
36673667
switch (access) {
36683668
case AccessControl::Public:

0 commit comments

Comments
 (0)