Skip to content

Commit b65b47d

Browse files
authored
enabled and fixed modernize-pass-by-value clang-tidy warnings (danmar#4169)
1 parent 304e448 commit b65b47d

27 files changed

Lines changed: 137 additions & 118 deletions

.clang-tidy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
Checks: '*,-abseil-*,-altera-*,-android-*,-boost-*,-cert-*,-cppcoreguidelines-*,-darwin-*,-fuchsia-*,-google-*,-hicpp-*,-linuxkernel-*,-llvm-*,-llvmlibc-*,-mpi-*,-objc-*,-openmp-*,-zircon-*,-readability-braces-around-statements,-readability-magic-numbers,-bugprone-macro-parentheses,-readability-isolate-declaration,-readability-function-size,-modernize-use-trailing-return-type,-readability-implicit-bool-conversion,-readability-uppercase-literal-suffix,-modernize-use-auto,-readability-else-after-return,-modernize-use-default-member-init,-readability-named-parameter,-readability-redundant-member-init,-performance-faster-string-find,-modernize-avoid-c-arrays,-modernize-use-equals-default,-readability-container-size-empty,-readability-simplify-boolean-expr,-modernize-pass-by-value,-bugprone-branch-clone,-bugprone-narrowing-conversions,-modernize-raw-string-literal,-readability-convert-member-functions-to-static,-modernize-loop-convert,-readability-const-return-type,-performance-unnecessary-value-param,-modernize-return-braced-init-list,-performance-inefficient-string-concatenation,-misc-throw-by-value-catch-by-reference,-readability-avoid-const-params-in-decls,-readability-non-const-parameter,-misc-non-private-member-variables-in-classes,-bugprone-suspicious-string-compare,-clang-analyzer-*,-bugprone-signed-char-misuse,-readability-make-member-function-const,-misc-no-recursion,-readability-use-anyofallof,-performance-no-automatic-move,-bugprone-suspicious-include,-modernize-replace-random-shuffle,-readability-function-cognitive-complexity,-readability-redundant-access-specifiers,-performance-noexcept-move-constructor,-concurrency-mt-unsafe,-bugprone-easily-swappable-parameters,-readability-suspicious-call-argument,-readability-identifier-length,-readability-container-data-pointer,-bugprone-assignment-in-if-condition,-misc-const-correctness'
2+
Checks: '*,-abseil-*,-altera-*,-android-*,-boost-*,-cert-*,-cppcoreguidelines-*,-darwin-*,-fuchsia-*,-google-*,-hicpp-*,-linuxkernel-*,-llvm-*,-llvmlibc-*,-mpi-*,-objc-*,-openmp-*,-zircon-*,-readability-braces-around-statements,-readability-magic-numbers,-bugprone-macro-parentheses,-readability-isolate-declaration,-readability-function-size,-modernize-use-trailing-return-type,-readability-implicit-bool-conversion,-readability-uppercase-literal-suffix,-modernize-use-auto,-readability-else-after-return,-modernize-use-default-member-init,-readability-named-parameter,-readability-redundant-member-init,-performance-faster-string-find,-modernize-avoid-c-arrays,-modernize-use-equals-default,-readability-container-size-empty,-readability-simplify-boolean-expr,-bugprone-branch-clone,-bugprone-narrowing-conversions,-modernize-raw-string-literal,-readability-convert-member-functions-to-static,-modernize-loop-convert,-readability-const-return-type,-performance-unnecessary-value-param,-modernize-return-braced-init-list,-performance-inefficient-string-concatenation,-misc-throw-by-value-catch-by-reference,-readability-avoid-const-params-in-decls,-readability-non-const-parameter,-misc-non-private-member-variables-in-classes,-bugprone-suspicious-string-compare,-clang-analyzer-*,-bugprone-signed-char-misuse,-readability-make-member-function-const,-misc-no-recursion,-readability-use-anyofallof,-performance-no-automatic-move,-bugprone-suspicious-include,-modernize-replace-random-shuffle,-readability-function-cognitive-complexity,-readability-redundant-access-specifiers,-performance-noexcept-move-constructor,-concurrency-mt-unsafe,-bugprone-easily-swappable-parameters,-readability-suspicious-call-argument,-readability-identifier-length,-readability-container-data-pointer,-bugprone-assignment-in-if-condition,-misc-const-correctness'
33
WarningsAsErrors: '*'
44
CheckOptions:
55
- key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic

gui/application.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818

1919
#include "application.h"
2020

21-
Application::Application(const QString &name, const QString &path,
22-
const QString &params)
23-
: mName(name)
24-
, mPath(path)
25-
, mParameters(params)
21+
Application::Application(QString name, QString path,
22+
QString params)
23+
: mName(std::move(name))
24+
, mPath(std::move(path))
25+
, mParameters(std::move(params))
2626
{}

gui/application.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
class Application {
4444
public:
4545
Application() {}
46-
Application(const QString &name, const QString &path, const QString &params);
46+
Application(QString name, QString path, QString params);
4747

4848
/**
4949
* @brief Get application name.

gui/codeeditorstyle.cpp

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,33 +19,42 @@
1919
#include "codeeditorstyle.h"
2020

2121
#include <QSettings>
22+
#include <utility>
2223

2324
CodeEditorStyle::CodeEditorStyle(
24-
const QColor& CtrlFGColor, const QColor& CtrlBGColor,
25-
const QColor& HiLiBGColor,
26-
const QColor& LnNumFGColor, const QColor& LnNumBGColor,
27-
const QColor& KeyWdFGColor, const QFont::Weight& KeyWdWeight,
28-
const QColor& ClsFGColor, const QFont::Weight& ClsWeight,
29-
const QColor& QteFGColor, const QFont::Weight& QteWeight,
30-
const QColor& CmtFGColor, const QFont::Weight& CmtWeight,
31-
const QColor& SymbFGColor, const QColor& SymbBGColor,
25+
// cppcheck-suppress naming-varname - TODO: fix this
26+
QColor CtrlFGColor, QColor CtrlBGColor,
27+
// cppcheck-suppress naming-varname - TODO: fix this
28+
QColor HiLiBGColor,
29+
// cppcheck-suppress naming-varname - TODO: fix this
30+
QColor LnNumFGColor, QColor LnNumBGColor,
31+
// cppcheck-suppress naming-varname - TODO: fix this
32+
QColor KeyWdFGColor, const QFont::Weight& KeyWdWeight,
33+
// cppcheck-suppress naming-varname - TODO: fix this
34+
QColor ClsFGColor, const QFont::Weight& ClsWeight,
35+
// cppcheck-suppress naming-varname - TODO: fix this
36+
QColor QteFGColor, const QFont::Weight& QteWeight,
37+
// cppcheck-suppress naming-varname - TODO: fix this
38+
QColor CmtFGColor, const QFont::Weight& CmtWeight,
39+
// cppcheck-suppress naming-varname - TODO: fix this
40+
QColor SymbFGColor, QColor SymbBGColor,
3241
const QFont::Weight& SymbWeight) :
3342
mSystemTheme(false),
34-
widgetFGColor(CtrlFGColor),
35-
widgetBGColor(CtrlBGColor),
36-
highlightBGColor(HiLiBGColor),
37-
lineNumFGColor(LnNumFGColor),
38-
lineNumBGColor(LnNumBGColor),
39-
keywordColor(KeyWdFGColor),
43+
widgetFGColor(std::move(CtrlFGColor)),
44+
widgetBGColor(std::move(CtrlBGColor)),
45+
highlightBGColor(std::move(HiLiBGColor)),
46+
lineNumFGColor(std::move(LnNumFGColor)),
47+
lineNumBGColor(std::move(LnNumBGColor)),
48+
keywordColor(std::move(KeyWdFGColor)),
4049
keywordWeight(KeyWdWeight),
41-
classColor(ClsFGColor),
50+
classColor(std::move(ClsFGColor)),
4251
classWeight(ClsWeight),
43-
quoteColor(QteFGColor),
52+
quoteColor(std::move(QteFGColor)),
4453
quoteWeight(QteWeight),
45-
commentColor(CmtFGColor),
54+
commentColor(std::move(CmtFGColor)),
4655
commentWeight(CmtWeight),
47-
symbolFGColor(SymbFGColor),
48-
symbolBGColor(SymbBGColor),
56+
symbolFGColor(std::move(SymbFGColor)),
57+
symbolBGColor(std::move(SymbBGColor)),
4958
symbolWeight(SymbWeight)
5059
{}
5160

gui/codeeditorstyle.h

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,22 @@ class QSettings;
5050
class CodeEditorStyle {
5151
public:
5252
explicit CodeEditorStyle(
53-
const QColor& CtrlFGColor, const QColor& CtrlBGColor,
54-
const QColor& HiLiBGColor,
55-
const QColor& LnNumFGColor, const QColor& LnNumBGColor,
56-
const QColor& KeyWdFGColor, const QFont::Weight& KeyWdWeight,
57-
const QColor& ClsFGColor, const QFont::Weight& ClsWeight,
58-
const QColor& QteFGColor, const QFont::Weight& QteWeight,
59-
const QColor& CmtFGColor, const QFont::Weight& CmtWeight,
60-
const QColor& SymbFGColor, const QColor& SymbBGColor,
53+
// cppcheck-suppress naming-varname - TODO: fix this
54+
QColor CtrlFGColor, QColor CtrlBGColor,
55+
// cppcheck-suppress naming-varname - TODO: fix this
56+
QColor HiLiBGColor,
57+
// cppcheck-suppress naming-varname - TODO: fix this
58+
QColor LnNumFGColor, QColor LnNumBGColor,
59+
// cppcheck-suppress naming-varname - TODO: fix this
60+
QColor KeyWdFGColor, const QFont::Weight& KeyWdWeight,
61+
// cppcheck-suppress naming-varname - TODO: fix this
62+
QColor ClsFGColor, const QFont::Weight& ClsWeight,
63+
// cppcheck-suppress naming-varname - TODO: fix this
64+
QColor QteFGColor, const QFont::Weight& QteWeight,
65+
// cppcheck-suppress naming-varname - TODO: fix this
66+
QColor CmtFGColor, const QFont::Weight& CmtWeight,
67+
// cppcheck-suppress naming-varname - TODO: fix this
68+
QColor SymbFGColor, QColor SymbBGColor,
6169
const QFont::Weight& SymbWeight);
6270
~CodeEditorStyle() {}
6371

gui/projectfile.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ ProjectFile::ProjectFile(QObject *parent) :
3838
clear();
3939
}
4040

41-
ProjectFile::ProjectFile(const QString &filename, QObject *parent) :
41+
ProjectFile::ProjectFile(QString filename, QObject *parent) :
4242
QObject(parent),
43-
mFilename(filename)
43+
mFilename(std::move(filename))
4444
{
4545
clear();
4646
read();

gui/projectfile.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class ProjectFile : public QObject {
4646

4747
public:
4848
explicit ProjectFile(QObject *parent = nullptr);
49-
explicit ProjectFile(const QString &filename, QObject *parent = nullptr);
49+
explicit ProjectFile(QString filename, QObject *parent = nullptr);
5050
~ProjectFile() override {
5151
if (this == mActiveProject) mActiveProject = nullptr;
5252
}

gui/report.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818

1919
#include "report.h"
2020

21-
Report::Report(const QString &filename) :
21+
Report::Report(QString filename) :
2222
QObject(),
23-
mFilename(filename)
23+
mFilename(std::move(filename))
2424
{}
2525

2626
Report::~Report()

gui/report.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class Report : public QObject {
3939
CSV,
4040
};
4141

42-
explicit Report(const QString &filename);
42+
explicit Report(QString filename);
4343
~Report() override;
4444

4545
/**

lib/checkunusedfunctions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ std::string CheckUnusedFunctions::analyzerInfo() const
393393
namespace {
394394
struct Location {
395395
Location() : lineNumber(0) {}
396-
Location(const std::string &f, const int l) : fileName(f), lineNumber(l) {}
396+
Location(std::string f, const int l) : fileName(std::move(f)), lineNumber(l) {}
397397
std::string fileName;
398398
int lineNumber;
399399
};

0 commit comments

Comments
 (0)