diff --git a/.clang-tidy b/.clang-tidy index 540d5a7e8..96c8908f0 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -56,7 +56,6 @@ Checks: > -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, diff --git a/clang-tidy.md b/clang-tidy.md index a2e2dd5db..b85031ac2 100644 --- a/clang-tidy.md +++ b/clang-tidy.md @@ -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. -`readability-container-size-empty`
`bugprone-branch-clone`
`readability-const-return-type`
`modernize-return-braced-init-list`
diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 2840c4833..fd5dc6dff 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -697,7 +697,7 @@ void MainWindow::analyzeFiles() 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") || file0.endsWith(".vcxproj") || file0.endsWith(compile_commands_json) diff --git a/gui/test/cppchecklibrarydata/testcppchecklibrarydata.cpp b/gui/test/cppchecklibrarydata/testcppchecklibrarydata.cpp index aadb090d1..015e8a60d 100644 --- a/gui/test/cppchecklibrarydata/testcppchecklibrarydata.cpp +++ b/gui/test/cppchecklibrarydata/testcppchecklibrarydata.cpp @@ -620,7 +620,7 @@ void TestCppcheckLibraryData::validateAllCfg() { const QDir dir(QString(SRCDIR) + "/../../../cfg/"); const QStringList files = dir.entryList(QStringList() << "*.cfg",QDir::Files); - QVERIFY(files.size() != 0); + QVERIFY(!files.empty()); bool error = false; for (const QString& f : files) { loadCfgFile(dir.absolutePath() + "/" + f, fileLibraryData, result); diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 123189bde..6b94c3484 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -3529,8 +3529,8 @@ void CheckOther::funcArgOrderDifferent(const std::string & functionName, const std::vector & definitions) { std::list tokens = { - declarations.size() ? declarations[0] ? declarations[0] : declaration : nullptr, - definitions.size() ? definitions[0] ? definitions[0] : definition : nullptr + !declarations.empty() ? declarations[0] ? declarations[0] : declaration : nullptr, + !definitions.empty() ? definitions[0] ? definitions[0] : definition : nullptr }; std::string msg = "$symbol:" + functionName + "\nFunction '$symbol' argument order different: declaration '"; for (int i = 0; i < declarations.size(); ++i) { diff --git a/lib/templatesimplifier.cpp b/lib/templatesimplifier.cpp index e79046cc6..f906fbb91 100644 --- a/lib/templatesimplifier.cpp +++ b/lib/templatesimplifier.cpp @@ -3356,7 +3356,7 @@ void TemplateSimplifier::replaceTemplateUsage( std::set* pointers = nameTok->templateSimplifierPointers(); // check if instantiation matches token instantiation from pointer - if (pointers && pointers->size()) { + if (pointers && !pointers->empty()) { // check full name if (instantiation.fullName() != (*pointers->begin())->fullName()) { // FIXME: fallback to just matching name diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index 13e719e46..f97f3373f 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -1921,6 +1921,7 @@ private: ASSERT_EQUALS(10, db->variableList().size() - 1); ASSERT_EQUALS(true, db->getVariableFromVarId(1) && db->getVariableFromVarId(1)->dimensions().size() == 1); 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(4) != nullptr); ASSERT_EQUALS(true, db->getVariableFromVarId(5) != nullptr); diff --git a/test/testvalueflow.cpp b/test/testvalueflow.cpp index d9faba928..50a58464a 100644 --- a/test/testvalueflow.cpp +++ b/test/testvalueflow.cpp @@ -6616,7 +6616,7 @@ private: " if (a.empty() && b.empty()) {}\n" " else if (a.empty() == false && b.empty() == false) {}\n" "}\n"; - ASSERT("" != isImpossibleContainerSizeValue(tokenValues(code, "a . empty ( ) == false"), 0)); + ASSERT(!isImpossibleContainerSizeValue(tokenValues(code, "a . empty ( ) == false"), 0).empty()); code = "bool g(std::vector& v) {\n" " v.push_back(1);\n"