mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
Use the empty method to check for emptiness instead of comparing to an empty object
This commit is contained in:
parent
b5acfed98f
commit
2c5812f7a3
17 changed files with 51 additions and 50 deletions
|
@ -241,7 +241,7 @@ static void determineHourRange (
|
|||
last_hour = 23;
|
||||
|
||||
// If there is no data, show the whole day.
|
||||
if (tracked.size ())
|
||||
if (! tracked.empty ())
|
||||
{
|
||||
// Get the extreme time range for the filtered data.
|
||||
first_hour = 23;
|
||||
|
@ -562,7 +562,7 @@ static void renderInterval (
|
|||
|
||||
for (auto& tag : track.tags ())
|
||||
{
|
||||
if (label != "")
|
||||
if (! label.empty ())
|
||||
label += ' ';
|
||||
|
||||
label += tag;
|
||||
|
|
|
@ -126,8 +126,7 @@ static bool setConfigVariable (Database& database, const Rules& rules, std::stri
|
|||
value)))
|
||||
{
|
||||
// Add blank line required by rules.
|
||||
if (lines.size () &&
|
||||
lines.back () != "")
|
||||
if (lines.empty () || lines.back ().empty ())
|
||||
lines.push_back ("");
|
||||
|
||||
// Add new line.
|
||||
|
@ -150,8 +149,7 @@ static bool setConfigVariable (Database& database, const Rules& rules, std::stri
|
|||
// new leaf/value properly. But that's non-trivial.
|
||||
|
||||
// Add blank line required by rules.
|
||||
if (lines.size () &&
|
||||
lines.back () != "")
|
||||
if (lines.empty () || lines.back ().empty ())
|
||||
lines.push_back ("");
|
||||
|
||||
// Add new line.
|
||||
|
@ -272,7 +270,7 @@ int CmdConfig (
|
|||
// task config name value # set name to value
|
||||
// task config name "" # set name to blank
|
||||
// task config name # remove name
|
||||
if (words.size ())
|
||||
if (! words.empty ())
|
||||
{
|
||||
bool confirmation = rules.getBoolean ("confirmation");
|
||||
std::string name = words[0];
|
||||
|
@ -290,7 +288,7 @@ int CmdConfig (
|
|||
}
|
||||
}
|
||||
|
||||
if (name != "")
|
||||
if (! name.empty ())
|
||||
{
|
||||
bool change = false;
|
||||
|
||||
|
|
|
@ -197,7 +197,7 @@ int CmdDiagnostics (
|
|||
<< " Location: " << describeFile (extDir) << '\n';
|
||||
|
||||
auto exts = extensions.all ();
|
||||
if (exts.size ())
|
||||
if (! exts.empty ())
|
||||
{
|
||||
unsigned int longest = 0;
|
||||
for (auto& e : exts)
|
||||
|
|
|
@ -67,7 +67,7 @@ int CmdHelpUsage (const Extensions& extensions)
|
|||
<< " timew week [<interval>] [<tag> ...]\n"
|
||||
<< '\n';
|
||||
|
||||
if (extensions.all ().size ())
|
||||
if (!extensions.all ().empty ())
|
||||
{
|
||||
std::cout << "Extensions (extensions do not provide help):\n";
|
||||
|
||||
|
@ -120,7 +120,8 @@ int CmdHelp (
|
|||
const Extensions& extensions)
|
||||
{
|
||||
auto words = cli.getWords ();
|
||||
if (words.size ())
|
||||
|
||||
if (! words.empty ())
|
||||
{
|
||||
// Ruler 1 2 3 4 5 6 7 8
|
||||
// 12345678901234567890123456789012345678901234567890123456789012345678901234567890
|
||||
|
|
|
@ -47,7 +47,7 @@ static std::string findExtension (
|
|||
std::vector <std::string> matches;
|
||||
autoComplete (partial, options, matches);
|
||||
|
||||
if (matches.size () == 0)
|
||||
if (matches.empty ())
|
||||
throw format ("The report '{1}' is not recognized.", partial);
|
||||
|
||||
if (matches.size () > 1)
|
||||
|
@ -75,7 +75,7 @@ int CmdReport (
|
|||
if (arg.hasTag ("EXT"))
|
||||
script = findExtension (extensions, arg.attribute ("canonical"));
|
||||
|
||||
if (script == "")
|
||||
if (script.empty ())
|
||||
throw std::string ("Specify which report to run.");
|
||||
|
||||
// Compose Header info.
|
||||
|
|
|
@ -84,7 +84,7 @@ int CmdStop (
|
|||
|
||||
// If tags are specified, but are not a full set of tags, remove them
|
||||
// before closing the interval.
|
||||
if (filter.tags ().size () &&
|
||||
if (! filter.tags ().empty () &&
|
||||
setIntersect (filter.tags (), latest.tags ()).size () != latest.tags ().size ())
|
||||
{
|
||||
for (auto& tag : filter.tags ())
|
||||
|
@ -95,7 +95,7 @@ int CmdStop (
|
|||
}
|
||||
|
||||
// Open a new interval with remaining tags, if any.
|
||||
if (filter.tags ().size () &&
|
||||
if (! filter.tags ().empty () &&
|
||||
modified.tags ().size () != latest.tags ().size ())
|
||||
{
|
||||
modified.range.start = modified.range.end;
|
||||
|
|
|
@ -65,7 +65,7 @@ int CmdSummary (
|
|||
std::cout << " - " << filter.range.end.toISOLocalExtended ();
|
||||
}
|
||||
|
||||
if (filter.tags ().size ())
|
||||
if (! filter.tags ().empty ())
|
||||
{
|
||||
std::cout << " tagged with " << joinQuotedIfNeeded (", ", filter.tags ());
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ int CmdTags (
|
|||
tags.insert (tag);
|
||||
|
||||
// Shows all tags.
|
||||
if (tags.size ())
|
||||
if (! tags.empty ())
|
||||
{
|
||||
Table t;
|
||||
t.width (1024);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue