diff --git a/src/CLI2.cpp b/src/CLI2.cpp index 408da2933..c5fbd638c 100644 --- a/src/CLI2.cpp +++ b/src/CLI2.cpp @@ -162,7 +162,7 @@ void A2::decompose () if (name == "rc") { - if (!mod.empty()) + if (mod != "") 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.empty()) + if (location != "") 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.empty()) + if (contextName == "") { 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.empty()) + if (contextFilter == "") Context::getContext ().debug ("Context '" + contextName + "' not defined."); else { @@ -635,14 +635,14 @@ void CLI2::prepareFilter () { if (a.hasTag ("FILTER")) { - if (!combined.empty()) + if (combined != "") combined += ' '; combined += a.attribute ("raw"); } } - if (!combined.empty()) + if (combined.size ()) Context::getContext ().footnote (std::string ("Filter: ") + combined); } } @@ -704,7 +704,7 @@ bool CLI2::canonicalize ( //////////////////////////////////////////////////////////////////////////////// std::string CLI2::getBinary () const { - if (!_args.empty()) + if (_args.size ()) return _args[0].attribute ("raw"); return ""; @@ -743,14 +743,14 @@ const std::string CLI2::dump (const std::string& title) const out << '\n'; - if (!_args.empty()) + if (_args.size ()) { out << " _args\n"; for (const auto& a : _args) out << " " << a.dump () << '\n'; } - if (!_id_ranges.empty()) + if (_id_ranges.size ()) { 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.empty()) + if (_uuid_list.size ()) { 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.empty()) + if (value == "") 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 ':'. - if (mod.empty()) + if (mod == "") { 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.empty() && + if (! _id_ranges.size () && filterCount == 0 && command != "add" && command != "log") @@ -1606,7 +1606,7 @@ void CLI2::findUUIDs () } } - if (_uuid_list.empty()) + if (! _uuid_list.size ()) { 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.empty() && - _uuid_list.empty()) + if (! _id_ranges.size () && + ! _uuid_list.size ()) 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.empty() && - !_uuid_list.empty()) + if (_id_ranges.size () && + _uuid_list.size ()) 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.empty()) + if (defaultCommand != "") { // Modify _args, _original_args to be: // [ ...] [...] diff --git a/src/Context.cpp b/src/Context.cpp index 5a650cd8f..05470720e 100644 --- a/src/Context.cpp +++ b/src/Context.cpp @@ -779,7 +779,7 @@ int Context::dispatch (std::string &out) { // Autocomplete args against keywords. std::string command = cli2.getCommand (); - if (!command.empty()) + if (command != "") { 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.empty()) + if (limit != "") { 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.empty() && ! rc_file.exists ()) + if (rc_file._data != "" && ! 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.empty() && + if (command != "" && command[0] == '_') { verbosity = {"nothing"}; diff --git a/src/DOM.cpp b/src/DOM.cpp index 33573be8c..d310f21f9 100644 --- a/src/DOM.cpp +++ b/src/DOM.cpp @@ -63,7 +63,7 @@ bool getDOM (const std::string& name, Variant& value) { // Special case, blank refs cause problems. - if (name.empty()) + if (name == "") 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.empty()) + if (commandLine != "") 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.empty()) + if (commandLine != "") 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.empty()) + if (name == "") return false; // Quickly deal with the most common cases. - if (!task.data.empty() && name == "id") + if (task.data.size () && name == "id") { value = Variant (static_cast (task.id)); return true; } - if (!task.data.empty() && name == "urgency") + if (task.data.size () && 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.empty() && size == 1 && canonical == "id") + if (ref.data.size () && size == 1 && canonical == "id") { value = Variant (static_cast (ref.id)); return true; } - if (!ref.data.empty() && size == 1 && canonical == "urgency") + if (ref.data.size () && 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.empty() && size == 1 && column) + if (ref.data.size () && 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.empty() && size == 2 && canonical == "tags") + if (ref.data.size () && size == 2 && canonical == "tags") { value = Variant (ref.hasTag (elements[1]) ? elements[1] : ""); return true; } - if (!ref.data.empty() && size == 2 && column && column->type () == "date") + if (ref.data.size () && size == 2 && column && column->type () == "date") { Datetime date (ref.get_date (canonical)); if (elements[1] == "year") { value = Variant (static_cast (date.year ())); return true; } @@ -365,13 +365,13 @@ bool getDOM (const std::string& name, const Task& task, Variant& value) } } - if (!ref.data.empty() && size == 2 && elements[0] == "annotations" && elements[1] == "count") + if (ref.data.size () && size == 2 && elements[0] == "annotations" && elements[1] == "count") { value = Variant (static_cast (ref.getAnnotationCount ())); return true; } - if (!ref.data.empty() && size == 3 && elements[0] == "annotations") + if (ref.data.size () && 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.empty() && size == 4 && elements[0] == "annotations" && elements[2] == "entry") + if (ref.data.size () && size == 4 && elements[0] == "annotations" && elements[2] == "entry") { auto annos = ref.getAnnotations (); diff --git a/src/Eval.cpp b/src/Eval.cpp index de278aecb..6afc1e31e 100644 --- a/src/Eval.cpp +++ b/src/Eval.cpp @@ -218,7 +218,7 @@ void Eval::evaluatePostfixStack ( const std::vector >& tokens, Variant& result) const { - if (tokens.empty()) + if (tokens.size () == 0) 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.empty()) + if (values.size () < 1) 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.empty()) + if (values.size () < 1) 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.empty() && + while (op_stack.size () && op_stack.back ().first != "(") { postfix.push_back (op_stack.back ()); op_stack.pop_back (); } - if (!op_stack.empty()) + if (op_stack.size ()) 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.empty() && + while (op_stack.size () > 0 && 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.empty()) + while (op_stack.size ()) { if (op_stack.back ().first == "(" || op_stack.back ().first == ")") diff --git a/src/Filter.cpp b/src/Filter.cpp index 88089ee8d..321b57aee 100644 --- a/src/Filter.cpp +++ b/src/Filter.cpp @@ -66,7 +66,7 @@ void Filter::subset (const std::vector & input, std::vector & output if (a.hasTag ("FILTER")) precompiled.push_back (std::pair (a.getToken (), a._lextype)); - if (!precompiled.empty()) + if (precompiled.size ()) { Eval eval; eval.addSource (domSource); @@ -112,7 +112,7 @@ void Filter::subset (std::vector & output) // Shortcut indicates that only pending.data needs to be loaded. bool shortcut = false; - if (!precompiled.empty()) + if (precompiled.size ()) { Timer timer_pending; auto pending = Context::getContext ().tdb2.pending.get_tasks (); diff --git a/src/Hooks.cpp b/src/Hooks.cpp index 21c25344a..d4f5a3897 100644 --- a/src/Hooks.cpp +++ b/src/Hooks.cpp @@ -135,7 +135,7 @@ void Hooks::onLaunch () const Timer timer; std::vector matchingScripts = scripts ("on-launch"); - if (!matchingScripts.empty()) + if (matchingScripts.size ()) { for (auto& script : matchingScripts) { @@ -188,7 +188,7 @@ void Hooks::onExit () const Timer timer; std::vector matchingScripts = scripts ("on-exit"); - if (!matchingScripts.empty()) + if (matchingScripts.size ()) { // Get the set of changed tasks. std::vector tasks; @@ -250,7 +250,7 @@ void Hooks::onAdd (Task& task) const Timer timer; std::vector matchingScripts = scripts ("on-add"); - if (!matchingScripts.empty()) + if (matchingScripts.size ()) { // Convert task to a vector of strings. std::vector input; @@ -316,7 +316,7 @@ void Hooks::onModify (const Task& before, Task& after) const Timer timer; std::vector matchingScripts = scripts ("on-modify"); - if (!matchingScripts.empty()) + if (matchingScripts.size ()) { // Convert vector of tasks to a vector of strings. std::vector input; @@ -601,7 +601,7 @@ int Hooks::callHookScript ( { Context::getContext ().debug ("Hook: output"); for (const auto& i : output) - if (!i.empty()) + if (i != "") Context::getContext ().debug (" " + i); Context::getContext ().debug (format ("Hook: Completed with status {1}", status)); diff --git a/src/TDB2.cpp b/src/TDB2.cpp index 6d224189f..daeb56688 100644 --- a/src/TDB2.cpp +++ b/src/TDB2.cpp @@ -123,7 +123,7 @@ bool TF2::get (const std::string& uuid, Task& task) if (! _loaded_tasks) load_tasks (); - if (!_tasks_map.empty() && uuid.size () == 36) + if (_tasks_map.size () > 0 && 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.empty() && _purged_tasks.empty() && - (!_added_tasks.empty() || !_added_lines.empty())) + if (!_modified_tasks.size () && !_purged_tasks.size () && + (_added_tasks.size () || _added_lines.size ())) { 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.empty()) + if (prior != "") { *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.empty()) + if (prior != "") { *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.empty() && prior.empty()) + if (current != "" && prior == "") { // 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.empty()) + if (prior != "") { 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.empty()) + if (currentValue != "") { row = view.addRow (); view.set (row, 0, att.first); @@ -1135,7 +1135,7 @@ void TDB2::show_diff ( { // Create reference tasks. Task before; - if (!prior.empty()) + if (prior != "") before.parse (prior); Task after (current); @@ -1199,7 +1199,7 @@ void TDB2::show_diff ( } // Attribute deleted. - else if (!before_att.empty() && after_att.empty()) + else if (before_att != "" && after_att == "") { row = view.addRow (); view.set (row, 0, '-' + a + ':', color_red); @@ -1210,7 +1210,7 @@ void TDB2::show_diff ( } // Attribute added. - else if (before_att.empty() && !after_att.empty()) + else if (before_att == "" && after_att != "") { row = view.addRow (); view.set (row, 0, '-' + a + ':', color_red); @@ -1417,7 +1417,7 @@ const std::vector TDB2::children (Task& task) std::string TDB2::uuid (int id) { std::string result = pending.uuid (id); - if (result.empty()) + if (result == "") result = completed.uuid (id); return result; diff --git a/src/TLSClient.cpp b/src/TLSClient.cpp index 4916e1e81..990a7a9d5 100644 --- a/src/TLSClient.cpp +++ b/src/TLSClient.cpp @@ -156,7 +156,7 @@ void TLSClient::init ( throw format ("Bad System Trust. {1}", gnutls_strerror (ret)); // All #endif - if (!_ca.empty()) + if (_ca != "") { // 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.empty() && - !_key.empty() && + if (_cert != "" && + _key != "" && (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.empty()) + if (_ciphers == "") _ciphers = "NORMAL"; const char *err; diff --git a/src/Task.cpp b/src/Task.cpp index 14a170a9c..646fc02f1 100644 --- a/src/Task.cpp +++ b/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.empty()) + if (type != "") { // 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.empty() ? "" : d.toEpochString ()); + set (i.first, text == "" ? "" : 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.empty()) + if (type == "") type = "string"; // If there is a value. - if (!it.second.empty()) + if (it.second != "") { 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.empty()) + if (i.second == "") continue; if (attributes_written) out << ','; std::string type = Task::attributes[i.first]; - if (type.empty()) + if (type == "") 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.empty() ? "" : d.toISO ()) + << (i.second == "" ? "" : 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.empty()) + if (uuid == "") 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.empty()) + if (depends != "") { // 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.empty() && depends.find (uuid) != std::string::npos) + if (uuid != "" && 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").empty()) + if (get ("status") != "") 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.empty()) + if (has ("uuid") && uid != "") { 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").empty()) && - (! has ("template") || get ("template").empty())) + (! has ("parent") || get ("parent") == "") && + (! has ("template") || get ("template") == "")) { 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").empty()) + get ("wait") != "") status = Task::waiting; // By default, tasks are pending. - else if (! has ("status") || get ("status").empty()) + else if (! has ("status") || get ("status") == "") status = Task::pending; // Default to 'periodic' type recurrence. if (status == Task::recurring && - (! has ("rtype") || get ("rtype").empty())) + (! has ("rtype") || get ("rtype") == "")) { 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").empty()) + if (! has ("entry") || get ("entry") == "") setAsNow ("entry"); // Completed tasks need an end date, so inherit the entry date. if ((status == Task::completed || status == Task::deleted) && - (! has ("end") || get ("end").empty())) + (! has ("end") || get ("end") == "")) setAsNow ("end"); // Pending tasks cannot have an end date, remove if present - if ((status == Task::pending) && (!get ("end").empty())) + if ((status == Task::pending) && (get ("end") != "")) remove ("end"); // Provide an entry date unless user already specified one. - if (! has ("modified") || get ("modified").empty()) + if (! has ("modified") || get ("modified") == "") setAsNow ("modified"); - if (applyDefault && (! has ("parent") || get ("parent").empty())) + if (applyDefault && (! has ("parent") || get ("parent") == "")) { // Override with default.project, if not specified. - if (!Task::defaultProject.empty() && + if (Task::defaultProject != "" && ! 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.empty() && + if (Task::defaultDue != "" && ! 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.empty() && + if (Task::defaultScheduled != "" && ! has ("scheduled")) { if (Context::getContext ().columns["scheduled"]->validate (Task::defaultScheduled)) @@ -1620,7 +1620,7 @@ void Task::validate (bool applyDefault /* = true */) } } - if (!udas.empty()) + if (udas.size ()) { // 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.empty() && get (uda).empty()) + if (defVal != "" && get (uda) == "") 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").empty()) + else if (get ("description") == "") 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").empty())) + if (has ("recur") && (! has ("due") || get ("due") == "")) 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.empty()) + if (value != "") { 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.empty() || + if (value == "" || 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).empty()) || + if ((has (name) && get (name) != "") || (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.empty()) + if (text != "") 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.empty()) + if (text != "") { Lexer::dequote (text); diff --git a/src/Variant.cpp b/src/Variant.cpp index 133320f55..c9cb54020 100644 --- a/src/Variant.cpp +++ b/src/Variant.cpp @@ -1900,7 +1900,7 @@ void Variant::cast (const enum type new_type) break; } - if (!dateFormat.empty()) + if (dateFormat != "") { _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.empty()) || + (_type == type_string && _string == "") || (_type == type_date && _date == 0) || (_type == type_duration && _duration == 0); } diff --git a/src/ViewTask.cpp b/src/ViewTask.cpp index b39057e1f..29ef5be75 100644 --- a/src/ViewTask.cpp +++ b/src/ViewTask.cpp @@ -327,7 +327,7 @@ std::string ViewTask::render (std::vector & data, std::vector & seque // Listing breaks are simply blank lines inserted when a column value // changes. if (s > 0 && - !_breaks.empty()) + _breaks.size () > 0) { for (auto& b : _breaks) { diff --git a/src/dependency.cpp b/src/dependency.cpp index 26fdf013a..80e1cb874 100644 --- a/src/dependency.cpp +++ b/src/dependency.cpp @@ -58,7 +58,7 @@ std::vector dependencyGetBlocking (const Task& task) auto depends = task.get ("depends"); std::vector blocking; - if (!depends.empty()) + if (depends != "") 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.empty()) + if (blocking.size ()) { 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.empty()) + if (blocked.size ()) { 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.empty()) + if (blocking.size ()) { std::cout << format (STRING_DEPEND_BLOCKED, task.identifier ()) << '\n'; diff --git a/src/feedback.cpp b/src/feedback.cpp index 6cd63e7d2..0e1d793c3 100644 --- a/src/feedback.cpp +++ b/src/feedback.cpp @@ -208,8 +208,8 @@ std::string taskInfoDifferences ( if (name != "uuid" && name != "modified" && before.get (name) != after.get (name) && - !before.get (name).empty() && - !after.get (name).empty()) + before.get (name) != "" && + after.get (name) != "") { 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.empty()) + value != "") { Datetime d ((time_t)strtol (value.c_str (), nullptr, 10)); - if (format.empty()) + if (format == "") 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.empty()) + if (blocking.size () == 0) { 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").empty() && + if (Context::getContext ().config.get ("taskd.server") != "" && 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.empty()) + if (project != "") { if (scope) msg << format ("The project '{1}' has changed.", project) diff --git a/src/legacy.cpp b/src/legacy.cpp index 83438e67e..9ed440e78 100644 --- a/src/legacy.cpp +++ b/src/legacy.cpp @@ -116,7 +116,7 @@ std::string legacyCheckForDeprecatedVariables () } std::stringstream out; - if (!deprecated.empty()) + if (deprecated.size ()) { out << "Your .taskrc file contains variables that are deprecated:\n"; @@ -149,7 +149,7 @@ std::string legacyCheckForDeprecatedColumns () std::stringstream out; out << "\n"; - if (!deprecated.empty()) + if (deprecated.size ()) { out << "Your .taskrc file contains reports with deprecated columns. Please check for entry_time, start_time or end_time in:\n"; diff --git a/src/nag.cpp b/src/nag.cpp index 0c905918c..cf69db8c6 100644 --- a/src/nag.cpp +++ b/src/nag.cpp @@ -41,7 +41,7 @@ bool nag (Task& task) return false; auto msg = Context::getContext ().config.get ("nag"); - if (!msg.empty()) + if (msg != "") { // Scan all pending, non-recurring tasks. auto pending = Context::getContext ().tdb2.pending.get_tasks (); diff --git a/src/recur.cpp b/src/recur.cpp index 479b1e470..c14539c99 100644 --- a/src/recur.cpp +++ b/src/recur.cpp @@ -155,7 +155,7 @@ bool generateDueDates (Task& parent, std::vector & allDue) bool specificEnd = false; Datetime until; - if (!parent.get ("until").empty()) + if (parent.get ("until") != "") { until = Datetime (parent.get ("until")); specificEnd = true; @@ -371,7 +371,7 @@ void updateRecurrenceMask (Task& task) auto uuid = task.get ("parent"); Task parent; - if (!uuid.empty() && + if (uuid != "" && Context::getContext ().tdb2.get (uuid, parent)) { unsigned int index = strtol (task.get ("imask").c_str (), nullptr, 10); diff --git a/src/recur2.cpp b/src/recur2.cpp index 4c22d7142..f9ca27075 100644 --- a/src/recur2.cpp +++ b/src/recur2.cpp @@ -279,7 +279,7 @@ static std::vector generateAllDueDates (const Task& templateTask) bool end_in_sight = false; Datetime until; - if (!templateTask.get ("until").empty()) + if (templateTask.get ("until") != "") { until = Datetime (templateTask.get ("until")); end_in_sight = true; @@ -296,7 +296,7 @@ static std::vector generateAllDueDates (const Task& templateTask) Datetime nextDue = generateNextDueDate (due, recur, lastN); // TODO Safety. - if (!dueDates.empty() && dueDates.back () == nextDue) + if (dueDates.size () && dueDates.back () == nextDue) break; // If nextDue > until, it means there are no more tasks to generate, so diff --git a/src/sort.cpp b/src/sort.cpp index 6cba01291..8fa6e50be 100644 --- a/src/sort.cpp +++ b/src/sort.cpp @@ -55,7 +55,7 @@ void sort_tasks ( global_keys = split (keys, ','); // Only sort if necessary. - if (!order.empty()) + if (order.size ()) 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 parents = extractParents (project.first); - if (!parents.empty()) + if (parents.size ()) { // if parents exist: store iterator position of last parent std::list >::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.empty() && right_string.empty()) + if (left_string != "" && right_string == "") return true; - if (left_string.empty() && !right_string.empty()) + if (left_string == "" && right_string != "") 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.empty() && !right_string.empty()) + if (left_string == "" && right_string != "") return ascending; - if (!left_string.empty() && right_string.empty()) + if (left_string != "" && right_string == "") 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.empty()) + if (left_string == "") return false; - else if (right_string.empty()) + else if (right_string == "") 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.empty() && right_string.empty()) + if (left_string != "" && right_string == "") return true; - if (left_string.empty() && !right_string.empty()) + if (left_string == "" && right_string != "") return false; if (left_string == right_string)