Revert "[clang-tidy] Simplify boolean expressions"

This reverts commit 51870dff34.
This commit is contained in:
Paul Beckingham 2020-12-05 16:18:15 -05:00
parent 623d5ceb59
commit 364b4ea8bd
8 changed files with 51 additions and 25 deletions

View file

@ -1492,9 +1492,11 @@ void CLI2::findIDs ()
}
std::string raw = a.attribute ("raw");
previousFilterArgWasAnOperator = a._lextype == Lexer::Type::op &&
previousFilterArgWasAnOperator = (a._lextype == Lexer::Type::op &&
raw != "(" &&
raw != ")";
raw != ")")
? true
: false;
}
}
@ -1720,7 +1722,10 @@ void CLI2::insertIDExpr ()
bool ascending = true;
int low = strtol (r->first.c_str (), nullptr, 10);
int high = strtol (r->second.c_str (), nullptr, 10);
ascending = low <= high;
if (low <= high)
ascending = true;
else
ascending = false;
reconstructed.push_back (openParen);
reconstructed.push_back (argID);

View file

@ -73,7 +73,7 @@ void Filter::subset (const std::vector <Task>& input, std::vector <Task>& output
// Debug output from Eval during compilation is useful. During evaluation
// it is mostly noise.
eval.debug (Context::getContext ().config.getInteger ("debug.parser") >= 3);
eval.debug (Context::getContext ().config.getInteger ("debug.parser") >= 3 ? true : false);
eval.compileExpression (precompiled);
for (auto& task : input)
@ -124,7 +124,7 @@ void Filter::subset (std::vector <Task>& output)
// Debug output from Eval during compilation is useful. During evaluation
// it is mostly noise.
eval.debug (Context::getContext ().config.getInteger ("debug.parser") >= 3);
eval.debug (Context::getContext ().config.getInteger ("debug.parser") >= 3 ? true : false);
eval.compileExpression (precompiled);
output.clear ();
@ -240,10 +240,16 @@ bool Filter::pendingOnly () const
if (countStatus)
{
return !(!countPending && !countWaiting && !countRecurring);
if (!countPending && !countWaiting && !countRecurring)
return false;
return true;
}
return countId != 0;
if (countId)
return true;
return false;
}
////////////////////////////////////////////////////////////////////////////////

View file

@ -75,7 +75,7 @@ bool Lexer::token (std::string& token, Lexer::Type& type)
// - path < substitution < pattern
// - set < number
// - word last
return isString (token, type, "'\"") ||
if (isString (token, type, "'\"") ||
isDate (token, type) ||
isDuration (token, type) ||
isURL (token, type) ||
@ -92,7 +92,10 @@ bool Lexer::token (std::string& token, Lexer::Type& type)
isPattern (token, type) ||
isOperator (token, type) ||
isIdentifier (token, type) ||
isWord (token, type);
isWord (token, type))
return true;
return false;
}
////////////////////////////////////////////////////////////////////////////////
@ -263,7 +266,10 @@ void Lexer::dequote (std::string& input, const std::string& quotes)
// escapes, to get them past the shell.
bool Lexer::wasQuoted (const std::string& input)
{
return input.find_first_of (" \t()<>&~") != std::string::npos;
if (input.find_first_of (" \t()<>&~") != std::string::npos)
return true;
return false;
}
////////////////////////////////////////////////////////////////////////////////
@ -1565,7 +1571,7 @@ bool Lexer::readWord (
prev = c;
}
return word.length () > 0;
return word.length () > 0 ? true : false;
}
////////////////////////////////////////////////////////////////////////////////

View file

@ -1438,7 +1438,7 @@ int TDB2::id (const std::string& uuid)
bool TDB2::verifyUniqueUUID (const std::string& uuid)
{
pending.get_tasks ();
return pending.id (uuid) == 0;
return pending.id (uuid) != 0 ? false : true;
}
////////////////////////////////////////////////////////////////////////////////

View file

@ -190,7 +190,10 @@ void Task::setAsNow (const std::string& att)
////////////////////////////////////////////////////////////////////////////////
bool Task::has (const std::string& name) const
{
return data.find (name) != data.end ();
if (data.find (name) != data.end ())
return true;
return false;
}
////////////////////////////////////////////////////////////////////////////////
@ -1046,7 +1049,7 @@ int Task::getAnnotationCount () const
////////////////////////////////////////////////////////////////////////////////
bool Task::hasAnnotations () const
{
return annotation_count != 0;
return annotation_count ? true : false;
}
////////////////////////////////////////////////////////////////////////////////
@ -1293,7 +1296,10 @@ bool Task::hasTag (const std::string& tag) const
// Concrete tags.
auto tags = split (get ("tags"), ',');
return std::find (tags.begin (), tags.end (), tag) != tags.end ();
if (std::find (tags.begin (), tags.end (), tag) != tags.end ())
return true;
return false;
}
////////////////////////////////////////////////////////////////////////////////
@ -1362,7 +1368,7 @@ void Task::substitute (
const std::string& to,
const std::string& flags)
{
bool global = (flags.find ('g') != std::string::npos);
bool global = (flags.find ('g') != std::string::npos ? true : false);
// Get the data to modify.
std::string description = get ("description");

View file

@ -1820,7 +1820,7 @@ void Variant::cast (const enum type new_type)
case type_integer:
switch (new_type)
{
case type_boolean: _bool = _integer != 0; break;
case type_boolean: _bool = _integer == 0 ? false : true; break;
case type_integer: break;
case type_real: _real = static_cast<double>(_integer); break;
case type_string:
@ -1838,7 +1838,7 @@ void Variant::cast (const enum type new_type)
case type_real:
switch (new_type)
{
case type_boolean: _bool = _real != 0.0; break;
case type_boolean: _bool = _real == 0.0 ? false : true; break;
case type_integer: _integer = static_cast<int>(_real); break;
case type_real: break;
case type_string:
@ -1858,9 +1858,9 @@ void Variant::cast (const enum type new_type)
switch (new_type)
{
case type_boolean:
_bool = !(_string.length () == 0 ||
_bool = (_string.length () == 0 ||
_string == "0" ||
_string == "0.0");
_string == "0.0") ? false : true;
break;
case type_integer:
_integer = static_cast<int>(strtol (_string.c_str (), nullptr, (_string.substr (0, 2) == "0x" ? 16 : 10)));
@ -1913,7 +1913,7 @@ void Variant::cast (const enum type new_type)
case type_date:
switch (new_type)
{
case type_boolean: _bool = _date != 0; break;
case type_boolean: _bool = _date != 0 ? true : false; break;
case type_integer: _integer = static_cast<int>(_date); break;
case type_real: _real = static_cast<double>(_date); break;
case type_string: _string = std::string(*this); break;
@ -1925,7 +1925,7 @@ void Variant::cast (const enum type new_type)
case type_duration:
switch (new_type)
{
case type_boolean: _bool = _duration != 0; break;
case type_boolean: _bool = _duration != 0 ? true : false; break;
case type_integer: _integer = static_cast<int>(_duration); break;
case type_real: _real = static_cast<double>(_duration); break;
case type_string: _string = std::string(*this); break;

View file

@ -302,7 +302,7 @@ std::string ViewTask::render (std::vector <Task>& data, std::vector <int>& seque
autoColorize (data[sequence[s]], rule_color);
// Alternate rows based on |s % 2|
bool odd = (s % 2) != 0;
bool odd = (s % 2) ? true : false;
Color row_color;
if (Context::getContext ().color ())
{

View file

@ -174,8 +174,11 @@ bool generateDueDates (Task& parent, std::vector <Datetime>& allDue)
// parent mask contains all + or X, then there never will be another task
// to generate, and this parent task may be safely reaped.
auto mask = parent.get ("mask");
return !(mask.length () == allDue.size () &&
mask.find ('-') == std::string::npos);
if (mask.length () == allDue.size () &&
mask.find ('-') == std::string::npos)
return false;
return true;
}
if (i > now)