STYLE: Use auto for variable type matches the type of the initializer expression

This check is responsible for using the auto type specifier for variable
declarations to improve code readability and maintainability.

The auto type specifier will only be introduced in situations where the
variable type matches the type of the initializer expression. In other words
auto should deduce the same type that was originally spelled in the source

SRCDIR=/Users/johnsonhj/src/jsoncpp/ #My local SRC
BLDDIR=/Users/johnsonhj/src/jsoncpp/cmake-build-debug/ #My local BLD

cd /Users/johnsonhj/src/jsoncpp/cmake-build-debug/
run-clang-tidy.py -extra-arg=-D__clang__ -checks=-*,modernize-use-auto -header-filter = .* -fix
This commit is contained in:
Hans Johnson
2019-01-14 17:09:15 -06:00
committed by Hans Johnson
parent cbeed7b076
commit 1fc3de7ca1
6 changed files with 18 additions and 18 deletions

View File

@@ -147,7 +147,7 @@ JSONCPP_STRING valueToString(double value,
(precisionType == PrecisionType::significantDigits) ? "%.*g" : "%.*f",
precision, value);
assert(len >= 0);
size_t wouldPrint = static_cast<size_t>(len);
auto wouldPrint = static_cast<size_t>(len);
if (wouldPrint >= buffer.size()) {
buffer.resize(wouldPrint + 1);
continue;
@@ -409,7 +409,7 @@ void FastWriter::writeValue(const Value& value) {
case objectValue: {
Value::Members members(value.getMemberNames());
document_ += '{';
for (Value::Members::iterator it = members.begin(); it != members.end();
for (auto it = members.begin(); it != members.end();
++it) {
const JSONCPP_STRING& name = *it;
if (it != members.begin())
@@ -479,7 +479,7 @@ void StyledWriter::writeValue(const Value& value) {
else {
writeWithIndent("{");
indent();
Value::Members::iterator it = members.begin();
auto it = members.begin();
for (;;) {
const JSONCPP_STRING& name = *it;
const Value& childValue = value[name];
@@ -699,7 +699,7 @@ void StyledStreamWriter::writeValue(const Value& value) {
else {
writeWithIndent("{");
indent();
Value::Members::iterator it = members.begin();
auto it = members.begin();
for (;;) {
const JSONCPP_STRING& name = *it;
const Value& childValue = value[name];
@@ -979,7 +979,7 @@ void BuiltStyledStreamWriter::writeValue(Value const& value) {
else {
writeWithIndent("{");
indent();
Value::Members::iterator it = members.begin();
auto it = members.begin();
for (;;) {
JSONCPP_STRING const& name = *it;
Value const& childValue = value[name];