Skip to content

Commit 25fc3db

Browse files
authored
style(clang-tidy): fix modernize-use-designated-initializers (#1810)
Signed-off-by: Balakrishna Avulapati <ba@bavulapati.com>
1 parent 90aa454 commit 25fc3db

File tree

3 files changed

+85
-54
lines changed

3 files changed

+85
-54
lines changed

src/core/jsonschema/frame.cc

Lines changed: 37 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -217,12 +217,17 @@ auto store(
217217
instance_locations.cbegin(), instance_locations.cend())
218218
.size() == instance_locations.size());
219219
const auto canonical{sourcemeta::core::URI::canonicalize(uri)};
220-
const auto inserted{
221-
frame
222-
.insert({{type, canonical},
223-
{parent, entry_type, root_id, base_id, pointer_from_root,
224-
pointer_from_base, dialect, base_dialect}})
225-
.second};
220+
const auto inserted{frame
221+
.insert({{type, canonical},
222+
{.parent = parent,
223+
.type = entry_type,
224+
.root = root_id,
225+
.base = base_id,
226+
.pointer = pointer_from_root,
227+
.relative_pointer = pointer_from_base,
228+
.dialect = dialect,
229+
.base_dialect = base_dialect}})
230+
.second};
226231
if (!ignore_if_present && !inserted) {
227232
throw_already_exists(uri);
228233
}
@@ -493,12 +498,15 @@ auto SchemaFrame::analyse(const JSON &root, const SchemaWalker &walker,
493498
entry.pointer.empty() ? default_id : std::nullopt)};
494499

495500
// Store information
496-
subschemas.emplace(entry.pointer,
497-
CacheSubschema{entry.instance_location,
498-
entry.relative_instance_location,
499-
entry.orphan, entry.parent});
501+
subschemas.emplace(
502+
entry.pointer,
503+
CacheSubschema{.instance_location = entry.instance_location,
504+
.relative_instance_location =
505+
entry.relative_instance_location,
506+
.orphan = entry.orphan,
507+
.parent = entry.parent});
500508
subschema_entries.emplace_back(
501-
InternalEntry{std::move(entry), std::move(id)});
509+
InternalEntry{.common = std::move(entry), .id = std::move(id)});
502510
current_subschema_entries.emplace_back(subschema_entries.size() - 1);
503511
}
504512

@@ -602,9 +610,10 @@ auto SchemaFrame::analyse(const JSON &root, const SchemaWalker &walker,
602610
{SchemaReferenceType::Static,
603611
entry.common.pointer.concat({"$schema"})},
604612
SchemaFrame::ReferencesEntry{
605-
maybe_metaschema.value(), destination,
606-
metaschema.recompose_without_fragment(),
607-
fragment_string(metaschema)});
613+
.original = maybe_metaschema.value(),
614+
.destination = destination,
615+
.base = metaschema.recompose_without_fragment(),
616+
.fragment = fragment_string(metaschema)});
608617
}
609618
}
610619

@@ -809,9 +818,11 @@ auto SchemaFrame::analyse(const JSON &root, const SchemaWalker &walker,
809818
this->references_.insert_or_assign(
810819
{SchemaReferenceType::Static,
811820
entry.common.pointer.concat({"$ref"})},
812-
SchemaFrame::ReferencesEntry{original, ref.recompose(),
813-
ref.recompose_without_fragment(),
814-
fragment_string(ref)});
821+
SchemaFrame::ReferencesEntry{.original = original,
822+
.destination = ref.recompose(),
823+
.base =
824+
ref.recompose_without_fragment(),
825+
.fragment = fragment_string(ref)});
815826
}
816827

817828
if (entry.common.vocabularies.contains(
@@ -842,9 +853,10 @@ auto SchemaFrame::analyse(const JSON &root, const SchemaWalker &walker,
842853
this->references_.insert_or_assign(
843854
{reference_type, entry.common.pointer.concat({"$recursiveRef"})},
844855
SchemaFrame::ReferencesEntry{
845-
ref, anchor_uri.recompose(),
846-
anchor_uri.recompose_without_fragment(),
847-
fragment_string(anchor_uri)});
856+
.original = ref,
857+
.destination = anchor_uri.recompose(),
858+
.base = anchor_uri.recompose_without_fragment(),
859+
.fragment = fragment_string(anchor_uri)});
848860
}
849861

850862
if (entry.common.vocabularies.contains(
@@ -878,9 +890,11 @@ auto SchemaFrame::analyse(const JSON &root, const SchemaWalker &walker,
878890
{behaves_as_static ? SchemaReferenceType::Static
879891
: SchemaReferenceType::Dynamic,
880892
entry.common.pointer.concat({"$dynamicRef"})},
881-
SchemaFrame::ReferencesEntry{original, std::move(ref_string),
882-
ref.recompose_without_fragment(),
883-
fragment_string(ref)});
893+
SchemaFrame::ReferencesEntry{.original = original,
894+
.destination = std::move(ref_string),
895+
.base =
896+
ref.recompose_without_fragment(),
897+
.fragment = fragment_string(ref)});
884898
}
885899
}
886900
}

src/core/jsonschema/official_walker.cc

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -396,10 +396,10 @@ auto sourcemeta::core::schema_official_walker(
396396
if ((vocabularies.contains(HTTP_BASE "draft-07/schema#") ||
397397
vocabularies.contains(HTTP_BASE "draft-07/hyper-schema#")) &&
398398
keyword != "$ref") {
399-
return {sourcemeta::core::SchemaKeywordType::Unknown,
400-
std::nullopt,
401-
{"$ref"},
402-
{}};
399+
return {.type = sourcemeta::core::SchemaKeywordType::Unknown,
400+
.vocabulary = std::nullopt,
401+
.dependencies = {"$ref"},
402+
.instances = {}};
403403
}
404404

405405
// Draft6
@@ -519,10 +519,10 @@ auto sourcemeta::core::schema_official_walker(
519519
if ((vocabularies.contains(HTTP_BASE "draft-06/schema#") ||
520520
vocabularies.contains(HTTP_BASE "draft-06/hyper-schema#")) &&
521521
keyword != "$ref") {
522-
return {sourcemeta::core::SchemaKeywordType::Unknown,
523-
std::nullopt,
524-
{"$ref"},
525-
{}};
522+
return {.type = sourcemeta::core::SchemaKeywordType::Unknown,
523+
.vocabulary = std::nullopt,
524+
.dependencies = {"$ref"},
525+
.instances = {}};
526526
}
527527

528528
// Draft4
@@ -619,10 +619,10 @@ auto sourcemeta::core::schema_official_walker(
619619
if ((vocabularies.contains(HTTP_BASE "draft-04/schema#") ||
620620
vocabularies.contains(HTTP_BASE "draft-04/hyper-schema#")) &&
621621
keyword != "$ref") {
622-
return {sourcemeta::core::SchemaKeywordType::Unknown,
623-
std::nullopt,
624-
{"$ref"},
625-
{}};
622+
return {.type = sourcemeta::core::SchemaKeywordType::Unknown,
623+
.vocabulary = std::nullopt,
624+
.dependencies = {"$ref"},
625+
.instances = {}};
626626
}
627627

628628
// Draft3
@@ -686,10 +686,10 @@ auto sourcemeta::core::schema_official_walker(
686686
// $ref also takes precedence over any unknown keyword
687687
if (vocabularies.contains(HTTP_BASE "draft-03/schema#") &&
688688
keyword != "$ref") {
689-
return {sourcemeta::core::SchemaKeywordType::Unknown,
690-
std::nullopt,
691-
{"$ref"},
692-
{}};
689+
return {.type = sourcemeta::core::SchemaKeywordType::Unknown,
690+
.vocabulary = std::nullopt,
691+
.dependencies = {"$ref"},
692+
.instances = {}};
693693
}
694694

695695
// Draft2
@@ -877,5 +877,8 @@ auto sourcemeta::core::schema_official_walker(
877877
#undef WALK
878878
#undef WALK_ANY
879879
#undef WALK_MAYBE_DEPENDENT
880-
return {sourcemeta::core::SchemaKeywordType::Unknown, std::nullopt, {}, {}};
880+
return {.type = sourcemeta::core::SchemaKeywordType::Unknown,
881+
.vocabulary = std::nullopt,
882+
.dependencies = {},
883+
.instances = {}};
881884
}

src/core/jsonschema/walker.cc

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,16 @@ auto walk(const std::optional<sourcemeta::core::Pointer> &parent,
5454
resolver, current_base_dialect, current_dialect)};
5555

5656
if (type == SchemaWalkerType_t::Deep || level > 0) {
57-
sourcemeta::core::SchemaIteratorEntry entry{parent,
58-
pointer,
59-
current_dialect,
60-
vocabularies,
61-
current_base_dialect,
62-
subschema,
63-
instance_location,
64-
relative_instance_location,
65-
orphan};
57+
sourcemeta::core::SchemaIteratorEntry entry{
58+
.parent = parent,
59+
.pointer = pointer,
60+
.dialect = current_dialect,
61+
.vocabularies = vocabularies,
62+
.base_dialect = current_base_dialect,
63+
.subschema = subschema,
64+
.instance_location = instance_location,
65+
.relative_instance_location = relative_instance_location,
66+
.orphan = orphan};
6667
subschemas.push_back(std::move(entry));
6768
}
6869

@@ -405,8 +406,15 @@ sourcemeta::core::SchemaIterator::SchemaIterator(
405406
// the current schema is a subschema, but cannot walk any further.
406407
if (!dialect.has_value()) {
407408
sourcemeta::core::SchemaIteratorEntry entry{
408-
std::nullopt, pointer, std::nullopt, {}, std::nullopt,
409-
schema, instance_location, instance_location, false};
409+
.parent = std::nullopt,
410+
.pointer = pointer,
411+
.dialect = std::nullopt,
412+
.vocabularies = {},
413+
.base_dialect = std::nullopt,
414+
.subschema = schema,
415+
.instance_location = instance_location,
416+
.relative_instance_location = instance_location,
417+
.orphan = false};
410418
this->subschemas.push_back(std::move(entry));
411419
} else {
412420
const auto base_dialect{
@@ -460,9 +468,15 @@ sourcemeta::core::SchemaKeywordIterator::SchemaKeywordIterator(
460468

461469
for (const auto &entry : schema.as_object()) {
462470
sourcemeta::core::SchemaIteratorEntry subschema_entry{
463-
std::nullopt, {entry.first}, dialect, vocabularies,
464-
base_dialect, entry.second, {}, {},
465-
false};
471+
.parent = std::nullopt,
472+
.pointer = {entry.first},
473+
.dialect = dialect,
474+
.vocabularies = vocabularies,
475+
.base_dialect = base_dialect,
476+
.subschema = entry.second,
477+
.instance_location = {},
478+
.relative_instance_location = {},
479+
.orphan = false};
466480
this->entries.push_back(std::move(subschema_entry));
467481
}
468482

0 commit comments

Comments
 (0)