Skip to content

Commit 5dbcea3

Browse files
authored
enabled and mitigated readability-container-size-empty clang-tidy warnings (#5340)
1 parent 3cf9100 commit 5dbcea3

8 files changed

Lines changed: 7 additions & 8 deletions

File tree

.clang-tidy

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ Checks: >
5656
-readability-braces-around-statements,
5757
-readability-const-return-type,
5858
-readability-container-data-pointer,
59-
-readability-container-size-empty,
6059
-readability-convert-member-functions-to-static,
6160
-readability-function-cognitive-complexity,
6261
-readability-function-size,

clang-tidy.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ Also reports a false positive about templates which deduce the array length: htt
128128

129129
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.
130130

131-
`readability-container-size-empty`<br/>
132131
`bugprone-branch-clone`<br/>
133132
`readability-const-return-type`<br/>
134133
`modernize-return-braced-init-list`<br/>

gui/mainwindow.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ void MainWindow::analyzeFiles()
697697

698698
QStringList selected = selectFilesToAnalyze(QFileDialog::ExistingFiles);
699699

700-
const QString file0 = (selected.size() ? selected[0].toLower() : QString());
700+
const QString file0 = (!selected.empty() ? selected[0].toLower() : QString());
701701
if (file0.endsWith(".sln")
702702
|| file0.endsWith(".vcxproj")
703703
|| file0.endsWith(compile_commands_json)

gui/test/cppchecklibrarydata/testcppchecklibrarydata.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ void TestCppcheckLibraryData::validateAllCfg()
620620
{
621621
const QDir dir(QString(SRCDIR) + "/../../../cfg/");
622622
const QStringList files = dir.entryList(QStringList() << "*.cfg",QDir::Files);
623-
QVERIFY(files.size() != 0);
623+
QVERIFY(!files.empty());
624624
bool error = false;
625625
for (const QString& f : files) {
626626
loadCfgFile(dir.absolutePath() + "/" + f, fileLibraryData, result);

lib/checkother.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3529,8 +3529,8 @@ void CheckOther::funcArgOrderDifferent(const std::string & functionName,
35293529
const std::vector<const Token *> & definitions)
35303530
{
35313531
std::list<const Token *> tokens = {
3532-
declarations.size() ? declarations[0] ? declarations[0] : declaration : nullptr,
3533-
definitions.size() ? definitions[0] ? definitions[0] : definition : nullptr
3532+
!declarations.empty() ? declarations[0] ? declarations[0] : declaration : nullptr,
3533+
!definitions.empty() ? definitions[0] ? definitions[0] : definition : nullptr
35343534
};
35353535
std::string msg = "$symbol:" + functionName + "\nFunction '$symbol' argument order different: declaration '";
35363536
for (int i = 0; i < declarations.size(); ++i) {

lib/templatesimplifier.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3356,7 +3356,7 @@ void TemplateSimplifier::replaceTemplateUsage(
33563356
std::set<TemplateSimplifier::TokenAndName*>* pointers = nameTok->templateSimplifierPointers();
33573357

33583358
// check if instantiation matches token instantiation from pointer
3359-
if (pointers && pointers->size()) {
3359+
if (pointers && !pointers->empty()) {
33603360
// check full name
33613361
if (instantiation.fullName() != (*pointers->begin())->fullName()) {
33623362
// FIXME: fallback to just matching name

test/testsymboldatabase.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1921,6 +1921,7 @@ class TestSymbolDatabase : public TestFixture {
19211921
ASSERT_EQUALS(10, db->variableList().size() - 1);
19221922
ASSERT_EQUALS(true, db->getVariableFromVarId(1) && db->getVariableFromVarId(1)->dimensions().size() == 1);
19231923
ASSERT_EQUALS(true, db->getVariableFromVarId(2) != nullptr);
1924+
// NOLINTNEXTLINE(readability-container-size-empty)
19241925
ASSERT_EQUALS(true, db->getVariableFromVarId(3) && db->getVariableFromVarId(3)->dimensions().size() == 0);
19251926
ASSERT_EQUALS(true, db->getVariableFromVarId(4) != nullptr);
19261927
ASSERT_EQUALS(true, db->getVariableFromVarId(5) != nullptr);

test/testvalueflow.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6616,7 +6616,7 @@ class TestValueFlow : public TestFixture {
66166616
" if (a.empty() && b.empty()) {}\n"
66176617
" else if (a.empty() == false && b.empty() == false) {}\n"
66186618
"}\n";
6619-
ASSERT("" != isImpossibleContainerSizeValue(tokenValues(code, "a . empty ( ) == false"), 0));
6619+
ASSERT(!isImpossibleContainerSizeValue(tokenValues(code, "a . empty ( ) == false"), 0).empty());
66206620

66216621
code = "bool g(std::vector<int>& v) {\n"
66226622
" v.push_back(1);\n"

0 commit comments

Comments
 (0)