clang-tidy fixes again (#1087)

* [clang-tidy] Do not use else after return

Found with readability-else-after-return

Signed-off-by: Rosen Penev <rosenp@gmail.com>

* [clang-tidy] Convert several loops to be range based

Found with modernize-loop-convert

Signed-off-by: Rosen Penev <rosenp@gmail.com>

* [clang-tidy] Replace deprecated C headers

Found with modernize-deprecated-headers

Signed-off-by: Rosen Penev <rosenp@gmail.com>

* [clang-tidy] Use auto where applicable

Found with modernize-use-auto

Signed-off-by: Rosen Penev <rosenp@gmail.com>

* .clang-tidy: Add these checks
This commit is contained in:
Rosen Penev
2020-02-02 20:03:45 -08:00
committed by GitHub
parent 6317f9a406
commit edf528edfa
7 changed files with 35 additions and 41 deletions

View File

@@ -9,7 +9,6 @@
#include <json/config.h>
#include <json/json.h>
#include <memory>
#include <stdint.h>
#include <string>
namespace Json {

View File

@@ -267,19 +267,18 @@ bool Runner::runAllTest(bool printSummary) const {
printf("All %zu tests passed\n", count);
}
return true;
} else {
for (auto& result : failures) {
result.printFailure(count > 1);
}
if (printSummary) {
size_t const failedCount = failures.size();
size_t const passedCount = count - failedCount;
printf("%zu/%zu tests passed (%zu failure(s))\n", passedCount, count,
failedCount);
}
return false;
}
for (auto& result : failures) {
result.printFailure(count > 1);
}
if (printSummary) {
size_t const failedCount = failures.size();
size_t const passedCount = count - failedCount;
printf("%zu/%zu tests passed (%zu failure(s))\n", passedCount, count,
failedCount);
}
return false;
}
bool Runner::testIndex(const Json::String& testName, size_t& indexOut) const {
@@ -308,7 +307,8 @@ int Runner::runCommandLine(int argc, const char* argv[]) const {
if (opt == "--list-tests") {
listTests();
return 0;
} else if (opt == "--test-auto") {
}
if (opt == "--test-auto") {
preventDialogOnCrash();
} else if (opt == "--test") {
++index;

View File

@@ -1476,9 +1476,7 @@ void ValueTest::checkMemberCount(Json::Value& value,
JSONTEST_ASSERT_PRED(checkConstMemberCount(value, expectedCount));
}
ValueTest::IsCheck::IsCheck()
= default;
ValueTest::IsCheck::IsCheck() = default;
void ValueTest::checkIs(const Json::Value& value, const IsCheck& check) {
JSONTEST_ASSERT_EQUAL(check.isObject_, value.isObject());
@@ -3752,8 +3750,8 @@ JSONTEST_FIXTURE_LOCAL(FuzzTest, fuzzDoesntCrash) {
int main(int argc, const char* argv[]) {
JsonTest::Runner runner;
for (auto it = local_.begin(); it != local_.end(); it++) {
runner.add(*it);
for (auto& local : local_) {
runner.add(local);
}
return runner.runCommandLine(argc, argv);