clang-tidy: use auto

Found with modernize-use-auto

Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
Rosen Penev
2021-02-28 19:39:31 -08:00
committed by Tomas Babej
parent d0c4350c2f
commit e84930be8d
4 changed files with 16 additions and 16 deletions

View File

@@ -486,7 +486,7 @@ void Hooks::assertSameTask (
for (auto& i : input) for (auto& i : input)
{ {
json::object* root_obj = (json::object*)json::parse (i); auto root_obj = (json::object*)json::parse (i);
// If there is no UUID at all. // If there is no UUID at all.
auto u = root_obj->_data.find ("uuid"); auto u = root_obj->_data.find ("uuid");
@@ -497,7 +497,7 @@ void Hooks::assertSameTask (
throw 0; throw 0;
} }
json::string* up = (json::string*) u->second; auto up = (json::string*) u->second;
auto text = up->dump (); auto text = up->dump ();
Lexer::dequote (text); Lexer::dequote (text);
std::string json_uuid = json::decode (text); std::string json_uuid = json::decode (text);

View File

@@ -684,10 +684,10 @@ void Task::parseJSON (const json::object* root_obj)
// Tags are an array of JSON strings. // Tags are an array of JSON strings.
else if (i.first == "tags" && i.second->type() == json::j_array) else if (i.first == "tags" && i.second->type() == json::j_array)
{ {
json::array* tags = (json::array*)i.second; auto tags = (json::array*)i.second;
for (auto& t : tags->_data) for (auto& t : tags->_data)
{ {
json::string* tag = (json::string*)t; auto tag = (json::string*)t;
addTag (tag->_data); addTag (tag->_data);
} }
} }
@@ -698,7 +698,7 @@ void Task::parseJSON (const json::object* root_obj)
// removed in a later release. // removed in a later release.
else if (i.first == "tags" && i.second->type() == json::j_string) else if (i.first == "tags" && i.second->type() == json::j_string)
{ {
json::string* tag = (json::string*)i.second; auto tag = (json::string*)i.second;
addTag (tag->_data); addTag (tag->_data);
} }
@@ -707,10 +707,10 @@ void Task::parseJSON (const json::object* root_obj)
// See other 2016-02-21 comments for details. // See other 2016-02-21 comments for details.
else if (i.first == "depends" && i.second->type() == json::j_array) else if (i.first == "depends" && i.second->type() == json::j_array)
{ {
json::array* deps = (json::array*)i.second; auto deps = (json::array*)i.second;
for (auto& t : deps->_data) for (auto& t : deps->_data)
{ {
json::string* dep = (json::string*)t; auto dep = (json::string*)t;
addDependency (dep->_data); addDependency (dep->_data);
} }
} }
@@ -719,7 +719,7 @@ void Task::parseJSON (const json::object* root_obj)
// 2016-02-21: Deprecated - see other 2016-02-21 comments for details. // 2016-02-21: Deprecated - see other 2016-02-21 comments for details.
else if (i.first == "depends" && i.second->type() == json::j_string) else if (i.first == "depends" && i.second->type() == json::j_string)
{ {
json::string* deps = (json::string*)i.second; auto deps = (json::string*)i.second;
auto uuids = split (deps->_data, ','); auto uuids = split (deps->_data, ',');
for (const auto& uuid : uuids) for (const auto& uuid : uuids)
@@ -752,12 +752,12 @@ void Task::parseJSON (const json::object* root_obj)
{ {
std::map <std::string, std::string> annos; std::map <std::string, std::string> annos;
json::array* atts = (json::array*)i.second; auto atts = (json::array*)i.second;
for (auto& annotations : atts->_data) for (auto& annotations : atts->_data)
{ {
json::object* annotation = (json::object*)annotations; auto annotation = (json::object*)annotations;
json::string* when = (json::string*)annotation->_data["entry"]; auto when = (json::string*)annotation->_data["entry"];
json::string* what = (json::string*)annotation->_data["description"]; auto what = (json::string*)annotation->_data["description"];
if (! when) if (! when)
throw format ("Annotation is missing an entry date: {1}", root_obj-> dump ()); throw format ("Annotation is missing an entry date: {1}", root_obj-> dump ());

View File

@@ -843,7 +843,7 @@ unsigned Chart::burndown_size (unsigned ntasks)
// Choose the number from here rounded up to the nearest 10% of the next // Choose the number from here rounded up to the nearest 10% of the next
// highest power of 10 or half of power of 10. // highest power of 10 or half of power of 10.
const unsigned count = (unsigned) log10 (static_cast<double>(std::numeric_limits<unsigned>::max ())); const auto count = (unsigned) log10 (static_cast<double>(std::numeric_limits<unsigned>::max ()));
unsigned half = 500; unsigned half = 500;
unsigned full = 1000; unsigned full = 1000;

View File

@@ -107,7 +107,7 @@ int CmdImport::import (const std::string& input)
if (root->type () == json::j_object) if (root->type () == json::j_object)
{ {
// For each object element... // For each object element...
json::object* root_obj = (json::object*)root; auto root_obj = (json::object*)root;
importSingleTask (root_obj); importSingleTask (root_obj);
++count; ++count;
} }
@@ -116,13 +116,13 @@ int CmdImport::import (const std::string& input)
// [ { ... } , { ... } ] // [ { ... } , { ... } ]
else if (root->type () == json::j_array) else if (root->type () == json::j_array)
{ {
json::array* root_arr = (json::array*)root; auto root_arr = (json::array*)root;
// For each object element... // For each object element...
for (auto& element : root_arr->_data) for (auto& element : root_arr->_data)
{ {
// For each object element... // For each object element...
json::object* root_obj = (json::object*)element; auto root_obj = (json::object*)element;
importSingleTask (root_obj); importSingleTask (root_obj);
++count; ++count;
} }