enabled and mitigated `readability-container-size-empty` clang-tidy warnings (#5340)

This commit is contained in:
Oliver Stöneberg 2023-08-17 17:01:08 +02:00 committed by GitHub
parent 3cf9100198
commit 5dbcea3f1d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 7 additions and 8 deletions

View File

@ -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,

View File

@ -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`<br/>
`bugprone-branch-clone`<br/>
`readability-const-return-type`<br/>
`modernize-return-braced-init-list`<br/>

View File

@ -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)

View File

@ -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);

View File

@ -3529,8 +3529,8 @@ void CheckOther::funcArgOrderDifferent(const std::string & functionName,
const std::vector<const Token *> & definitions)
{
std::list<const Token *> 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) {

View File

@ -3356,7 +3356,7 @@ void TemplateSimplifier::replaceTemplateUsage(
std::set<TemplateSimplifier::TokenAndName*>* 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

View File

@ -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);

View File

@ -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<int>& v) {\n"
" v.push_back(1);\n"