enabled and fixed `readability-named-parameter` clang-tidy warnings (#4487)

This commit is contained in:
Oliver Stöneberg 2022-09-27 20:03:25 +02:00 committed by GitHub
parent 767db58a5b
commit b9e07e918e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 45 additions and 46 deletions

View File

@ -1,5 +1,5 @@
---
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,-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,-bugprone-suspicious-include,-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,-portability-std-allocator-const,-modernize-deprecated-ios-base-aliases,-bugprone-unchecked-optional-access,-modernize-replace-auto-ptr,-readability-identifier-naming,-portability-simd-intrinsics'
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-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,-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,-bugprone-suspicious-include,-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,-portability-std-allocator-const,-modernize-deprecated-ios-base-aliases,-bugprone-unchecked-optional-access,-modernize-replace-auto-ptr,-readability-identifier-naming,-portability-simd-intrinsics'
WarningsAsErrors: '*'
CheckOptions:
- key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic

View File

@ -46,6 +46,10 @@ jobs:
modules: 'qtcharts'
cached: ${{ steps.cache-qt.outputs.cache-hit }}
- name: Verify clang-tidy configuration
run: |
clang-tidy-15 --verify-config
- name: Prepare CMake
run: |
cmake -S . -B cmake.output -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=On -DWITH_QCHART=On -DENABLE_CHECK_INTERNAL=On -DCMAKE_GLOBAL_AUTOGEN_TARGET=On -DCPPCHK_GLIBCXX_DEBUG=Off

View File

@ -55,7 +55,6 @@ These do not (always) increase readability.
`bugprone-macro-parentheses`<br>
`readability-implicit-bool-conversion`<br>
`readability-named-parameter`<br>
To be documented.

View File

@ -123,7 +123,7 @@ protected:
private slots:
void updateLineNumberAreaWidth(int newBlockCount);
void highlightErrorLine();
void updateLineNumberArea(const QRect &, int);
void updateLineNumberArea(const QRect & /*rect*/, int /*dy*/);
private:
QString generateStyleString();

View File

@ -46,10 +46,10 @@ private slots:
void addFunction();
void changeFunction();
void editArg();
void editFunctionName(QListWidgetItem*);
void filterFunctions(const QString&);
void editFunctionName(QListWidgetItem* /*item*/);
void filterFunctions(const QString& /*filter*/);
void selectFunction();
void sortFunctions(bool);
void sortFunctions(bool /*sort*/);
private:
Ui::LibraryDialog *mUi;

View File

@ -110,7 +110,7 @@ CppcheckLibraryData::Function::Arg LibraryEditArgDialog::getArg() const
return ret;
}
void LibraryEditArgDialog::minsizeChanged(int)
void LibraryEditArgDialog::minsizeChanged()
{
mUi->minsize1arg->setEnabled(mUi->minsize1type->currentIndex() != 0);
mUi->minsize1arg2->setEnabled(mUi->minsize1type->currentText() == "mul");

View File

@ -41,7 +41,7 @@ public:
CppcheckLibraryData::Function::Arg getArg() const;
private slots:
void minsizeChanged(int);
void minsizeChanged();
private:
Ui::LibraryEditArgDialog *mUi;

View File

@ -366,7 +366,7 @@
<sender>minsize1type</sender>
<signal>currentIndexChanged(int)</signal>
<receiver>LibraryEditArgDialog</receiver>
<slot>minsizeChanged(int)</slot>
<slot>minsizeChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>413</x>
@ -382,7 +382,7 @@
<sender>minsize2type</sender>
<signal>currentIndexChanged(int)</signal>
<receiver>LibraryEditArgDialog</receiver>
<slot>minsizeChanged(int)</slot>
<slot>minsizeChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>436</x>
@ -396,6 +396,6 @@
</connection>
</connections>
<slots>
<slot>minsizeChanged(int)</slot>
<slot>minsizeChanged()</slot>
</slots>
</ui>

View File

@ -38,7 +38,7 @@ NewSuppressionDialog::NewSuppressionDialog(QWidget *parent) :
class QErrorLogger : public ErrorLogger {
public:
void reportOut(const std::string & /*outmsg*/, Color) override {}
void reportOut(const std::string & /*outmsg*/, Color /*c*/) override {}
void reportErr(const ErrorMessage &msg) override {
errorIds << QString::fromStdString(msg.id);
}

View File

@ -878,7 +878,7 @@ void ProjectFileDialog::removeSuppression()
delete item;
}
void ProjectFileDialog::editSuppression(const QModelIndex &)
void ProjectFileDialog::editSuppression(const QModelIndex & /*index*/)
{
const int row = mUI->mListSuppressions->currentRow();
QListWidgetItem *item = mUI->mListSuppressions->item(row);

View File

@ -35,7 +35,7 @@ ThreadResult::~ThreadResult()
//dtor
}
void ThreadResult::reportOut(const std::string &outmsg, Color)
void ThreadResult::reportOut(const std::string &outmsg, Color /*c*/)
{
emit log(QString::fromStdString(outmsg));
}

View File

@ -161,7 +161,7 @@ CPPCHECKLIB void strTolower(std::string& str);
* \return size of array
* */
template<typename T, int size>
std::size_t getArrayLength(const T (&)[size])
std::size_t getArrayLength(const T (& /*unused*/)[size])
{
return size;
}

View File

@ -1987,7 +1987,7 @@ static void valueFlowReverse(TokenList* tokenlist,
ValueFlow::Value val,
const ValueFlow::Value& val2,
ErrorLogger* /*errorLogger*/,
const Settings* = nullptr,
const Settings* /*settings*/ = nullptr,
SourceLocation loc = SourceLocation::current())
{
std::list<ValueFlow::Value> values = {std::move(val)};
@ -2052,7 +2052,7 @@ static void assignValueIfMutable(T& x, const U& y)
}
template<class T, class U>
static void assignValueIfMutable(const T&, const U&)
static void assignValueIfMutable(const T& /*unused*/, const U& /*unused*/)
{}
template<class Value, REQUIRES("Value must ValueFlow::Value", std::is_convertible<Value&, const ValueFlow::Value&> )>
@ -2262,7 +2262,7 @@ struct ValueFlowAnalyzer : Analyzer {
virtual bool match(const Token* tok) const = 0;
virtual bool internalMatch(const Token*) const {
virtual bool internalMatch(const Token* /*tok*/) const {
return false;
}
@ -2806,7 +2806,7 @@ struct ValueFlowAnalyzer : Analyzer {
makeConditional();
}
virtual void internalUpdate(Token*, const ValueFlow::Value&, Direction)
virtual void internalUpdate(Token* /*tok*/, const ValueFlow::Value& /*v*/, Direction /*d*/)
{
assert(false && "Internal update unimplemented.");
}
@ -2837,7 +2837,7 @@ struct ValueFlowAnalyzer : Analyzer {
setTokenValue(tok, *value, getSettings());
}
ValuePtr<Analyzer> reanalyze(Token*, const std::string&) const override {
ValuePtr<Analyzer> reanalyze(Token* /*tok*/, const std::string& /*msg*/) const override {
return {};
}
};
@ -2859,10 +2859,10 @@ struct SingleValueFlowAnalyzer : ValueFlowAnalyzer {
return aliases;
}
const ValueFlow::Value* getValue(const Token*) const override {
const ValueFlow::Value* getValue(const Token* /*tok*/) const override {
return &value;
}
ValueFlow::Value* getValue(const Token*) override {
ValueFlow::Value* getValue(const Token* /*tok*/) override {
return &value;
}
@ -2945,7 +2945,7 @@ struct SingleValueFlowAnalyzer : ValueFlowAnalyzer {
return cs.isUnknownDependent();
}
bool updateScope(const Token* endBlock, bool) const override {
bool updateScope(const Token* endBlock, bool /*modified*/) const override {
const Scope* scope = endBlock->scope();
if (!scope)
return false;
@ -3124,13 +3124,13 @@ struct SubExpressionAnalyzer : ExpressionAnalyzer {
{
return tok->exprId() == expr->exprId() && !(astIsLHS(tok) && submatch(tok->astParent(), false));
}
void internalUpdate(Token* tok, const ValueFlow::Value& v, Direction) override
void internalUpdate(Token* tok, const ValueFlow::Value& v, Direction /*d*/) override
{
partialReads->emplace_back(tok, v);
}
// No reanalysis for subexression
ValuePtr<Analyzer> reanalyze(Token*, const std::string&) const override {
ValuePtr<Analyzer> reanalyze(Token* /*tok*/, const std::string& /*msg*/) const override {
return {};
}
};
@ -4491,7 +4491,7 @@ static bool isConvertedToView(const Token* tok, const Settings* settings)
});
}
static void valueFlowLifetime(TokenList *tokenlist, SymbolDatabase*, ErrorLogger *errorLogger, const Settings *settings)
static void valueFlowLifetime(TokenList *tokenlist, SymbolDatabase* /*db*/, ErrorLogger *errorLogger, const Settings *settings)
{
for (Token *tok = tokenlist->front(); tok; tok = tok->next()) {
if (!tok->scope())
@ -5322,7 +5322,7 @@ static void valueFlowForwardConst(Token* start,
const Variable* var,
const ContainerOfValue& values,
const Settings* const settings,
int = 0)
int /*unused*/ = 0)
{
for (Token* tok = start; tok != end; tok = tok->next()) {
if (tok->varId() == var->declarationId()) {
@ -5472,7 +5472,7 @@ static void valueFlowForwardAssign(Token* const tok,
static void valueFlowForwardAssign(Token* const tok,
const Variable* const var,
const std::list<ValueFlow::Value>& values,
const bool,
const bool /*unused*/,
const bool init,
TokenList* const tokenlist,
ErrorLogger* const errorLogger,
@ -6352,7 +6352,7 @@ static void valueFlowCondition(const ValuePtr<ConditionHandler>& handler,
}
struct SimpleConditionHandler : ConditionHandler {
std::vector<Condition> parse(const Token* tok, const Settings*) const override {
std::vector<Condition> parse(const Token* tok, const Settings* /*settings*/) const override {
std::vector<Condition> conds;
parseCompareEachInt(tok, [&](const Token* vartok, ValueFlow::Value true_value, ValueFlow::Value false_value) {
@ -6939,11 +6939,11 @@ struct MultiValueFlowAnalyzer : ValueFlowAnalyzer {
return false;
}
bool stopOnCondition(const Token*) const override {
bool stopOnCondition(const Token* /*condTok*/) const override {
return isConditional();
}
bool updateScope(const Token* endBlock, bool) const override {
bool updateScope(const Token* endBlock, bool /*modified*/) const override {
const Scope* scope = endBlock->scope();
if (!scope)
return false;
@ -7953,7 +7953,7 @@ static std::list<ValueFlow::Value> getIteratorValues(std::list<ValueFlow::Value>
}
struct IteratorConditionHandler : SimpleConditionHandler {
std::vector<Condition> parse(const Token* tok, const Settings*) const override {
std::vector<Condition> parse(const Token* tok, const Settings* /*settings*/) const override {
Condition cond;
if (Token::Match(tok, "==|!=")) {

View File

@ -23,11 +23,11 @@ enum class Color;
class DummyErrorLogger : public ErrorLogger {
public:
void reportOut(const std::string&, Color) override {}
void reportErr(const ErrorMessage&) override {}
void reportProgress(const std::string&,
const char[],
const std::size_t) override {}
void reportOut(const std::string& /*outmsg*/, Color /*c*/) override {}
void reportErr(const ErrorMessage& /*msg*/) override {}
void reportProgress(const std::string& /*filename*/,
const char /*stage*/[],
const std::size_t /*value*/) override {} // FN
};
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t dataSize);

View File

@ -38,7 +38,7 @@ private:
public:
std::list<std::string> id;
void reportOut(const std::string & /*outmsg*/, Color = Color::Reset) override {}
void reportOut(const std::string & /*outmsg*/, Color /*c*/ = Color::Reset) override {}
void reportErr(const ErrorMessage &msg) override {
id.push_back(msg.id);

View File

@ -22,6 +22,7 @@
#include "standards.h"
#include "testsuite.h"
#include "tokenize.h"
#include "utils.h"
#include <cstddef>
#include <sstream> // IWYU pragma: keep
@ -3028,17 +3029,12 @@ private:
ASSERT_EQUALS("", errout.str());
}
template<size_t n, typename T>
static size_t getArraylength(const T (&)[n]) {
return n;
}
void stlBoundaries1() {
const std::string stlCont[] = {
"list", "set", "multiset", "map", "multimap"
};
for (size_t i = 0; i < getArraylength(stlCont); ++i) {
for (size_t i = 0; i < getArrayLength(stlCont); ++i) {
check("void f()\n"
"{\n"
" std::" + stlCont[i] + "<int>::iterator it;\n"

View File

@ -374,7 +374,7 @@ std::size_t TestFixture::runTests(const options& args)
return fails_counter;
}
void TestFixture::reportOut(const std::string & outmsg, Color)
void TestFixture::reportOut(const std::string & outmsg, Color /*c*/)
{
output << outmsg << std::endl;
}

View File

@ -60,7 +60,7 @@ class SimpleSuppressor : public ErrorLogger {
public:
SimpleSuppressor(Settings &settings, ErrorLogger *next)
: settings(settings), next(next) {}
void reportOut(const std::string &outmsg, Color = Color::Reset) override {
void reportOut(const std::string &outmsg, Color /*c*/ = Color::Reset) override {
next->reportOut(outmsg);
}
void reportErr(const ErrorMessage &msg) override {