Skip to content

Commit fdf6d1d

Browse files
author
Fabien Coelho
committed
apply clang-format
1 parent 2011c8b commit fdf6d1d

File tree

5 files changed

+46
-47
lines changed

5 files changed

+46
-47
lines changed

src/command_lint.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ static auto disable_lint_rules(sourcemeta::core::SchemaTransformer &bundle,
2929
}
3030

3131
static auto reindent(const std::string_view &value,
32-
const std::string &indentation, std::ostream &stream)
33-
-> void {
32+
const std::string &indentation,
33+
std::ostream &stream) -> void {
3434
if (!value.empty()) {
3535
stream << indentation;
3636
}

src/command_test.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
#include "utils.h"
1414

1515
static auto get_data(const sourcemeta::core::JSON &test_case,
16-
const std::filesystem::path &base, const bool verbose)
17-
-> sourcemeta::core::JSON {
16+
const std::filesystem::path &base,
17+
const bool verbose) -> sourcemeta::core::JSON {
1818
assert(base.is_absolute());
1919
assert(test_case.is_object());
2020
assert(test_case.defines("data") || test_case.defines("dataPath"));

src/command_validate.cc

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,18 @@
66
#include <sourcemeta/blaze/evaluator.h>
77

88
#include <chrono> // std::chrono
9+
#include <cmath> // for sqrt
910
#include <cstdlib> // EXIT_SUCCESS, EXIT_FAILURE
1011
#include <iostream> // std::cerr
1112
#include <set> // std::set
1213
#include <string> // std::string
13-
#include <cmath> // for sqrt
1414

1515
#include "command.h"
1616
#include "utils.h"
1717

1818
// parse unsigned int option, how many loop for benchmarking
1919
auto benchmark_loop(
20-
const std::map<std::string, std::vector<std::string>> &options)
21-
-> size_t {
20+
const std::map<std::string, std::vector<std::string>> &options) -> size_t {
2221

2322
size_t loop = 1;
2423

@@ -142,9 +141,8 @@ auto sourcemeta::jsonschema::cli::validate(
142141
} else if (subresult) {
143142
log_verbose(options)
144143
<< "ok: " << safe_weakly_canonical(instance_path).string()
145-
<< " (entry #" << index << ")"
146-
<< "\n matches " << safe_weakly_canonical(schema_path).string()
147-
<< "\n";
144+
<< " (entry #" << index << ")" << "\n matches "
145+
<< safe_weakly_canonical(schema_path).string() << "\n";
148146
print_annotations(output, options, std::cerr);
149147
} else {
150148
std::cerr << "fail: "
@@ -179,38 +177,45 @@ auto sourcemeta::jsonschema::cli::validate(
179177
double sum = 0.0, sum2 = 0.0, empty = 0.0;
180178
size_t count = 0;
181179

182-
// overhead evaluation, if the compiler is kind enough not to optimize this out!
183-
for (auto i = bench_loop; i; i--) {
180+
// overhead evaluation, if the compiler is kind enough not to optimize
181+
// this out!
182+
for (auto i = bench_loop; i; i--) {
184183
const auto start{std::chrono::high_resolution_clock::now()};
185184
count++;
186185
const auto end{std::chrono::high_resolution_clock::now()};
187-
empty += (double)
188-
(std::chrono::duration_cast<std::chrono::microseconds>(end - start)).count();
186+
empty +=
187+
(double)(std::chrono::duration_cast<std::chrono::microseconds>(
188+
end - start))
189+
.count();
189190
}
190191
assert(count == bench_loop);
191-
empty /= (double) bench_loop;
192+
empty /= (double)bench_loop;
192193

193194
// execution time evaluation
194-
for (auto i = bench_loop; i; i--) {
195+
for (auto i = bench_loop; i; i--) {
195196
const auto start{std::chrono::high_resolution_clock::now()};
196197

197198
// force fast evaluation
198199
subresult = evaluator.validate(schema_template, instance);
199200

200201
const auto end{std::chrono::high_resolution_clock::now()};
201-
const auto delay = (double) (std::chrono::duration_cast<
202-
std::chrono::microseconds>(end - start)).count() - empty;
202+
const auto delay =
203+
(double)(std::chrono::duration_cast<std::chrono::microseconds>(
204+
end - start))
205+
.count() -
206+
empty;
203207

204208
sum += delay;
205209
sum2 += delay * delay;
206210
}
207211

208212
// compute and show average execution time and standard deviation
209-
auto avg = sum / (double) bench_loop;
210-
auto stdev = sqrt(sum2 / (double) bench_loop - avg * avg);
213+
auto avg = sum / (double)bench_loop;
214+
auto stdev = sqrt(sum2 / (double)bench_loop - avg * avg);
211215
std::cout << std::fixed;
212216
std::cout.precision(3);
213-
std::cout << "took: " << avg << " +- " << stdev << " us (" << empty << ")\n";
217+
std::cout << "took: " << avg << " +- " << stdev << " us (" << empty
218+
<< ")\n";
214219

215220
if (!subresult) {
216221
error << "error: Schema validation failure\n";

src/utils.cc

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,8 @@ auto parse_options(const std::span<const std::string> &arguments,
185185
return options;
186186
}
187187

188-
auto print(const sourcemeta::blaze::SimpleOutput &output, std::ostream &stream)
189-
-> void {
188+
auto print(const sourcemeta::blaze::SimpleOutput &output,
189+
std::ostream &stream) -> void {
190190
stream << "error: Schema validation failure\n";
191191
output.stacktrace(stream, " ");
192192
}
@@ -211,8 +211,8 @@ auto print_annotations(
211211
}
212212

213213
// TODO: Move this as an operator<< overload for TraceOutput in Blaze itself
214-
auto print(const sourcemeta::blaze::TraceOutput &output, std::ostream &stream)
215-
-> void {
214+
auto print(const sourcemeta::blaze::TraceOutput &output,
215+
std::ostream &stream) -> void {
216216
for (auto iterator = output.cbegin(); iterator != output.cend(); iterator++) {
217217
const auto &entry{*iterator};
218218

@@ -376,9 +376,8 @@ auto log_verbose(const std::map<std::string, std::vector<std::string>> &options)
376376
return null_stream;
377377
}
378378

379-
auto parse_extensions(
380-
const std::map<std::string, std::vector<std::string>> &options)
381-
-> std::set<std::string> {
379+
auto parse_extensions(const std::map<std::string, std::vector<std::string>>
380+
&options) -> std::set<std::string> {
382381
std::set<std::string> result;
383382

384383
if (options.contains("extension")) {
@@ -404,9 +403,8 @@ auto parse_extensions(
404403
return result;
405404
}
406405

407-
auto parse_ignore(
408-
const std::map<std::string, std::vector<std::string>> &options)
409-
-> std::set<std::filesystem::path> {
406+
auto parse_ignore(const std::map<std::string, std::vector<std::string>>
407+
&options) -> std::set<std::filesystem::path> {
410408
std::set<std::filesystem::path> result;
411409

412410
if (options.contains("ignore")) {
@@ -435,9 +433,8 @@ auto safe_weakly_canonical(const std::filesystem::path &input)
435433
: std::filesystem::weakly_canonical(input);
436434
}
437435

438-
auto default_dialect(
439-
const std::map<std::string, std::vector<std::string>> &options)
440-
-> std::optional<std::string> {
436+
auto default_dialect(const std::map<std::string, std::vector<std::string>>
437+
&options) -> std::optional<std::string> {
441438

442439
if (options.contains("default-dialect")) {
443440
return options.at("default-dialect").front();

src/utils.h

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,16 @@ auto for_each_json(const std::vector<std::string> &arguments,
3030
const std::set<std::string> &extensions)
3131
-> std::vector<std::pair<std::filesystem::path, sourcemeta::core::JSON>>;
3232

33-
auto print(const sourcemeta::blaze::SimpleOutput &output, std::ostream &stream)
34-
-> void;
33+
auto print(const sourcemeta::blaze::SimpleOutput &output,
34+
std::ostream &stream) -> void;
3535

3636
auto print_annotations(
3737
const sourcemeta::blaze::SimpleOutput &output,
3838
const std::map<std::string, std::vector<std::string>> &options,
3939
std::ostream &stream) -> void;
4040

41-
auto print(const sourcemeta::blaze::TraceOutput &output, std::ostream &stream)
42-
-> void;
41+
auto print(const sourcemeta::blaze::TraceOutput &output,
42+
std::ostream &stream) -> void;
4343

4444
auto resolver(const std::map<std::string, std::vector<std::string>> &options,
4545
const bool remote,
@@ -49,20 +49,17 @@ auto resolver(const std::map<std::string, std::vector<std::string>> &options,
4949
auto log_verbose(const std::map<std::string, std::vector<std::string>> &options)
5050
-> std::ostream &;
5151

52-
auto parse_extensions(
53-
const std::map<std::string, std::vector<std::string>> &options)
54-
-> std::set<std::string>;
52+
auto parse_extensions(const std::map<std::string, std::vector<std::string>>
53+
&options) -> std::set<std::string>;
5554

56-
auto parse_ignore(
57-
const std::map<std::string, std::vector<std::string>> &options)
58-
-> std::set<std::filesystem::path>;
55+
auto parse_ignore(const std::map<std::string, std::vector<std::string>>
56+
&options) -> std::set<std::filesystem::path>;
5957

6058
auto safe_weakly_canonical(const std::filesystem::path &input)
6159
-> std::filesystem::path;
6260

63-
auto default_dialect(
64-
const std::map<std::string, std::vector<std::string>> &options)
65-
-> std::optional<std::string>;
61+
auto default_dialect(const std::map<std::string, std::vector<std::string>>
62+
&options) -> std::optional<std::string>;
6663

6764
} // namespace sourcemeta::jsonschema::cli
6865

0 commit comments

Comments
 (0)