Skip to content

Commit 93c82c1

Browse files
committed
Merge branch 'enable-bugprone-clang-tidy-checks' into alternate-main
2 parents bf7e78c + cb48e8c commit 93c82c1

File tree

7 files changed

+25
-41
lines changed

7 files changed

+25
-41
lines changed

cmake/common/clang-tidy.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"Checks": "-*, concurrency-*, modernize-*, performance-*, portability-*",
2+
"Checks": "-*, bugprone-*, -bugprone-easily-swappable-parameters,-bugprone-unchecked-optional-access, concurrency-*, modernize-*, performance-*, portability-*",
33
"WarningsAsErrors": "*",
44
"FormatStyle": "none",
55
"UseColor": true

src/core/gzip/gzip.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ auto gzip(std::string_view input) -> std::optional<std::string> {
2929
stream.next_out = reinterpret_cast<Bytef *>(buffer.data());
3030
stream.avail_out = sizeof(buffer);
3131
code = deflate(&stream, Z_FINISH);
32-
compressed.write(buffer.data(), sizeof(buffer) - stream.avail_out);
32+
compressed.write(buffer.data(),
33+
static_cast<long>(sizeof(buffer)) - stream.avail_out);
3334
} while (code == Z_OK);
3435

3536
if (code != Z_STREAM_END) {

src/core/json/include/sourcemeta/core/json_object.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,7 @@ template <typename Key, typename Value, typename Hash> class JSONObject {
9191

9292
for (const auto &entry : this->data) {
9393
const auto *result{other.try_at(entry.first, entry.hash)};
94-
if (!result) {
95-
return false;
96-
} else if (*result != entry.second) {
94+
if (!result || *result != entry.second) {
9795
return false;
9896
}
9997
}

src/core/json/parser.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -650,21 +650,21 @@ auto parse_number(
650650

651651
#define CALLBACK_PRE(value_type, value) \
652652
if (callback) { \
653-
assert(value.is_null() || value.is_string() || value.is_integer()); \
653+
assert((value).is_null() || (value).is_string() || (value).is_integer()); \
654654
callback(JSON::ParsePhase::Pre, JSON::Type::value_type, line, column, \
655655
value); \
656656
}
657657

658658
#define CALLBACK_PRE_WITH_POSITION(value_type, line, column, value) \
659659
if (callback) { \
660-
assert(value.is_null() || value.is_string() || value.is_integer()); \
660+
assert((value).is_null() || (value).is_string() || (value).is_integer()); \
661661
callback(JSON::ParsePhase::Pre, JSON::Type::value_type, line, column, \
662662
value); \
663663
}
664664

665665
#define CALLBACK_POST(value_type, value) \
666666
if (callback) { \
667-
assert(value.type() == JSON::Type::value_type); \
667+
assert((value).type() == JSON::Type::value_type); \
668668
callback(JSON::ParsePhase::Post, JSON::Type::value_type, line, column, \
669669
value); \
670670
}

src/core/jsonschema/frame.cc

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,9 @@ auto find_anchors(const sourcemeta::core::JSON &schema,
7777
if (identifier.is_fragment_only()) {
7878
result.insert(
7979
{sourcemeta::core::JSON::String{
80-
identifier.fragment()
81-
.value()}, // NOLINT(bugprone-unchecked-optional-access):
82-
// Check for optional is happening
83-
// inside is_fragment_only()
80+
// Check for optional is happening inside is_fragment_only()
81+
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
82+
identifier.fragment().value()},
8483
AnchorType::Static});
8584
}
8685
}
@@ -96,10 +95,9 @@ auto find_anchors(const sourcemeta::core::JSON &schema,
9695
if (identifier.is_fragment_only()) {
9796
result.insert(
9897
{sourcemeta::core::JSON::String{
99-
identifier.fragment()
100-
.value()}, // NOLINT(bugprone-unchecked-optional-access):
101-
// Check for optional is happening
102-
// inside is_fragment_only()
98+
// Check for optional is happening inside is_fragment_only()
99+
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
100+
identifier.fragment().value()},
103101
AnchorType::Static});
104102
}
105103
}

src/core/jsonschema/official_resolver.in.cc

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,15 @@
33
auto sourcemeta::core::schema_official_resolver(std::string_view identifier)
44
-> std::optional<sourcemeta::core::JSON> {
55
// JSON Schema 2020-12
6-
if (identifier == "https://json-schema.org/draft/2020-12/schema") {
6+
if (identifier == "https://json-schema.org/draft/2020-12/schema" ||
7+
// Just for compatibility given that this is such a common issue
8+
identifier == "https://json-schema.org/draft/2020-12/schema#") {
79
return sourcemeta::core::parse_json(
810
R"EOF(@METASCHEMA_JSONSCHEMA_2020_12@)EOF");
911
} else if (identifier ==
10-
"https://json-schema.org/draft/2020-12/hyper-schema") {
12+
"https://json-schema.org/draft/2020-12/hyper-schema" ||
13+
identifier ==
14+
"https://json-schema.org/draft/2020-12/hyper-schema#") {
1115
return sourcemeta::core::parse_json(
1216
R"EOF(@METASCHEMA_HYPERSCHEMA_2020_12@)EOF");
1317
} else if (identifier ==
@@ -52,21 +56,16 @@ auto sourcemeta::core::schema_official_resolver(std::string_view identifier)
5256
return sourcemeta::core::parse_json(
5357
R"EOF(@METASCHEMA_JSONSCHEMA_2020_12_OUTPUT@)EOF");
5458

55-
// Just for compatibility given that this is such a common issue
56-
} else if (identifier == "https://json-schema.org/draft/2020-12/schema#") {
57-
return sourcemeta::core::parse_json(
58-
R"EOF(@METASCHEMA_JSONSCHEMA_2020_12@)EOF");
59-
} else if (identifier ==
60-
"https://json-schema.org/draft/2020-12/hyper-schema#") {
61-
return sourcemeta::core::parse_json(
62-
R"EOF(@METASCHEMA_HYPERSCHEMA_2020_12@)EOF");
63-
6459
// JSON Schema 2019-09
65-
} else if (identifier == "https://json-schema.org/draft/2019-09/schema") {
60+
} else if (identifier == "https://json-schema.org/draft/2019-09/schema" ||
61+
// Just for compatibility given that this is such a common issue
62+
identifier == "https://json-schema.org/draft/2019-09/schema#") {
6663
return sourcemeta::core::parse_json(
6764
R"EOF(@METASCHEMA_JSONSCHEMA_2019_09@)EOF");
6865
} else if (identifier ==
69-
"https://json-schema.org/draft/2019-09/hyper-schema") {
66+
"https://json-schema.org/draft/2019-09/hyper-schema" ||
67+
identifier ==
68+
"https://json-schema.org/draft/2019-09/hyper-schema#") {
7069
return sourcemeta::core::parse_json(
7170
R"EOF(@METASCHEMA_HYPERSCHEMA_2019_09@)EOF");
7271
} else if (identifier ==
@@ -106,16 +105,6 @@ auto sourcemeta::core::schema_official_resolver(std::string_view identifier)
106105
"https://json-schema.org/draft/2019-09/output/hyper-schema") {
107106
return sourcemeta::core::parse_json(
108107
R"EOF(@METASCHEMA_HYPERSCHEMA_2019_09_OUTPUT@)EOF");
109-
110-
// Just for compatibility given that this is such a common issue
111-
} else if (identifier == "https://json-schema.org/draft/2019-09/schema#") {
112-
return sourcemeta::core::parse_json(
113-
R"EOF(@METASCHEMA_JSONSCHEMA_2019_09@)EOF");
114-
} else if (identifier ==
115-
"https://json-schema.org/draft/2019-09/hyper-schema#") {
116-
return sourcemeta::core::parse_json(
117-
R"EOF(@METASCHEMA_HYPERSCHEMA_2019_09@)EOF");
118-
119108
// JSON Schema Draft7
120109
} else if (identifier == "http://json-schema.org/draft-07/schema#" ||
121110
identifier == "http://json-schema.org/draft-07/schema") {

src/core/uri/uri.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -688,8 +688,6 @@ auto URI::try_resolve_from(const URI &base) -> URI & {
688688
this->scheme_ = base.scheme_;
689689
this->query_ = base.query_;
690690
return *this;
691-
} else if (base.path().has_value() && base.path().value().starts_with("..")) {
692-
return *this;
693691
} else if (base.is_relative() && this->is_relative() &&
694692
base.path_.has_value() && this->path_.has_value() &&
695693
this->path_.value().find('/') == std::string::npos &&

0 commit comments

Comments
 (0)