mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +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
38
src/CLI2.cpp
38
src/CLI2.cpp
|
@ -162,7 +162,7 @@ void A2::decompose ()
|
|||
|
||||
if (name == "rc")
|
||||
{
|
||||
if (mod != "")
|
||||
if (!mod.empty())
|
||||
tag ("CONFIG");
|
||||
else
|
||||
tag ("RC");
|
||||
|
@ -258,7 +258,7 @@ bool CLI2::getDataLocation (int argc, const char** argv, Path& data)
|
|||
if (value == nullptr)
|
||||
{
|
||||
std::string location = Context::getContext ().config.get ("data.location");
|
||||
if (location != "")
|
||||
if (!location.empty())
|
||||
data = location;
|
||||
return false;
|
||||
}
|
||||
|
@ -573,7 +573,7 @@ void CLI2::addContextFilter ()
|
|||
|
||||
// Detect if any context is set, and bail out if not
|
||||
std::string contextName = Context::getContext ().config.get ("context");
|
||||
if (contextName == "")
|
||||
if (contextName.empty())
|
||||
{
|
||||
Context::getContext ().debug ("No context.");
|
||||
return;
|
||||
|
@ -595,7 +595,7 @@ void CLI2::addContextFilter ()
|
|||
Context::getContext ().debug ("Applying context: " + contextName);
|
||||
std::string contextFilter = Context::getContext ().config.get ("context." + contextName);
|
||||
|
||||
if (contextFilter == "")
|
||||
if (contextFilter.empty())
|
||||
Context::getContext ().debug ("Context '" + contextName + "' not defined.");
|
||||
else
|
||||
{
|
||||
|
@ -635,14 +635,14 @@ void CLI2::prepareFilter ()
|
|||
{
|
||||
if (a.hasTag ("FILTER"))
|
||||
{
|
||||
if (combined != "")
|
||||
if (!combined.empty())
|
||||
combined += ' ';
|
||||
|
||||
combined += a.attribute ("raw");
|
||||
}
|
||||
}
|
||||
|
||||
if (combined.size ())
|
||||
if (!combined.empty())
|
||||
Context::getContext ().footnote (std::string ("Filter: ") + combined);
|
||||
}
|
||||
}
|
||||
|
@ -704,7 +704,7 @@ bool CLI2::canonicalize (
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::string CLI2::getBinary () const
|
||||
{
|
||||
if (_args.size ())
|
||||
if (!_args.empty())
|
||||
return _args[0].attribute ("raw");
|
||||
|
||||
return "";
|
||||
|
@ -743,14 +743,14 @@ const std::string CLI2::dump (const std::string& title) const
|
|||
|
||||
out << '\n';
|
||||
|
||||
if (_args.size ())
|
||||
if (!_args.empty())
|
||||
{
|
||||
out << " _args\n";
|
||||
for (const auto& a : _args)
|
||||
out << " " << a.dump () << '\n';
|
||||
}
|
||||
|
||||
if (_id_ranges.size ())
|
||||
if (!_id_ranges.empty())
|
||||
{
|
||||
out << " _id_ranges\n ";
|
||||
for (const auto& range : _id_ranges)
|
||||
|
@ -764,7 +764,7 @@ const std::string CLI2::dump (const std::string& title) const
|
|||
out << '\n';
|
||||
}
|
||||
|
||||
if (_uuid_list.size ())
|
||||
if (!_uuid_list.empty())
|
||||
{
|
||||
out << " _uuid_list\n ";
|
||||
for (const auto& uuid : _uuid_list)
|
||||
|
@ -1229,7 +1229,7 @@ void CLI2::desugarFilterAttributes ()
|
|||
|
||||
// An unquoted string, while equivalent to an empty string, doesn't cause
|
||||
// an operand shortage in eval.
|
||||
if (value == "")
|
||||
if (value.empty())
|
||||
value = "''";
|
||||
|
||||
// Some values are expressions, which need to be lexed. The best way to
|
||||
|
@ -1278,7 +1278,7 @@ void CLI2::desugarFilterAttributes ()
|
|||
rhs.tag ("FILTER");
|
||||
|
||||
// Special case for '<name>:<value>'.
|
||||
if (mod == "")
|
||||
if (mod.empty())
|
||||
{
|
||||
op.attribute ("raw", "=");
|
||||
rhs.attribute ("raw", value);
|
||||
|
@ -1515,7 +1515,7 @@ void CLI2::findIDs ()
|
|||
// listed as a MODIFICATION.
|
||||
std::string command = getCommand ();
|
||||
|
||||
if (! _id_ranges.size () &&
|
||||
if (_id_ranges.empty() &&
|
||||
filterCount == 0 &&
|
||||
command != "add" &&
|
||||
command != "log")
|
||||
|
@ -1606,7 +1606,7 @@ void CLI2::findUUIDs ()
|
|||
}
|
||||
}
|
||||
|
||||
if (! _uuid_list.size ())
|
||||
if (_uuid_list.empty())
|
||||
{
|
||||
for (auto& a : _args)
|
||||
{
|
||||
|
@ -1655,8 +1655,8 @@ void CLI2::insertIDExpr ()
|
|||
{
|
||||
// Skip completely if no ID/UUID was found. This is because below, '(' and ')'
|
||||
// are inserted regardless of list size.
|
||||
if (! _id_ranges.size () &&
|
||||
! _uuid_list.size ())
|
||||
if (_id_ranges.empty() &&
|
||||
_uuid_list.empty())
|
||||
return;
|
||||
|
||||
// Find the *first* occurence of lexer type set/number/uuid, and replace it
|
||||
|
@ -1759,8 +1759,8 @@ void CLI2::insertIDExpr ()
|
|||
}
|
||||
|
||||
// Combine the ID and UUID sections with 'or'.
|
||||
if (_id_ranges.size () &&
|
||||
_uuid_list.size ())
|
||||
if (!_id_ranges.empty() &&
|
||||
!_uuid_list.empty())
|
||||
reconstructed.push_back (opOr);
|
||||
|
||||
// Add all UUID list items.
|
||||
|
@ -2033,7 +2033,7 @@ void CLI2::defaultCommand ()
|
|||
{
|
||||
// Apply overrides, if any.
|
||||
std::string defaultCommand = Context::getContext ().config.get ("default.command");
|
||||
if (defaultCommand != "")
|
||||
if (!defaultCommand.empty())
|
||||
{
|
||||
// Modify _args, _original_args to be:
|
||||
// <args0> [<def0> ...] <args1> [...]
|
||||
|
|
|
@ -779,7 +779,7 @@ int Context::dispatch (std::string &out)
|
|||
{
|
||||
// Autocomplete args against keywords.
|
||||
std::string command = cli2.getCommand ();
|
||||
if (command != "")
|
||||
if (!command.empty())
|
||||
{
|
||||
updateXtermTitle ();
|
||||
updateVerbosity ();
|
||||
|
@ -1026,7 +1026,7 @@ void Context::getLimits (int& rows, int& lines)
|
|||
|
||||
// This is an integer specified as a filter (limit:10).
|
||||
auto limit = config.get ("limit");
|
||||
if (limit != "")
|
||||
if (!limit.empty())
|
||||
{
|
||||
if (limit == "page")
|
||||
{
|
||||
|
@ -1106,7 +1106,7 @@ void Context::staticInitialization ()
|
|||
void Context::createDefaultConfig ()
|
||||
{
|
||||
// Do we need to create a default rc?
|
||||
if (rc_file._data != "" && ! rc_file.exists ())
|
||||
if (!rc_file._data.empty() && ! rc_file.exists ())
|
||||
{
|
||||
if (config.getBoolean ("confirmation") &&
|
||||
! confirm ( format ("A configuration file could not be found in {1}\n\nWould you like a sample {2} created, so Taskwarrior can proceed?", home_dir, rc_file._data)))
|
||||
|
@ -1240,7 +1240,7 @@ void Context::updateXtermTitle ()
|
|||
void Context::updateVerbosity ()
|
||||
{
|
||||
auto command = cli2.getCommand ();
|
||||
if (command != "" &&
|
||||
if (!command.empty() &&
|
||||
command[0] == '_')
|
||||
{
|
||||
verbosity = {"nothing"};
|
||||
|
|
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 ();
|
||||
|
||||
|
|
14
src/Eval.cpp
14
src/Eval.cpp
|
@ -218,7 +218,7 @@ void Eval::evaluatePostfixStack (
|
|||
const std::vector <std::pair <std::string, Lexer::Type>>& tokens,
|
||||
Variant& result) const
|
||||
{
|
||||
if (tokens.size () == 0)
|
||||
if (tokens.empty())
|
||||
throw std::string ("No expression to evaluate.");
|
||||
|
||||
// This is stack used by the postfix evaluator.
|
||||
|
@ -229,7 +229,7 @@ void Eval::evaluatePostfixStack (
|
|||
if (token.second == Lexer::Type::op &&
|
||||
token.first == "!")
|
||||
{
|
||||
if (values.size () < 1)
|
||||
if (values.empty())
|
||||
throw std::string ("The expression could not be evaluated.");
|
||||
|
||||
Variant right = values.back ();
|
||||
|
@ -242,7 +242,7 @@ void Eval::evaluatePostfixStack (
|
|||
else if (token.second == Lexer::Type::op &&
|
||||
token.first == "_neg_")
|
||||
{
|
||||
if (values.size () < 1)
|
||||
if (values.empty())
|
||||
throw std::string ("The expression could not be evaluated.");
|
||||
|
||||
Variant right = values.back ();
|
||||
|
@ -755,14 +755,14 @@ void Eval::infixToPostfix (
|
|||
else if (token.second == Lexer::Type::op &&
|
||||
token.first == ")")
|
||||
{
|
||||
while (op_stack.size () &&
|
||||
while (!op_stack.empty() &&
|
||||
op_stack.back ().first != "(")
|
||||
{
|
||||
postfix.push_back (op_stack.back ());
|
||||
op_stack.pop_back ();
|
||||
}
|
||||
|
||||
if (op_stack.size ())
|
||||
if (!op_stack.empty())
|
||||
op_stack.pop_back ();
|
||||
else
|
||||
throw std::string ("Mismatched parentheses in expression");
|
||||
|
@ -773,7 +773,7 @@ void Eval::infixToPostfix (
|
|||
char type2;
|
||||
unsigned int precedence2;
|
||||
char associativity2;
|
||||
while (op_stack.size () > 0 &&
|
||||
while (!op_stack.empty() &&
|
||||
identifyOperator (op_stack.back ().first, type2, precedence2, associativity2) &&
|
||||
((associativity == 'l' && precedence <= precedence2) ||
|
||||
(associativity == 'r' && precedence < precedence2)))
|
||||
|
@ -790,7 +790,7 @@ void Eval::infixToPostfix (
|
|||
}
|
||||
}
|
||||
|
||||
while (op_stack.size ())
|
||||
while (!op_stack.empty())
|
||||
{
|
||||
if (op_stack.back ().first == "(" ||
|
||||
op_stack.back ().first == ")")
|
||||
|
|
|
@ -66,7 +66,7 @@ void Filter::subset (const std::vector <Task>& input, std::vector <Task>& output
|
|||
if (a.hasTag ("FILTER"))
|
||||
precompiled.push_back (std::pair <std::string, Lexer::Type> (a.getToken (), a._lextype));
|
||||
|
||||
if (precompiled.size ())
|
||||
if (!precompiled.empty())
|
||||
{
|
||||
Eval eval;
|
||||
eval.addSource (domSource);
|
||||
|
@ -112,7 +112,7 @@ void Filter::subset (std::vector <Task>& output)
|
|||
// Shortcut indicates that only pending.data needs to be loaded.
|
||||
bool shortcut = false;
|
||||
|
||||
if (precompiled.size ())
|
||||
if (!precompiled.empty())
|
||||
{
|
||||
Timer timer_pending;
|
||||
auto pending = Context::getContext ().tdb2.pending.get_tasks ();
|
||||
|
|
|
@ -135,7 +135,7 @@ void Hooks::onLaunch () const
|
|||
Timer timer;
|
||||
|
||||
std::vector <std::string> matchingScripts = scripts ("on-launch");
|
||||
if (matchingScripts.size ())
|
||||
if (!matchingScripts.empty())
|
||||
{
|
||||
for (auto& script : matchingScripts)
|
||||
{
|
||||
|
@ -188,7 +188,7 @@ void Hooks::onExit () const
|
|||
Timer timer;
|
||||
|
||||
std::vector <std::string> matchingScripts = scripts ("on-exit");
|
||||
if (matchingScripts.size ())
|
||||
if (!matchingScripts.empty())
|
||||
{
|
||||
// Get the set of changed tasks.
|
||||
std::vector <Task> tasks;
|
||||
|
@ -250,7 +250,7 @@ void Hooks::onAdd (Task& task) const
|
|||
Timer timer;
|
||||
|
||||
std::vector <std::string> matchingScripts = scripts ("on-add");
|
||||
if (matchingScripts.size ())
|
||||
if (!matchingScripts.empty())
|
||||
{
|
||||
// Convert task to a vector of strings.
|
||||
std::vector <std::string> input;
|
||||
|
@ -316,7 +316,7 @@ void Hooks::onModify (const Task& before, Task& after) const
|
|||
Timer timer;
|
||||
|
||||
std::vector <std::string> matchingScripts = scripts ("on-modify");
|
||||
if (matchingScripts.size ())
|
||||
if (!matchingScripts.empty())
|
||||
{
|
||||
// Convert vector of tasks to a vector of strings.
|
||||
std::vector <std::string> input;
|
||||
|
@ -601,7 +601,7 @@ int Hooks::callHookScript (
|
|||
{
|
||||
Context::getContext ().debug ("Hook: output");
|
||||
for (const auto& i : output)
|
||||
if (i != "")
|
||||
if (!i.empty())
|
||||
Context::getContext ().debug (" " + i);
|
||||
|
||||
Context::getContext ().debug (format ("Hook: Completed with status {1}", status));
|
||||
|
|
24
src/TDB2.cpp
24
src/TDB2.cpp
|
@ -123,7 +123,7 @@ bool TF2::get (const std::string& uuid, Task& task)
|
|||
if (! _loaded_tasks)
|
||||
load_tasks ();
|
||||
|
||||
if (_tasks_map.size () > 0 && uuid.size () == 36)
|
||||
if (!_tasks_map.empty() && uuid.size () == 36)
|
||||
{
|
||||
// Fast lookup, same result as below. Only used during "task import".
|
||||
auto i = _tasks_map.find (uuid);
|
||||
|
@ -263,8 +263,8 @@ void TF2::commit ()
|
|||
if (_dirty)
|
||||
{
|
||||
// Special case: added but no modified means just append to the file.
|
||||
if (!_modified_tasks.size () && !_purged_tasks.size () &&
|
||||
(_added_tasks.size () || _added_lines.size ()))
|
||||
if (_modified_tasks.empty() && _purged_tasks.empty() &&
|
||||
(!_added_tasks.empty() || !_added_lines.empty()))
|
||||
{
|
||||
if (_file.open ())
|
||||
{
|
||||
|
@ -920,7 +920,7 @@ void TDB2::revert_pending (
|
|||
Context::getContext ().debug ("TDB::revert - task found in pending.data");
|
||||
|
||||
// Either revert if there was a prior state, or remove the task.
|
||||
if (prior != "")
|
||||
if (!prior.empty())
|
||||
{
|
||||
*task = prior;
|
||||
std::cout << STRING_TDB2_REVERTED << '\n';
|
||||
|
@ -953,7 +953,7 @@ void TDB2::revert_completed (
|
|||
Context::getContext ().debug ("TDB::revert_completed - task found in completed.data");
|
||||
|
||||
// Either revert if there was a prior state, or remove the task.
|
||||
if (prior != "")
|
||||
if (!prior.empty())
|
||||
{
|
||||
*task = prior;
|
||||
if (task->find ("status:\"pending\"") != std::string::npos ||
|
||||
|
@ -1003,7 +1003,7 @@ void TDB2::revert_backlog (
|
|||
found = true;
|
||||
|
||||
// If this is a new task (no prior), then just remove it from the backlog.
|
||||
if (current != "" && prior == "")
|
||||
if (!current.empty() && prior.empty())
|
||||
{
|
||||
// Yes, this is what is needed, when you want to erase using a reverse
|
||||
// iterator.
|
||||
|
@ -1055,7 +1055,7 @@ void TDB2::show_diff (
|
|||
|
||||
Task after (current);
|
||||
|
||||
if (prior != "")
|
||||
if (!prior.empty())
|
||||
{
|
||||
Task before (prior);
|
||||
|
||||
|
@ -1084,7 +1084,7 @@ void TDB2::show_diff (
|
|||
std::string priorValue = before.get (att.first);
|
||||
std::string currentValue = after.get (att.first);
|
||||
|
||||
if (currentValue != "")
|
||||
if (!currentValue.empty())
|
||||
{
|
||||
row = view.addRow ();
|
||||
view.set (row, 0, att.first);
|
||||
|
@ -1135,7 +1135,7 @@ void TDB2::show_diff (
|
|||
{
|
||||
// Create reference tasks.
|
||||
Task before;
|
||||
if (prior != "")
|
||||
if (!prior.empty())
|
||||
before.parse (prior);
|
||||
|
||||
Task after (current);
|
||||
|
@ -1199,7 +1199,7 @@ void TDB2::show_diff (
|
|||
}
|
||||
|
||||
// Attribute deleted.
|
||||
else if (before_att != "" && after_att == "")
|
||||
else if (!before_att.empty() && after_att.empty())
|
||||
{
|
||||
row = view.addRow ();
|
||||
view.set (row, 0, '-' + a + ':', color_red);
|
||||
|
@ -1210,7 +1210,7 @@ void TDB2::show_diff (
|
|||
}
|
||||
|
||||
// Attribute added.
|
||||
else if (before_att == "" && after_att != "")
|
||||
else if (before_att.empty() && !after_att.empty())
|
||||
{
|
||||
row = view.addRow ();
|
||||
view.set (row, 0, '-' + a + ':', color_red);
|
||||
|
@ -1417,7 +1417,7 @@ const std::vector <Task> TDB2::children (Task& task)
|
|||
std::string TDB2::uuid (int id)
|
||||
{
|
||||
std::string result = pending.uuid (id);
|
||||
if (result == "")
|
||||
if (result.empty())
|
||||
result = completed.uuid (id);
|
||||
|
||||
return result;
|
||||
|
|
|
@ -156,7 +156,7 @@ void TLSClient::init (
|
|||
throw format ("Bad System Trust. {1}", gnutls_strerror (ret)); // All
|
||||
#endif
|
||||
|
||||
if (_ca != "")
|
||||
if (!_ca.empty())
|
||||
{
|
||||
// The gnutls_certificate_set_x509_key_file call returns number of
|
||||
// certificates parsed on success (including 0, when no certificate was
|
||||
|
@ -170,8 +170,8 @@ void TLSClient::init (
|
|||
}
|
||||
|
||||
// TODO This may need 0x030111 protection.
|
||||
if (_cert != "" &&
|
||||
_key != "" &&
|
||||
if (!_cert.empty() &&
|
||||
!_key.empty() &&
|
||||
(ret = gnutls_certificate_set_x509_key_file (_credentials, _cert.c_str (), _key.c_str (), GNUTLS_X509_FMT_PEM)) < 0) // 3.1.11
|
||||
throw format ("Bad client CERT/KEY file. {1}", gnutls_strerror (ret)); // All
|
||||
|
||||
|
@ -189,7 +189,7 @@ void TLSClient::init (
|
|||
throw format ("TLS client init error. {1}", gnutls_strerror (ret)); // All
|
||||
|
||||
// Use default priorities unless overridden.
|
||||
if (_ciphers == "")
|
||||
if (_ciphers.empty())
|
||||
_ciphers = "NORMAL";
|
||||
|
||||
const char *err;
|
||||
|
|
68
src/Task.cpp
68
src/Task.cpp
|
@ -653,7 +653,7 @@ void Task::parseJSON (const json::object* root_obj)
|
|||
{
|
||||
// If the attribute is a recognized column.
|
||||
std::string type = Task::attributes[i.first];
|
||||
if (type != "")
|
||||
if (!type.empty())
|
||||
{
|
||||
// Any specified id is ignored.
|
||||
if (i.first == "id")
|
||||
|
@ -678,7 +678,7 @@ void Task::parseJSON (const json::object* root_obj)
|
|||
auto text = i.second->dump ();
|
||||
Lexer::dequote (text);
|
||||
Datetime d (text);
|
||||
set (i.first, text == "" ? "" : d.toEpochString ());
|
||||
set (i.first, text.empty() ? "" : d.toEpochString ());
|
||||
}
|
||||
|
||||
// Tags are an array of JSON strings.
|
||||
|
@ -840,11 +840,11 @@ std::string Task::composeF4 () const
|
|||
{
|
||||
// Orphans have no type, treat as string.
|
||||
std::string type = Task::attributes[it.first];
|
||||
if (type == "")
|
||||
if (type.empty())
|
||||
type = "string";
|
||||
|
||||
// If there is a value.
|
||||
if (it.second != "")
|
||||
if (!it.second.empty())
|
||||
{
|
||||
ff4 += (first ? "" : " ");
|
||||
ff4 += it.first;
|
||||
|
@ -883,14 +883,14 @@ std::string Task::composeJSON (bool decorate /*= false*/) const
|
|||
continue;
|
||||
|
||||
// If value is an empty string, do not ever output it
|
||||
if (i.second == "")
|
||||
if (i.second.empty())
|
||||
continue;
|
||||
|
||||
if (attributes_written)
|
||||
out << ',';
|
||||
|
||||
std::string type = Task::attributes[i.first];
|
||||
if (type == "")
|
||||
if (type.empty())
|
||||
type = "string";
|
||||
|
||||
// Date fields are written as ISO 8601.
|
||||
|
@ -901,7 +901,7 @@ std::string Task::composeJSON (bool decorate /*= false*/) const
|
|||
<< (i.first == "modification" ? "modified" : i.first)
|
||||
<< "\":\""
|
||||
// Date was deleted, do not export parsed empty string
|
||||
<< (i.second == "" ? "" : d.toISO ())
|
||||
<< (i.second.empty() ? "" : d.toISO ())
|
||||
<< '"';
|
||||
|
||||
++attributes_written;
|
||||
|
@ -1124,7 +1124,7 @@ void Task::addDependency (int depid)
|
|||
{
|
||||
// Check that id is resolvable.
|
||||
std::string uuid = Context::getContext ().tdb2.pending.uuid (depid);
|
||||
if (uuid == "")
|
||||
if (uuid.empty())
|
||||
throw format ("Could not create a dependency on task {1} - not found.", depid);
|
||||
|
||||
std::string depends = get ("depends");
|
||||
|
@ -1146,7 +1146,7 @@ void Task::addDependency (const std::string& uuid)
|
|||
|
||||
// Store the dependency.
|
||||
std::string depends = get ("depends");
|
||||
if (depends != "")
|
||||
if (!depends.empty())
|
||||
{
|
||||
// Check for extant dependency.
|
||||
if (depends.find (uuid) == std::string::npos)
|
||||
|
@ -1193,7 +1193,7 @@ void Task::removeDependency (int id)
|
|||
{
|
||||
std::string depends = get ("depends");
|
||||
std::string uuid = Context::getContext ().tdb2.pending.uuid (id);
|
||||
if (uuid != "" && depends.find (uuid) != std::string::npos)
|
||||
if (!uuid.empty() && depends.find (uuid) != std::string::npos)
|
||||
removeDependency (uuid);
|
||||
else
|
||||
throw format ("Could not delete a dependency on task {1} - not found.", id);
|
||||
|
@ -1491,13 +1491,13 @@ void Task::substitute (
|
|||
void Task::validate (bool applyDefault /* = true */)
|
||||
{
|
||||
Task::status status = Task::pending;
|
||||
if (get ("status") != "")
|
||||
if (!get ("status").empty())
|
||||
status = getStatus ();
|
||||
|
||||
// 1) Provide missing attributes where possible
|
||||
// Provide a UUID if necessary. Validate if present.
|
||||
std::string uid = get ("uuid");
|
||||
if (has ("uuid") && uid != "")
|
||||
if (has ("uuid") && !uid.empty())
|
||||
{
|
||||
Lexer lex (uid);
|
||||
std::string token;
|
||||
|
@ -1513,8 +1513,8 @@ void Task::validate (bool applyDefault /* = true */)
|
|||
if (status == Task::pending &&
|
||||
has ("due") &&
|
||||
has ("recur") &&
|
||||
(! has ("parent") || get ("parent") == "") &&
|
||||
(! has ("template") || get ("template") == ""))
|
||||
(! has ("parent") || get ("parent").empty()) &&
|
||||
(! has ("template") || get ("template").empty()))
|
||||
{
|
||||
status = Task::recurring;
|
||||
}
|
||||
|
@ -1532,16 +1532,16 @@ void Task::validate (bool applyDefault /* = true */)
|
|||
// Tasks with a wait: date get a special status.
|
||||
else if (status == Task::pending &&
|
||||
has ("wait") &&
|
||||
get ("wait") != "")
|
||||
!get ("wait").empty())
|
||||
status = Task::waiting;
|
||||
|
||||
// By default, tasks are pending.
|
||||
else if (! has ("status") || get ("status") == "")
|
||||
else if (! has ("status") || get ("status").empty())
|
||||
status = Task::pending;
|
||||
|
||||
// Default to 'periodic' type recurrence.
|
||||
if (status == Task::recurring &&
|
||||
(! has ("rtype") || get ("rtype") == ""))
|
||||
(! has ("rtype") || get ("rtype").empty()))
|
||||
{
|
||||
set ("rtype", "periodic");
|
||||
}
|
||||
|
@ -1551,26 +1551,26 @@ void Task::validate (bool applyDefault /* = true */)
|
|||
|
||||
#ifdef PRODUCT_TASKWARRIOR
|
||||
// Provide an entry date unless user already specified one.
|
||||
if (! has ("entry") || get ("entry") == "")
|
||||
if (! has ("entry") || get ("entry").empty())
|
||||
setAsNow ("entry");
|
||||
|
||||
// Completed tasks need an end date, so inherit the entry date.
|
||||
if ((status == Task::completed || status == Task::deleted) &&
|
||||
(! has ("end") || get ("end") == ""))
|
||||
(! has ("end") || get ("end").empty()))
|
||||
setAsNow ("end");
|
||||
|
||||
// Pending tasks cannot have an end date, remove if present
|
||||
if ((status == Task::pending) && (get ("end") != ""))
|
||||
if ((status == Task::pending) && (!get ("end").empty()))
|
||||
remove ("end");
|
||||
|
||||
// Provide an entry date unless user already specified one.
|
||||
if (! has ("modified") || get ("modified") == "")
|
||||
if (! has ("modified") || get ("modified").empty())
|
||||
setAsNow ("modified");
|
||||
|
||||
if (applyDefault && (! has ("parent") || get ("parent") == ""))
|
||||
if (applyDefault && (! has ("parent") || get ("parent").empty()))
|
||||
{
|
||||
// Override with default.project, if not specified.
|
||||
if (Task::defaultProject != "" &&
|
||||
if (!Task::defaultProject.empty() &&
|
||||
! has ("project"))
|
||||
{
|
||||
if (Context::getContext ().columns["project"]->validate (Task::defaultProject))
|
||||
|
@ -1578,7 +1578,7 @@ void Task::validate (bool applyDefault /* = true */)
|
|||
}
|
||||
|
||||
// Override with default.due, if not specified.
|
||||
if (Task::defaultDue != "" &&
|
||||
if (!Task::defaultDue.empty() &&
|
||||
! has ("due"))
|
||||
{
|
||||
if (Context::getContext ().columns["due"]->validate (Task::defaultDue))
|
||||
|
@ -1592,7 +1592,7 @@ void Task::validate (bool applyDefault /* = true */)
|
|||
}
|
||||
|
||||
// Override with default.scheduled, if not specified.
|
||||
if (Task::defaultScheduled != "" &&
|
||||
if (!Task::defaultScheduled.empty() &&
|
||||
! has ("scheduled"))
|
||||
{
|
||||
if (Context::getContext ().columns["scheduled"]->validate (Task::defaultScheduled))
|
||||
|
@ -1620,7 +1620,7 @@ void Task::validate (bool applyDefault /* = true */)
|
|||
}
|
||||
}
|
||||
|
||||
if (udas.size ())
|
||||
if (!udas.empty())
|
||||
{
|
||||
// For each of those, setup the default value on the task now,
|
||||
// of course only if we don't have one on the command line already
|
||||
|
@ -1629,7 +1629,7 @@ void Task::validate (bool applyDefault /* = true */)
|
|||
std::string defVal= Context::getContext ().config.get ("uda." + uda + ".default");
|
||||
|
||||
// If the default is empty, or we already have a value, skip it
|
||||
if (defVal != "" && get (uda) == "")
|
||||
if (!defVal.empty() && get (uda).empty())
|
||||
set (uda, defVal);
|
||||
}
|
||||
}
|
||||
|
@ -1652,18 +1652,18 @@ void Task::validate (bool applyDefault /* = true */)
|
|||
// There is no fixing a missing description.
|
||||
if (! has ("description"))
|
||||
throw std::string ("A task must have a description.");
|
||||
else if (get ("description") == "")
|
||||
else if (get ("description").empty())
|
||||
throw std::string ("Cannot add a task that is blank.");
|
||||
|
||||
// Cannot have a recur frequency with no due date - when would it recur?
|
||||
if (has ("recur") && (! has ("due") || get ("due") == ""))
|
||||
if (has ("recur") && (! has ("due") || get ("due").empty()))
|
||||
throw std::string ("A recurring task must also have a 'due' date.");
|
||||
|
||||
// Recur durations must be valid.
|
||||
if (has ("recur"))
|
||||
{
|
||||
std::string value = get ("recur");
|
||||
if (value != "")
|
||||
if (!value.empty())
|
||||
{
|
||||
Duration p;
|
||||
std::string::size_type i = 0;
|
||||
|
@ -2074,13 +2074,13 @@ void Task::modify (modType type, bool text_required /* = false */)
|
|||
// 'value' requires eval.
|
||||
std::string name = a.attribute ("canonical");
|
||||
std::string value = a.attribute ("value");
|
||||
if (value == "" ||
|
||||
if (value.empty() ||
|
||||
value == "''" ||
|
||||
value == "\"\"")
|
||||
{
|
||||
// ::composeF4 will skip if the value is blank, but the presence of
|
||||
// the attribute will prevent ::validate from applying defaults.
|
||||
if ((has (name) && get (name) != "") ||
|
||||
if ((has (name) && !get (name).empty()) ||
|
||||
(name == "due" && Context::getContext ().config.has ("default.due")) ||
|
||||
(name == "scheduled" && Context::getContext ().config.has ("default.scheduled")) ||
|
||||
(name == "project" && Context::getContext ().config.has ("default.project")))
|
||||
|
@ -2155,7 +2155,7 @@ void Task::modify (modType type, bool text_required /* = false */)
|
|||
// Unknown args are accumulated as though they were WORDs.
|
||||
else
|
||||
{
|
||||
if (text != "")
|
||||
if (!text.empty())
|
||||
text += ' ';
|
||||
text += a.attribute ("raw");
|
||||
}
|
||||
|
@ -2164,7 +2164,7 @@ void Task::modify (modType type, bool text_required /* = false */)
|
|||
|
||||
// Task::modType determines what happens to the WORD arguments, if there are
|
||||
// any.
|
||||
if (text != "")
|
||||
if (!text.empty())
|
||||
{
|
||||
Lexer::dequote (text);
|
||||
|
||||
|
|
|
@ -1900,7 +1900,7 @@ void Variant::cast (const enum type new_type)
|
|||
break;
|
||||
}
|
||||
|
||||
if (dateFormat != "")
|
||||
if (!dateFormat.empty())
|
||||
{
|
||||
_date = Datetime (_string, dateFormat).toEpoch ();
|
||||
break;
|
||||
|
@ -1961,7 +1961,7 @@ bool Variant::trivial () const
|
|||
{
|
||||
return (_type == type_integer && _integer == 0) ||
|
||||
(_type == type_real && _real == 0.0) ||
|
||||
(_type == type_string && _string == "") ||
|
||||
(_type == type_string && _string.empty()) ||
|
||||
(_type == type_date && _date == 0) ||
|
||||
(_type == type_duration && _duration == 0);
|
||||
}
|
||||
|
|
|
@ -327,7 +327,7 @@ std::string ViewTask::render (std::vector <Task>& data, std::vector <int>& seque
|
|||
// Listing breaks are simply blank lines inserted when a column value
|
||||
// changes.
|
||||
if (s > 0 &&
|
||||
_breaks.size () > 0)
|
||||
!_breaks.empty())
|
||||
{
|
||||
for (auto& b : _breaks)
|
||||
{
|
||||
|
|
|
@ -58,7 +58,7 @@ std::vector <Task> dependencyGetBlocking (const Task& task)
|
|||
auto depends = task.get ("depends");
|
||||
|
||||
std::vector <Task> blocking;
|
||||
if (depends != "")
|
||||
if (!depends.empty())
|
||||
for (auto& it : Context::getContext ().tdb2.pending.get_tasks ())
|
||||
if (it.getStatus () != Task::completed &&
|
||||
it.getStatus () != Task::deleted &&
|
||||
|
@ -153,7 +153,7 @@ void dependencyChainOnComplete (Task& task)
|
|||
auto blocking = dependencyGetBlocking (task);
|
||||
|
||||
// If the task is anything but the tail end of a dependency chain.
|
||||
if (blocking.size ())
|
||||
if (!blocking.empty())
|
||||
{
|
||||
auto blocked = dependencyGetBlocked (task);
|
||||
|
||||
|
@ -168,7 +168,7 @@ void dependencyChainOnComplete (Task& task)
|
|||
}
|
||||
|
||||
// If there are both blocking and blocked tasks, the chain is broken.
|
||||
if (blocked.size ())
|
||||
if (!blocked.empty())
|
||||
{
|
||||
if (Context::getContext ().config.getBoolean ("dependency.reminder"))
|
||||
{
|
||||
|
@ -211,7 +211,7 @@ void dependencyChainOnStart (Task& task)
|
|||
|
||||
// If the task is anything but the tail end of a dependency chain, nag about
|
||||
// broken chain.
|
||||
if (blocking.size ())
|
||||
if (!blocking.empty())
|
||||
{
|
||||
std::cout << format (STRING_DEPEND_BLOCKED, task.identifier ())
|
||||
<< '\n';
|
||||
|
|
|
@ -208,8 +208,8 @@ std::string taskInfoDifferences (
|
|||
if (name != "uuid" &&
|
||||
name != "modified" &&
|
||||
before.get (name) != after.get (name) &&
|
||||
before.get (name) != "" &&
|
||||
after.get (name) != "")
|
||||
!before.get (name).empty() &&
|
||||
!after.get (name).empty())
|
||||
{
|
||||
if (name == "depends")
|
||||
{
|
||||
|
@ -245,10 +245,10 @@ std::string renderAttribute (const std::string& name, const std::string& value,
|
|||
Column* col = Context::getContext ().columns[name];
|
||||
if (col &&
|
||||
col->type () == "date" &&
|
||||
value != "")
|
||||
!value.empty())
|
||||
{
|
||||
Datetime d ((time_t)strtol (value.c_str (), nullptr, 10));
|
||||
if (format == "")
|
||||
if (format.empty())
|
||||
return d.toString (Context::getContext ().config.get ("dateformat"));
|
||||
|
||||
return d.toString (format);
|
||||
|
@ -379,7 +379,7 @@ void feedback_unblocked (const Task& task)
|
|||
for (auto& i : blocked)
|
||||
{
|
||||
auto blocking = dependencyGetBlocking (i);
|
||||
if (blocking.size () == 0)
|
||||
if (blocking.empty())
|
||||
{
|
||||
if (i.id)
|
||||
std::cout << format ("Unblocked {1} '{2}'.",
|
||||
|
@ -402,7 +402,7 @@ void feedback_unblocked (const Task& task)
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
void feedback_backlog ()
|
||||
{
|
||||
if (Context::getContext ().config.get ("taskd.server") != "" &&
|
||||
if (!Context::getContext ().config.get ("taskd.server").empty() &&
|
||||
Context::getContext ().verbose ("sync"))
|
||||
{
|
||||
int count = 0;
|
||||
|
@ -423,7 +423,7 @@ std::string onProjectChange (Task& task, bool scope /* = true */)
|
|||
std::stringstream msg;
|
||||
std::string project = task.get ("project");
|
||||
|
||||
if (project != "")
|
||||
if (!project.empty())
|
||||
{
|
||||
if (scope)
|
||||
msg << format ("The project '{1}' has changed.", project)
|
||||
|
|
|
@ -116,7 +116,7 @@ std::string legacyCheckForDeprecatedVariables ()
|
|||
}
|
||||
|
||||
std::stringstream out;
|
||||
if (deprecated.size ())
|
||||
if (!deprecated.empty())
|
||||
{
|
||||
out << "Your .taskrc file contains variables that are deprecated:\n";
|
||||
|
||||
|
@ -149,7 +149,7 @@ std::string legacyCheckForDeprecatedColumns ()
|
|||
std::stringstream out;
|
||||
out << "\n";
|
||||
|
||||
if (deprecated.size ())
|
||||
if (!deprecated.empty())
|
||||
{
|
||||
out << "Your .taskrc file contains reports with deprecated columns. Please check for entry_time, start_time or end_time in:\n";
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ bool nag (Task& task)
|
|||
return false;
|
||||
|
||||
auto msg = Context::getContext ().config.get ("nag");
|
||||
if (msg != "")
|
||||
if (!msg.empty())
|
||||
{
|
||||
// Scan all pending, non-recurring tasks.
|
||||
auto pending = Context::getContext ().tdb2.pending.get_tasks ();
|
||||
|
|
|
@ -155,7 +155,7 @@ bool generateDueDates (Task& parent, std::vector <Datetime>& allDue)
|
|||
|
||||
bool specificEnd = false;
|
||||
Datetime until;
|
||||
if (parent.get ("until") != "")
|
||||
if (!parent.get ("until").empty())
|
||||
{
|
||||
until = Datetime (parent.get ("until"));
|
||||
specificEnd = true;
|
||||
|
@ -371,7 +371,7 @@ void updateRecurrenceMask (Task& task)
|
|||
auto uuid = task.get ("parent");
|
||||
Task parent;
|
||||
|
||||
if (uuid != "" &&
|
||||
if (!uuid.empty() &&
|
||||
Context::getContext ().tdb2.get (uuid, parent))
|
||||
{
|
||||
unsigned int index = strtol (task.get ("imask").c_str (), nullptr, 10);
|
||||
|
|
|
@ -279,7 +279,7 @@ static std::vector <Datetime> generateAllDueDates (const Task& templateTask)
|
|||
|
||||
bool end_in_sight = false;
|
||||
Datetime until;
|
||||
if (templateTask.get ("until") != "")
|
||||
if (!templateTask.get ("until").empty())
|
||||
{
|
||||
until = Datetime (templateTask.get ("until"));
|
||||
end_in_sight = true;
|
||||
|
@ -296,7 +296,7 @@ static std::vector <Datetime> generateAllDueDates (const Task& templateTask)
|
|||
Datetime nextDue = generateNextDueDate (due, recur, lastN);
|
||||
|
||||
// TODO Safety.
|
||||
if (dueDates.size () && dueDates.back () == nextDue)
|
||||
if (!dueDates.empty() && dueDates.back () == nextDue)
|
||||
break;
|
||||
|
||||
// If nextDue > until, it means there are no more tasks to generate, so
|
||||
|
|
20
src/sort.cpp
20
src/sort.cpp
|
@ -55,7 +55,7 @@ void sort_tasks (
|
|||
global_keys = split (keys, ',');
|
||||
|
||||
// Only sort if necessary.
|
||||
if (order.size ())
|
||||
if (!order.empty())
|
||||
std::stable_sort (order.begin (), order.end (), sort_compare);
|
||||
|
||||
Context::getContext ().time_sort_us += timer.total_us ();
|
||||
|
@ -68,7 +68,7 @@ void sort_projects (
|
|||
for (auto& project : allProjects)
|
||||
{
|
||||
const std::vector <std::string> parents = extractParents (project.first);
|
||||
if (parents.size ())
|
||||
if (!parents.empty())
|
||||
{
|
||||
// if parents exist: store iterator position of last parent
|
||||
std::list <std::pair <std::string, int>>::iterator parent_pos;
|
||||
|
@ -184,10 +184,10 @@ static bool sort_compare (int left, int right)
|
|||
auto left_string = (*global_data)[left].get_ref (field);
|
||||
auto right_string = (*global_data)[right].get_ref (field);
|
||||
|
||||
if (left_string != "" && right_string == "")
|
||||
if (!left_string.empty() && right_string.empty())
|
||||
return true;
|
||||
|
||||
if (left_string == "" && right_string != "")
|
||||
if (left_string.empty() && !right_string.empty())
|
||||
return false;
|
||||
|
||||
if (left_string == right_string)
|
||||
|
@ -207,10 +207,10 @@ static bool sort_compare (int left, int right)
|
|||
if (left_string == right_string)
|
||||
continue;
|
||||
|
||||
if (left_string == "" && right_string != "")
|
||||
if (left_string.empty() && !right_string.empty())
|
||||
return ascending;
|
||||
|
||||
if (left_string != "" && right_string == "")
|
||||
if (!left_string.empty() && right_string.empty())
|
||||
return !ascending;
|
||||
|
||||
// Sort on the first dependency.
|
||||
|
@ -274,9 +274,9 @@ static bool sort_compare (int left, int right)
|
|||
else
|
||||
{
|
||||
// Empty values are unconditionally last, if no custom order was specified.
|
||||
if (left_string == "")
|
||||
if (left_string.empty())
|
||||
return false;
|
||||
else if (right_string == "")
|
||||
else if (right_string.empty())
|
||||
return true;
|
||||
|
||||
return ascending ? (left_string < right_string)
|
||||
|
@ -289,10 +289,10 @@ static bool sort_compare (int left, int right)
|
|||
auto left_string = (*global_data)[left].get_ref (field);
|
||||
auto right_string = (*global_data)[right].get_ref (field);
|
||||
|
||||
if (left_string != "" && right_string == "")
|
||||
if (!left_string.empty() && right_string.empty())
|
||||
return true;
|
||||
|
||||
if (left_string == "" && right_string != "")
|
||||
if (left_string.empty() && !right_string.empty())
|
||||
return false;
|
||||
|
||||
if (left_string == right_string)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue