mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Cleanup: Don't use string literals when character literals are needed
This commit is contained in:
parent
35e518cbc2
commit
814d7d69fa
27 changed files with 122 additions and 122 deletions
|
@ -60,7 +60,7 @@ int CmdZshAttributes::execute (std::string& output)
|
|||
|
||||
std::stringstream out;
|
||||
for (auto& col : columns)
|
||||
out << col << ":" << col << '\n';
|
||||
out << col << ':' << col << '\n';
|
||||
|
||||
output = out.str ();
|
||||
return 0;
|
||||
|
|
|
@ -214,7 +214,7 @@ Chart::Chart (char type)
|
|||
std::vector <std::string> words = context.cli2.getWords ();
|
||||
std::string filter;
|
||||
join (filter, " ", words);
|
||||
_title = "(" + filter + ")";
|
||||
_title = '(' + filter + ')';
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -860,7 +860,7 @@ void Chart::calculateRates ()
|
|||
_completion = end.toString (format)
|
||||
+ " ("
|
||||
+ delta.formatVague ()
|
||||
+ ")";
|
||||
+ ')';
|
||||
|
||||
std::stringstream completion_message;
|
||||
completion_message << "Chart::calculateRates ("
|
||||
|
|
|
@ -224,8 +224,8 @@ int CmdZshCommands::execute (std::string& output)
|
|||
// Emit the commands in order.
|
||||
std::stringstream out;
|
||||
for (auto& zc : commands)
|
||||
out << zc._command << ":"
|
||||
<< Command::categoryNames.at (zc._category) << ":"
|
||||
out << zc._command << ':'
|
||||
<< Command::categoryNames.at (zc._category) << ':'
|
||||
<< zc._description << '\n';
|
||||
|
||||
output = out.str ();
|
||||
|
|
|
@ -65,8 +65,8 @@ bool CmdConfig::setConfigVariable (std::string name, std::string value, bool con
|
|||
for (auto& line : contents)
|
||||
{
|
||||
// If there is a comment on the line, it must follow the pattern.
|
||||
auto comment = line.find ("#");
|
||||
auto pos = line.find (name + "=");
|
||||
auto comment = line.find ('#');
|
||||
auto pos = line.find (name + '=');
|
||||
|
||||
if (pos != std::string::npos &&
|
||||
(comment == std::string::npos ||
|
||||
|
@ -77,9 +77,9 @@ bool CmdConfig::setConfigVariable (std::string name, std::string value, bool con
|
|||
confirm (format (STRING_CMD_CONFIG_CONFIRM, name, context.config.get (name), value)))
|
||||
{
|
||||
if (comment != std::string::npos)
|
||||
line = name + "=" + json::encode (value) + ' ' + line.substr (comment);
|
||||
line = name + '=' + json::encode (value) + ' ' + line.substr (comment);
|
||||
else
|
||||
line = name + "=" + json::encode (value);
|
||||
line = name + '=' + json::encode (value);
|
||||
|
||||
change = true;
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ bool CmdConfig::setConfigVariable (std::string name, std::string value, bool con
|
|||
(!confirmation ||
|
||||
confirm (format (STRING_CMD_CONFIG_CONFIRM2, name, value))))
|
||||
{
|
||||
contents.push_back (name + "=" + json::encode (value));
|
||||
contents.push_back (name + '=' + json::encode (value));
|
||||
change = true;
|
||||
}
|
||||
|
||||
|
@ -116,8 +116,8 @@ int CmdConfig::unsetConfigVariable (std::string name, bool confirmation /* = fal
|
|||
bool lineDeleted = false;
|
||||
|
||||
// If there is a comment on the line, it must follow the pattern.
|
||||
auto comment = line->find ("#");
|
||||
auto pos = line->find (name + "=");
|
||||
auto comment = line->find ('#');
|
||||
auto pos = line->find (name + '=');
|
||||
|
||||
if (pos != std::string::npos &&
|
||||
(comment == std::string::npos ||
|
||||
|
|
|
@ -89,7 +89,7 @@ int CmdDiagnostics::execute (std::string& output)
|
|||
<< " " << STRING_CMD_DIAG_VERSION << ": "
|
||||
<< __VERSION__ << '\n'
|
||||
#endif
|
||||
<< " " << STRING_CMD_DIAG_CAPS << ":"
|
||||
<< " " << STRING_CMD_DIAG_CAPS << ':'
|
||||
#ifdef __STDC__
|
||||
<< " +stdc"
|
||||
#endif
|
||||
|
@ -168,7 +168,7 @@ int CmdDiagnostics::execute (std::string& output)
|
|||
#ifdef CMAKE_BUILD_TYPE
|
||||
<< CMAKE_BUILD_TYPE
|
||||
#else
|
||||
<< "-"
|
||||
<< '-'
|
||||
#endif
|
||||
<< "\n\n";
|
||||
|
||||
|
@ -273,7 +273,7 @@ int CmdDiagnostics::execute (std::string& output)
|
|||
auto last_slash = credentials.rfind ('/');
|
||||
if (last_slash != std::string::npos)
|
||||
credentials = credentials.substr (0, last_slash)
|
||||
+ "/"
|
||||
+ '/'
|
||||
+ std::string (credentials.length () - last_slash - 1, '*');
|
||||
|
||||
out << " Creds: "
|
||||
|
@ -379,7 +379,7 @@ int CmdDiagnostics::execute (std::string& output)
|
|||
<< (term ? term : STRING_CMD_DIAG_NONE)
|
||||
<< " ("
|
||||
<< context.getWidth ()
|
||||
<< "x"
|
||||
<< 'x'
|
||||
<< context.getHeight ()
|
||||
<< ")\n";
|
||||
|
||||
|
|
|
@ -798,7 +798,7 @@ CmdEdit::editResult CmdEdit::editFile (Task& task)
|
|||
|
||||
// Complete the command line.
|
||||
editor += ' ';
|
||||
editor += "\"" + file.str () + "\"";
|
||||
editor += '"' + file.str () + '"';
|
||||
|
||||
ARE_THESE_REALLY_HARMFUL:
|
||||
bool changes = false; // No changes made.
|
||||
|
|
|
@ -84,7 +84,7 @@ int CmdExport::execute (std::string& output)
|
|||
if (counter)
|
||||
{
|
||||
if (json_array)
|
||||
output += ",";
|
||||
output += ',';
|
||||
output += '\n';
|
||||
}
|
||||
|
||||
|
|
|
@ -525,9 +525,9 @@ int CmdGHistoryMonthly::execute (std::string& output)
|
|||
}
|
||||
else
|
||||
{
|
||||
std::string aBar = ""; while (aBar.length () < addedBar) aBar += "+";
|
||||
std::string cBar = ""; while (cBar.length () < completedBar) cBar += "X";
|
||||
std::string dBar = ""; while (dBar.length () < deletedBar) dBar += "-";
|
||||
std::string aBar = ""; while (aBar.length () < addedBar) aBar += '+';
|
||||
std::string cBar = ""; while (cBar.length () < completedBar) cBar += 'X';
|
||||
std::string dBar = ""; while (dBar.length () < deletedBar) dBar += '-';
|
||||
|
||||
bar += std::string (leftOffset - aBar.length (), ' ');
|
||||
bar += aBar + cBar + dBar;
|
||||
|
@ -722,9 +722,9 @@ int CmdGHistoryAnnual::execute (std::string& output)
|
|||
}
|
||||
else
|
||||
{
|
||||
std::string aBar = ""; while (aBar.length () < addedBar) aBar += "+";
|
||||
std::string cBar = ""; while (cBar.length () < completedBar) cBar += "X";
|
||||
std::string dBar = ""; while (dBar.length () < deletedBar) dBar += "-";
|
||||
std::string aBar = ""; while (aBar.length () < addedBar) aBar += '+';
|
||||
std::string cBar = ""; while (cBar.length () < completedBar) cBar += 'X';
|
||||
std::string dBar = ""; while (dBar.length () < deletedBar) dBar += '-';
|
||||
|
||||
bar += std::string (leftOffset - aBar.length (), ' ');
|
||||
bar += aBar + cBar + dBar;
|
||||
|
|
|
@ -103,7 +103,7 @@ std::string CmdIDs::compressIds (const std::vector <int>& ids)
|
|||
result << ' ';
|
||||
|
||||
if (range_start < range_end)
|
||||
result << ids[range_start] << "-" << ids[range_end];
|
||||
result << ids[range_start] << '-' << ids[range_end];
|
||||
else
|
||||
result << ids[range_start];
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ std::string CmdIDs::compressIds (const std::vector <int>& ids)
|
|||
result << ' ';
|
||||
|
||||
if (range_start < range_end)
|
||||
result << ids[range_start] << "-" << ids[range_end];
|
||||
result << ids[range_start] << '-' << ids[range_end];
|
||||
else
|
||||
result << ids[range_start];
|
||||
|
||||
|
@ -312,7 +312,7 @@ int CmdZshCompletionUuids::execute (std::string& output)
|
|||
std::stringstream out;
|
||||
for (auto& task : filtered)
|
||||
out << task.get ("uuid")
|
||||
<< ":"
|
||||
<< ':'
|
||||
<< str_replace (task.get ("description"), ":", zshColonReplacement)
|
||||
<< '\n';
|
||||
|
||||
|
|
|
@ -231,7 +231,7 @@ int CmdInfo::execute (std::string& output)
|
|||
age = ISO8601p (now - dt).formatVague ();
|
||||
}
|
||||
|
||||
view.set (row, 1, entry + " (" + age + ")");
|
||||
view.set (row, 1, entry + " (" + age + ')');
|
||||
|
||||
// wait
|
||||
if (task.has ("wait"))
|
||||
|
@ -289,7 +289,7 @@ int CmdInfo::execute (std::string& output)
|
|||
|
||||
ISO8601d mod (task.get_date ("modified"));
|
||||
std::string age = ISO8601p (now - mod).formatVague ();
|
||||
view.set (row, 1, mod.toString (dateformat) + " (" + age + ")");
|
||||
view.set (row, 1, mod.toString (dateformat) + " (" + age + ')');
|
||||
}
|
||||
|
||||
// tags ...
|
||||
|
@ -399,8 +399,8 @@ int CmdInfo::execute (std::string& output)
|
|||
context.columns.find (att) == context.columns.end ())
|
||||
{
|
||||
row = view.addRow ();
|
||||
view.set (row, 0, "[" + att);
|
||||
view.set (row, 1, task.get (att) + "]");
|
||||
view.set (row, 0, '[' + att);
|
||||
view.set (row, 1, task.get (att) + ']');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -232,7 +232,7 @@ int CmdStats::execute (std::string& output)
|
|||
view.set (row, 0, STRING_CMD_STATS_TAGGED);
|
||||
|
||||
std::stringstream value;
|
||||
value << std::setprecision (3) << (100.0 * taggedT / totalT) << "%";
|
||||
value << std::setprecision (3) << (100.0 * taggedT / totalT) << '%';
|
||||
view.set (row, 1, value.str ());
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue