Skip to content

Commit

Permalink
Use in-class initializers, default constructors, class -> struct (#4842)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github committed Aug 8, 2023
1 parent 838b6b8 commit eee1221
Show file tree
Hide file tree
Showing 80 changed files with 531 additions and 861 deletions.
66 changes: 65 additions & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
@@ -1,5 +1,69 @@
---
Checks: '*,-abseil-*,-altera-*,-android-*,-boost-*,-cert-*,-cppcoreguidelines-*,-darwin-*,-fuchsia-*,-google-*,-hicpp-*,-linuxkernel-*,-llvm-*,-llvmlibc-*,-mpi-*,-objc-*,-openmp-*,-zircon-*,google-explicit-constructor,-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,-modernize-use-default-member-init,-readability-redundant-member-init,-modernize-avoid-c-arrays,-modernize-use-equals-default,-readability-container-size-empty,-bugprone-branch-clone,-bugprone-narrowing-conversions,-modernize-raw-string-literal,-readability-convert-member-functions-to-static,-modernize-loop-convert,-readability-const-return-type,-modernize-return-braced-init-list,-performance-inefficient-string-concatenation,-misc-throw-by-value-catch-by-reference,-readability-avoid-const-params-in-decls,-misc-non-private-member-variables-in-classes,-clang-analyzer-*,-bugprone-signed-char-misuse,-misc-no-recursion,-readability-use-anyofallof,-performance-no-automatic-move,-readability-function-cognitive-complexity,-readability-redundant-access-specifiers,-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,-portability-std-allocator-const,-modernize-deprecated-ios-base-aliases,-bugprone-unchecked-optional-access,-modernize-replace-auto-ptr,-readability-identifier-naming,-portability-simd-intrinsics,-misc-use-anonymous-namespace,cert-err34-c'
Checks: >
*,
-abseil-*,
-altera-*,
-android-*,
-boost-*,
-cert-*,
-cppcoreguidelines-*,
-darwin-*,
-fuchsia-*,
-google-*,
-hicpp-*,
-linuxkernel-*,
-llvm-*,
-llvmlibc-*,
-mpi-*,
-objc-*,
-openmp-*,
-zircon-*,
cert-err34-c,
google-explicit-constructor,
-bugprone-assignment-in-if-condition,
-bugprone-branch-clone,
-bugprone-easily-swappable-parameters,
-bugprone-macro-parentheses,
-bugprone-narrowing-conversions,
-bugprone-signed-char-misuse,
-bugprone-unchecked-optional-access,
-clang-analyzer-*,
-concurrency-mt-unsafe,
-misc-const-correctness,
-misc-no-recursion,
-misc-non-private-member-variables-in-classes,
-misc-throw-by-value-catch-by-reference,
-misc-use-anonymous-namespace,
-modernize-avoid-c-arrays,
-modernize-deprecated-ios-base-aliases,
-modernize-loop-convert,
-modernize-raw-string-literal,
-modernize-replace-auto-ptr,
-modernize-return-braced-init-list,
-modernize-use-auto,
-modernize-use-equals-default,
-modernize-use-trailing-return-type,
-performance-inefficient-string-concatenation,
-performance-no-automatic-move,
-portability-simd-intrinsics,
-portability-std-allocator-const,
-readability-avoid-const-params-in-decls,
-readability-braces-around-statements,
-readability-const-return-type,
-readability-container-data-pointer,
-readability-container-size-empty,
-readability-convert-member-functions-to-static,
-readability-function-cognitive-complexity,
-readability-function-size,
-readability-identifier-length,
-readability-identifier-naming,
-readability-implicit-bool-conversion,
-readability-isolate-declaration,
-readability-magic-numbers,
-readability-redundant-access-specifiers,
-readability-suspicious-call-argument,
-readability-uppercase-literal-suffix,
-readability-use-anyofallof
WarningsAsErrors: '*'
HeaderFilterRegex: '(cli|gui|lib|oss-fuzz|test|triage)\/[a-z]+\.h'
CheckOptions:
Expand Down
8 changes: 3 additions & 5 deletions clang-tidy.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,16 @@ These are coding guidelines we do not follow. Some of the checks might be explic
`modernize-use-auto`<br>
`readability-uppercase-literal-suffix`<br>
`readability-else-after-return`<br>
`modernize-use-default-member-init`<br>
`readability-identifier-length`<br>

These do not relect the style we are (currently) enforcing.
These do not reflect the style we are (currently) enforcing.

`readability-function-size`<br>
`readability-function-cognitive-complexity`<br>

We are not interesting in the size/complexity of a function.
We are not interested in the size/complexity of a function.

`readability-magic-numbers`<br>
`readability-redundant-member-init`<br>

These do not (always) increase readability.

Expand All @@ -58,7 +56,7 @@ To be documented.

`readability-implicit-bool-conversion`<br>

This does not appear not to be useful as it is reported on very common code.
This does not appear to be useful as it is reported on very common code.

`bugprone-narrowing-conversions`<br>
`performance-no-automatic-move`<br>
Expand Down
4 changes: 0 additions & 4 deletions cli/cmdlineparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,6 @@ CmdLineParser::CmdLineParser(Settings &settings, Suppressions &suppressions, Sup
: mSettings(settings)
, mSuppressions(suppressions)
, mSuppressionsNoFail(suppressionsNoFail)
, mShowHelp(false)
, mShowVersion(false)
, mShowErrorMessages(false)
, mExitAfterPrint(false)
{}

void CmdLineParser::printMessage(const std::string &message)
Expand Down
8 changes: 4 additions & 4 deletions cli/cmdlineparser.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,10 @@ class CmdLineParser {
Settings &mSettings;
Suppressions &mSuppressions;
Suppressions &mSuppressionsNoFail;
bool mShowHelp;
bool mShowVersion;
bool mShowErrorMessages;
bool mExitAfterPrint;
bool mShowHelp{};
bool mShowVersion{};
bool mShowErrorMessages{};
bool mExitAfterPrint{};
std::string mVSConfig;
};

Expand Down
4 changes: 0 additions & 4 deletions cli/cppcheckexecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,6 @@

/*static*/ FILE* CppCheckExecutor::mExceptionOutput = stdout;

CppCheckExecutor::CppCheckExecutor()
: mSettings(nullptr), mLatestProgressOutputTime(0), mErrorOutput(nullptr), mShowAllErrors(false)
{}

CppCheckExecutor::~CppCheckExecutor()
{
delete mErrorOutput;
Expand Down
10 changes: 5 additions & 5 deletions cli/cppcheckexecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class CppCheckExecutor : public ErrorLogger {
/**
* Constructor
*/
CppCheckExecutor();
CppCheckExecutor() = default;
CppCheckExecutor(const CppCheckExecutor &) = delete;
void operator=(const CppCheckExecutor&) = delete;

Expand Down Expand Up @@ -154,7 +154,7 @@ class CppCheckExecutor : public ErrorLogger {
/**
* Pointer to current settings; set while check() is running for reportError().
*/
const Settings* mSettings;
const Settings* mSettings{};

/**
* Used to filter out duplicate error messages.
Expand All @@ -169,7 +169,7 @@ class CppCheckExecutor : public ErrorLogger {
/**
* Report progress time
*/
std::time_t mLatestProgressOutputTime;
std::time_t mLatestProgressOutputTime{};

/**
* Output file name for exception handler
Expand All @@ -179,12 +179,12 @@ class CppCheckExecutor : public ErrorLogger {
/**
* Error output
*/
std::ofstream *mErrorOutput;
std::ofstream* mErrorOutput{};

/**
* Has --errorlist been given?
*/
bool mShowAllErrors;
bool mShowAllErrors{};
};

#endif // CPPCHECKEXECUTOR_H
10 changes: 5 additions & 5 deletions cli/threadexecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class ThreadData
{
public:
ThreadData(ThreadExecutor &threadExecutor, ErrorLogger &errorLogger, const Settings &settings, const std::map<std::string, std::size_t> &files, const std::list<ImportProject::FileSettings> &fileSettings)
: mFiles(files), mFileSettings(fileSettings), mProcessedFiles(0), mProcessedSize(0), mSettings(settings), logForwarder(threadExecutor, errorLogger)
: mFiles(files), mFileSettings(fileSettings), mSettings(settings), logForwarder(threadExecutor, errorLogger)
{
mItNextFile = mFiles.begin();
mItNextFileSettings = mFileSettings.begin();
Expand Down Expand Up @@ -148,10 +148,10 @@ class ThreadData
const std::list<ImportProject::FileSettings> &mFileSettings;
std::list<ImportProject::FileSettings>::const_iterator mItNextFileSettings;

std::size_t mProcessedFiles;
std::size_t mTotalFiles;
std::size_t mProcessedSize;
std::size_t mTotalFileSize;
std::size_t mProcessedFiles{};
std::size_t mTotalFiles{};
std::size_t mProcessedSize{};
std::size_t mTotalFileSize{};

std::mutex mFileSync;
const Settings &mSettings;
Expand Down
3 changes: 1 addition & 2 deletions gui/applicationlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
#include <QVariant>

ApplicationList::ApplicationList(QObject *parent) :
QObject(parent),
mDefaultApplicationIndex(-1)
QObject(parent)
{
//ctor
}
Expand Down
2 changes: 1 addition & 1 deletion gui/applicationlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class ApplicationList : public QObject {
* @brief Index of the default application.
*
*/
int mDefaultApplicationIndex;
int mDefaultApplicationIndex = -1;
};
/// @}
#endif // APPLICATIONLIST_H
4 changes: 1 addition & 3 deletions gui/checkthread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,8 @@ static bool executeCommand(std::string exe, std::vector<std::string> args, std::


CheckThread::CheckThread(ThreadResult &result) :
mState(Ready),
mResult(result),
mCppcheck(result, true, executeCommand),
mAnalyseWholeProgram(false)
mCppcheck(result, true, executeCommand)
{
//ctor
}
Expand Down
4 changes: 2 additions & 2 deletions gui/checkthread.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class CheckThread : public QThread {
/**
* @brief Thread's current execution state.
*/
State mState;
State mState = Ready;

ThreadResult &mResult;
/**
Expand All @@ -136,7 +136,7 @@ class CheckThread : public QThread {
bool isSuppressed(const Suppressions::ErrorMessage &errorMessage) const;

QStringList mFiles;
bool mAnalyseWholeProgram;
bool mAnalyseWholeProgram{};
QStringList mAddonsAndTools;
QStringList mClangIncludePaths;
QList<Suppressions::Suppression> mSuppressions;
Expand Down
1 change: 0 additions & 1 deletion gui/codeeditorstyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ CodeEditorStyle::CodeEditorStyle(
// cppcheck-suppress naming-varname - TODO: fix this
QColor SymbFGColor, QColor SymbBGColor,
const QFont::Weight& SymbWeight) :
mSystemTheme(false),
widgetFGColor(std::move(CtrlFGColor)),
widgetBGColor(std::move(CtrlBGColor)),
highlightBGColor(std::move(HiLiBGColor)),
Expand Down
2 changes: 1 addition & 1 deletion gui/codeeditorstyle.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class CodeEditorStyle {
static void saveSettings(QSettings *settings, const CodeEditorStyle& theStyle);

public:
bool mSystemTheme;
bool mSystemTheme{};
QColor widgetFGColor;
QColor widgetBGColor;
QColor highlightBGColor;
Expand Down
3 changes: 1 addition & 2 deletions gui/codeeditstylecontrols.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ const QColor& SelectColorButton::getColor()
}

SelectFontWeightCombo::SelectFontWeightCombo(QWidget* parent) :
QComboBox(parent),
mWeight(QFont::Normal)
QComboBox(parent)
{
addItem(QObject::tr("Thin"),
QVariant(static_cast<int>(QFont::Thin)));
Expand Down
2 changes: 1 addition & 1 deletion gui/codeeditstylecontrols.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public slots:
void changeWeight(int index);

private:
QFont::Weight mWeight;
QFont::Weight mWeight = QFont::Normal;
};

#endif //CODEEDITORSTYLECONTROLS_H
Expand Down
Loading

0 comments on commit eee1221

Please sign in to comment.