mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-09-06 17:37:21 +02:00
[clang-tidy] Use .empty instead of comparing size
Found with readability-container-size-empty Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
parent
d43fa66489
commit
a331cceded
18 changed files with 132 additions and 132 deletions
28
src/DOM.cpp
28
src/DOM.cpp
|
@ -63,7 +63,7 @@
|
|||
bool getDOM (const std::string& name, Variant& value)
|
||||
{
|
||||
// Special case, blank refs cause problems.
|
||||
if (name == "")
|
||||
if (name.empty())
|
||||
return false;
|
||||
|
||||
auto len = name.length ();
|
||||
|
@ -111,7 +111,7 @@ bool getDOM (const std::string& name, Variant& value)
|
|||
std::string commandLine;
|
||||
for (auto& arg : Context::getContext ().cli2._original_args)
|
||||
{
|
||||
if (commandLine != "")
|
||||
if (!commandLine.empty())
|
||||
commandLine += ' ';
|
||||
|
||||
commandLine += arg.attribute("raw");
|
||||
|
@ -158,7 +158,7 @@ bool getDOM (const std::string& name, Variant& value)
|
|||
std::string commandLine;
|
||||
for (auto& arg : Context::getContext ().cli2._original_args)
|
||||
{
|
||||
if (commandLine != "")
|
||||
if (!commandLine.empty())
|
||||
commandLine += ' ';
|
||||
|
||||
commandLine += arg.attribute("raw");
|
||||
|
@ -242,17 +242,17 @@ bool getDOM (const std::string& name, Variant& value)
|
|||
bool getDOM (const std::string& name, const Task& task, Variant& value)
|
||||
{
|
||||
// Special case, blank refs cause problems.
|
||||
if (name == "")
|
||||
if (name.empty())
|
||||
return false;
|
||||
|
||||
// Quickly deal with the most common cases.
|
||||
if (task.data.size () && name == "id")
|
||||
if (!task.data.empty() && name == "id")
|
||||
{
|
||||
value = Variant (static_cast<int> (task.id));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (task.data.size () && name == "urgency")
|
||||
if (!task.data.empty() && name == "urgency")
|
||||
{
|
||||
value = Variant (task.urgency_c ());
|
||||
return true;
|
||||
|
@ -295,13 +295,13 @@ bool getDOM (const std::string& name, const Task& task, Variant& value)
|
|||
{
|
||||
// Now that 'ref' is the contextual task, and any ID/UUID is chopped off the
|
||||
// elements vector, DOM resolution is now simple.
|
||||
if (ref.data.size () && size == 1 && canonical == "id")
|
||||
if (!ref.data.empty() && size == 1 && canonical == "id")
|
||||
{
|
||||
value = Variant (static_cast<int> (ref.id));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (ref.data.size () && size == 1 && canonical == "urgency")
|
||||
if (!ref.data.empty() && size == 1 && canonical == "urgency")
|
||||
{
|
||||
value = Variant (ref.urgency_c ());
|
||||
return true;
|
||||
|
@ -309,7 +309,7 @@ bool getDOM (const std::string& name, const Task& task, Variant& value)
|
|||
|
||||
Column* column = Context::getContext ().columns[canonical];
|
||||
|
||||
if (ref.data.size () && size == 1 && column)
|
||||
if (!ref.data.empty() && size == 1 && column)
|
||||
{
|
||||
if (column->is_uda () && ! ref.has (canonical))
|
||||
{
|
||||
|
@ -344,13 +344,13 @@ bool getDOM (const std::string& name, const Task& task, Variant& value)
|
|||
return true;
|
||||
}
|
||||
|
||||
if (ref.data.size () && size == 2 && canonical == "tags")
|
||||
if (!ref.data.empty() && size == 2 && canonical == "tags")
|
||||
{
|
||||
value = Variant (ref.hasTag (elements[1]) ? elements[1] : "");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (ref.data.size () && size == 2 && column && column->type () == "date")
|
||||
if (!ref.data.empty() && size == 2 && column && column->type () == "date")
|
||||
{
|
||||
Datetime date (ref.get_date (canonical));
|
||||
if (elements[1] == "year") { value = Variant (static_cast<int> (date.year ())); return true; }
|
||||
|
@ -365,13 +365,13 @@ bool getDOM (const std::string& name, const Task& task, Variant& value)
|
|||
}
|
||||
}
|
||||
|
||||
if (ref.data.size () && size == 2 && elements[0] == "annotations" && elements[1] == "count")
|
||||
if (!ref.data.empty() && size == 2 && elements[0] == "annotations" && elements[1] == "count")
|
||||
{
|
||||
value = Variant (static_cast<int> (ref.getAnnotationCount ()));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (ref.data.size () && size == 3 && elements[0] == "annotations")
|
||||
if (!ref.data.empty() && size == 3 && elements[0] == "annotations")
|
||||
{
|
||||
auto annos = ref.getAnnotations ();
|
||||
|
||||
|
@ -399,7 +399,7 @@ bool getDOM (const std::string& name, const Task& task, Variant& value)
|
|||
}
|
||||
}
|
||||
|
||||
if (ref.data.size () && size == 4 && elements[0] == "annotations" && elements[2] == "entry")
|
||||
if (!ref.data.empty() && size == 4 && elements[0] == "annotations" && elements[2] == "entry")
|
||||
{
|
||||
auto annos = ref.getAnnotations ();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue