Skip to content

Commit 3d66a83

Browse files
committed
[build] Expand clang-tidy coverage
1 parent 49feab0 commit 3d66a83

File tree

8 files changed

+17
-10
lines changed

8 files changed

+17
-10
lines changed

.clang-tidy

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@ Checks: >
1616
bugprone-return-const-ref-from-parameter,
1717
bugprone-suspicious-*,
1818
-bugprone-suspicious-semicolon,
19+
bugprone-switch-missing-default-case,
1920
bugprone-undefined-memory-manipulation,
2021
bugprone-unhandled-self-assignment,
2122
bugprone-unused-raii,
2223
bugprone-use-after-move,
2324
cppcoreguidelines-c-copy-assignment-signature,
25+
cppcoreguidelines-interfaces-global-init,
2426
cppcoreguidelines-misleading-capture-default-by-value,
2527
cppcoreguidelines-noexcept-destructor,
2628
cppcoreguidelines-prefer-member-initializer,
@@ -32,6 +34,7 @@ Checks: >
3234
misc-unused-alias-decls,
3335
misc-unused-using-decls,
3436
modernize-avoid-variadic-functions,
37+
modernize-loop-convert,
3538
modernize-macro-to-enum,
3639
modernize-redundant-void-arg,
3740
modernize-type-traits,
@@ -72,6 +75,7 @@ Checks: >
7275
# modernize-use-override
7376
# modernize-use-ranges
7477
# readability-avoid-return-with-void-value
78+
# readability-convert-member-functions-to-static
7579
# readability-redundant-smartptr-get
7680
# readability-use-anyofallof
7781

src/workerd/api/analytics-engine-impl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ void setDoubles(Message msg, kj::ArrayPtr<double> arr, kj::StringPtr errorPrefix
2020

2121
uint index = 1;
2222
for (auto& item: arr) {
23+
// NOLINTNEXTLINE(bugprone-switch-missing-default-case)
2324
switch (index) {
2425
case 1:
2526
msg.setDouble1(item);
@@ -108,6 +109,7 @@ void setBlobs(Message msg,
108109
sizeSum += value.size();
109110
JSG_REQUIRE(sizeSum <= MAX_CUMULATIVE_BYTES_IN_BLOBS, TypeError, errorPrefix,
110111
"Cumulative size of blobs exceeds ", MAX_CUMULATIVE_BYTES_IN_BLOBS, " bytes).");
112+
// NOLINTNEXTLINE(bugprone-switch-missing-default-case)
111113
switch (index) {
112114
case 1:
113115
msg.setBlob1(value);

src/workerd/api/crypto/aes.c++

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,8 +475,9 @@ class AesCtrKey final: public AesKeyBase {
475475
return *EVP_aes_192_ctr();
476476
case 32:
477477
return *EVP_aes_256_ctr();
478+
default:
479+
KJ_FAIL_ASSERT("CryptoKey has invalid data length");
478480
}
479-
KJ_FAIL_ASSERT("CryptoKey has invalid data length");
480481
}
481482

482483
jsg::BufferSource encryptOrDecrypt(jsg::Lock& js,

src/workerd/api/crypto/ec.c++

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,9 +1120,9 @@ kj::OneOf<jsg::Ref<CryptoKey>, CryptoKeyPair> EdDsaKey::generateKey(jsg::Lock& j
11201120
case NID_X25519:
11211121
return generateKeyImpl<X25519_PUBLIC_VALUE_LEN, X25519_keypair>(js, normalizedName, nid,
11221122
privateKeyUsages, publicKeyUsages, extractablePrivateKey, "X25519"_kj);
1123+
default:
1124+
KJ_FAIL_REQUIRE("ED ", normalizedName, " unimplemented", nid);
11231125
}
1124-
1125-
KJ_FAIL_REQUIRE("ED ", normalizedName, " unimplemented", nid);
11261126
}
11271127

11281128
} // namespace

src/workerd/io/trace.c++

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,8 +1156,8 @@ kj::Maybe<kj::Array<kj::String>> getScriptTagsFromReader(const rpc::Trace::Onset
11561156
if (reader.hasScriptTags()) {
11571157
auto tags = reader.getScriptTags();
11581158
kj::Vector<kj::String> scriptTags(tags.size());
1159-
for (size_t i = 0; i < tags.size(); i++) {
1160-
scriptTags.add(kj::str(tags[i]));
1159+
for (auto tag: tags) {
1160+
scriptTags.add(kj::str(tag));
11611161
}
11621162
return kj::Maybe(scriptTags.releaseAsArray());
11631163
}

src/workerd/jsg/url-test.c++

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1215,8 +1215,8 @@ KJ_TEST("Special scheme URLS") {
12151215
kj::str("file:///example"),
12161216
};
12171217

1218-
for (auto n = 0; n < kj::size(tests); n++) {
1219-
KJ_ASSERT_NONNULL(Url::tryParse(tests[n].asPtr()));
1218+
for (const auto& test: tests) {
1219+
KJ_ASSERT_NONNULL(Url::tryParse(test.asPtr()));
12201220
}
12211221
}
12221222

src/workerd/jsg/value-test.c++

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1219,8 +1219,9 @@ struct ExceptionContext: public ContextGlobalObject {
12191219
return JSG_KJ_EXCEPTION(FAILED, TypeError, "boom");
12201220
case 2:
12211221
return JSG_KJ_EXCEPTION(FAILED, DOMAbortError, "boom");
1222+
default:
1223+
KJ_UNREACHABLE;
12221224
}
1223-
KJ_UNREACHABLE;
12241225
}
12251226

12261227
JSG_RESOURCE_TYPE(ExceptionContext) {

src/workerd/tests/bench-api-headers.c++

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,7 @@ BENCHMARK_F(ApiHeaders, set_append)(benchmark::State& state) {
9292
for (size_t i = 0; i < 1000; ++i) {
9393
auto headers = js.alloc<api::Headers>();
9494
// Set common headers with various representative lengths
95-
for (int n = 0; n < 13; n++) {
96-
auto& h = kHeaders[n];
95+
for (auto& h: kHeaders) {
9796
if (h.append) {
9897
headers->append(env.js, kj::str(h.name), kj::str(h.value));
9998
} else {

0 commit comments

Comments
 (0)