Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Checks: >
misc-unused-alias-decls,
misc-unused-using-decls,
modernize-avoid-variadic-functions,
modernize-loop-convert,
modernize-macro-to-enum,
modernize-redundant-void-arg,
modernize-type-traits,
Expand Down Expand Up @@ -72,6 +73,7 @@ Checks: >
# modernize-use-override
# modernize-use-ranges
# readability-avoid-return-with-void-value
# readability-convert-member-functions-to-static
# readability-redundant-smartptr-get
# readability-use-anyofallof

Expand Down
3 changes: 3 additions & 0 deletions src/workerd/api/form-data.c++
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,9 @@ void FormData::forEach(jsg::Lock& js,
// it up. Using the classic for (;;) syntax here allows for that. However, this does
// mean that it's possible for a user to trigger an infinite loop here if new items
// are added to the search params unconditionally on each iteration.
// Silence clang-tidy warning, using an iterator would not work correctly if callback
// increases the array size.
// NOLINTNEXTLINE(modernize-loop-convert)
for (size_t i = 0; i < this->data.size(); i++) {
auto& [key, value] = this->data[i];
callback(js, clone(js, value), key, JSG_THIS);
Expand Down
3 changes: 3 additions & 0 deletions src/workerd/api/url.c++
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,9 @@ void URLSearchParams::forEach(jsg::Lock& js,
// it up. Using the classic for (;;) syntax here allows for that. However, this does
// mean that it's possible for a user to trigger an infinite loop here if new items
// are added to the search params unconditionally on each iteration.
// Silence clang-tidy warning, using an iterator would not work correctly if callback
// increases the size of data.
// NOLINTNEXTLINE(modernize-loop-convert)
for (size_t i = 0; i < this->url->query.size(); i++) {
auto& [key, value] = this->url->query[i];
callback(js, value, key, JSG_THIS);
Expand Down
8 changes: 4 additions & 4 deletions src/workerd/io/trace.c++
Original file line number Diff line number Diff line change
Expand Up @@ -1156,8 +1156,8 @@ kj::Maybe<kj::Array<kj::String>> getScriptTagsFromReader(const rpc::Trace::Onset
if (reader.hasScriptTags()) {
auto tags = reader.getScriptTags();
kj::Vector<kj::String> scriptTags(tags.size());
for (size_t i = 0; i < tags.size(); i++) {
scriptTags.add(kj::str(tags[i]));
for (const auto& tag: tags) {
scriptTags.add(kj::str(tag));
}
return kj::Maybe(scriptTags.releaseAsArray());
}
Expand Down Expand Up @@ -1339,8 +1339,8 @@ TailEvent::Event readEventFromTailEvent(const rpc::Trace::TailEvent::Reader& rea
case rpc::Trace::TailEvent::Event::ATTRIBUTE: {
auto listReader = event.getAttribute();
kj::Vector<Attribute> attrs(listReader.size());
for (size_t n = 0; n < listReader.size(); n++) {
attrs.add(Attribute(listReader[n]));
for (const auto& reader: listReader) {
attrs.add(Attribute(reader));
}
return attrs.releaseAsArray();
}
Expand Down
4 changes: 2 additions & 2 deletions src/workerd/jsg/url-test.c++
Original file line number Diff line number Diff line change
Expand Up @@ -1215,8 +1215,8 @@ KJ_TEST("Special scheme URLS") {
kj::str("file:///example"),
};

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

Expand Down
3 changes: 1 addition & 2 deletions src/workerd/tests/bench-api-headers.c++
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@ BENCHMARK_F(ApiHeaders, set_append)(benchmark::State& state) {
for (size_t i = 0; i < 1000; ++i) {
auto headers = js.alloc<api::Headers>();
// Set common headers with various representative lengths
for (int n = 0; n < 13; n++) {
auto& h = kHeaders[n];
for (auto& h: kHeaders) {
if (h.append) {
headers->append(env.js, kj::str(h.name), kj::str(h.value));
} else {
Expand Down
4 changes: 4 additions & 0 deletions src/workerd/util/ring-buffer-test.c++
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ KJ_TEST("RingBuffer iterator basic") {
}

int expected = 0;
// Using verbose syntax to test iterator
// NOLINTNEXTLINE(modernize-loop-convert)
for (auto it = buffer.begin(); it != buffer.end(); ++it) {
KJ_EXPECT(*it == expected++);
}
Expand Down Expand Up @@ -165,6 +167,8 @@ KJ_TEST("RingBuffer const_iterator") {
const auto& constBuffer = buffer;

int expected = 0;
// Using verbose syntax to test iterator
// NOLINTNEXTLINE(modernize-loop-convert)
for (auto it = constBuffer.begin(); it != constBuffer.end(); ++it) {
KJ_EXPECT(*it == expected++);
}
Expand Down
Loading