enabled and mitigated `readability-container-size-empty` clang-tidy warnings (#5340)
This commit is contained in:
parent
3cf9100198
commit
5dbcea3f1d
|
@ -56,7 +56,6 @@ Checks: >
|
||||||
-readability-braces-around-statements,
|
-readability-braces-around-statements,
|
||||||
-readability-const-return-type,
|
-readability-const-return-type,
|
||||||
-readability-container-data-pointer,
|
-readability-container-data-pointer,
|
||||||
-readability-container-size-empty,
|
|
||||||
-readability-convert-member-functions-to-static,
|
-readability-convert-member-functions-to-static,
|
||||||
-readability-function-cognitive-complexity,
|
-readability-function-cognitive-complexity,
|
||||||
-readability-function-size,
|
-readability-function-size,
|
||||||
|
|
|
@ -128,7 +128,6 @@ Also reports a false positive about templates which deduce the array length: htt
|
||||||
|
|
||||||
We run this separately via `clang-include-cleaner` in the `iwyu.yml` workflow as the findings of the include checkers still need to be reviewed manually before applying them.
|
We run this separately via `clang-include-cleaner` in the `iwyu.yml` workflow as the findings of the include checkers still need to be reviewed manually before applying them.
|
||||||
|
|
||||||
`readability-container-size-empty`<br/>
|
|
||||||
`bugprone-branch-clone`<br/>
|
`bugprone-branch-clone`<br/>
|
||||||
`readability-const-return-type`<br/>
|
`readability-const-return-type`<br/>
|
||||||
`modernize-return-braced-init-list`<br/>
|
`modernize-return-braced-init-list`<br/>
|
||||||
|
|
|
@ -697,7 +697,7 @@ void MainWindow::analyzeFiles()
|
||||||
|
|
||||||
QStringList selected = selectFilesToAnalyze(QFileDialog::ExistingFiles);
|
QStringList selected = selectFilesToAnalyze(QFileDialog::ExistingFiles);
|
||||||
|
|
||||||
const QString file0 = (selected.size() ? selected[0].toLower() : QString());
|
const QString file0 = (!selected.empty() ? selected[0].toLower() : QString());
|
||||||
if (file0.endsWith(".sln")
|
if (file0.endsWith(".sln")
|
||||||
|| file0.endsWith(".vcxproj")
|
|| file0.endsWith(".vcxproj")
|
||||||
|| file0.endsWith(compile_commands_json)
|
|| file0.endsWith(compile_commands_json)
|
||||||
|
|
|
@ -620,7 +620,7 @@ void TestCppcheckLibraryData::validateAllCfg()
|
||||||
{
|
{
|
||||||
const QDir dir(QString(SRCDIR) + "/../../../cfg/");
|
const QDir dir(QString(SRCDIR) + "/../../../cfg/");
|
||||||
const QStringList files = dir.entryList(QStringList() << "*.cfg",QDir::Files);
|
const QStringList files = dir.entryList(QStringList() << "*.cfg",QDir::Files);
|
||||||
QVERIFY(files.size() != 0);
|
QVERIFY(!files.empty());
|
||||||
bool error = false;
|
bool error = false;
|
||||||
for (const QString& f : files) {
|
for (const QString& f : files) {
|
||||||
loadCfgFile(dir.absolutePath() + "/" + f, fileLibraryData, result);
|
loadCfgFile(dir.absolutePath() + "/" + f, fileLibraryData, result);
|
||||||
|
|
|
@ -3529,8 +3529,8 @@ void CheckOther::funcArgOrderDifferent(const std::string & functionName,
|
||||||
const std::vector<const Token *> & definitions)
|
const std::vector<const Token *> & definitions)
|
||||||
{
|
{
|
||||||
std::list<const Token *> tokens = {
|
std::list<const Token *> tokens = {
|
||||||
declarations.size() ? declarations[0] ? declarations[0] : declaration : nullptr,
|
!declarations.empty() ? declarations[0] ? declarations[0] : declaration : nullptr,
|
||||||
definitions.size() ? definitions[0] ? definitions[0] : definition : nullptr
|
!definitions.empty() ? definitions[0] ? definitions[0] : definition : nullptr
|
||||||
};
|
};
|
||||||
std::string msg = "$symbol:" + functionName + "\nFunction '$symbol' argument order different: declaration '";
|
std::string msg = "$symbol:" + functionName + "\nFunction '$symbol' argument order different: declaration '";
|
||||||
for (int i = 0; i < declarations.size(); ++i) {
|
for (int i = 0; i < declarations.size(); ++i) {
|
||||||
|
|
|
@ -3356,7 +3356,7 @@ void TemplateSimplifier::replaceTemplateUsage(
|
||||||
std::set<TemplateSimplifier::TokenAndName*>* pointers = nameTok->templateSimplifierPointers();
|
std::set<TemplateSimplifier::TokenAndName*>* pointers = nameTok->templateSimplifierPointers();
|
||||||
|
|
||||||
// check if instantiation matches token instantiation from pointer
|
// check if instantiation matches token instantiation from pointer
|
||||||
if (pointers && pointers->size()) {
|
if (pointers && !pointers->empty()) {
|
||||||
// check full name
|
// check full name
|
||||||
if (instantiation.fullName() != (*pointers->begin())->fullName()) {
|
if (instantiation.fullName() != (*pointers->begin())->fullName()) {
|
||||||
// FIXME: fallback to just matching name
|
// FIXME: fallback to just matching name
|
||||||
|
|
|
@ -1921,6 +1921,7 @@ private:
|
||||||
ASSERT_EQUALS(10, db->variableList().size() - 1);
|
ASSERT_EQUALS(10, db->variableList().size() - 1);
|
||||||
ASSERT_EQUALS(true, db->getVariableFromVarId(1) && db->getVariableFromVarId(1)->dimensions().size() == 1);
|
ASSERT_EQUALS(true, db->getVariableFromVarId(1) && db->getVariableFromVarId(1)->dimensions().size() == 1);
|
||||||
ASSERT_EQUALS(true, db->getVariableFromVarId(2) != nullptr);
|
ASSERT_EQUALS(true, db->getVariableFromVarId(2) != nullptr);
|
||||||
|
// NOLINTNEXTLINE(readability-container-size-empty)
|
||||||
ASSERT_EQUALS(true, db->getVariableFromVarId(3) && db->getVariableFromVarId(3)->dimensions().size() == 0);
|
ASSERT_EQUALS(true, db->getVariableFromVarId(3) && db->getVariableFromVarId(3)->dimensions().size() == 0);
|
||||||
ASSERT_EQUALS(true, db->getVariableFromVarId(4) != nullptr);
|
ASSERT_EQUALS(true, db->getVariableFromVarId(4) != nullptr);
|
||||||
ASSERT_EQUALS(true, db->getVariableFromVarId(5) != nullptr);
|
ASSERT_EQUALS(true, db->getVariableFromVarId(5) != nullptr);
|
||||||
|
|
|
@ -6616,7 +6616,7 @@ private:
|
||||||
" if (a.empty() && b.empty()) {}\n"
|
" if (a.empty() && b.empty()) {}\n"
|
||||||
" else if (a.empty() == false && b.empty() == false) {}\n"
|
" else if (a.empty() == false && b.empty() == false) {}\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
ASSERT("" != isImpossibleContainerSizeValue(tokenValues(code, "a . empty ( ) == false"), 0));
|
ASSERT(!isImpossibleContainerSizeValue(tokenValues(code, "a . empty ( ) == false"), 0).empty());
|
||||||
|
|
||||||
code = "bool g(std::vector<int>& v) {\n"
|
code = "bool g(std::vector<int>& v) {\n"
|
||||||
" v.push_back(1);\n"
|
" v.push_back(1);\n"
|
||||||
|
|
Loading…
Reference in New Issue