Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use clang-format to sort includes #2725

Merged
merged 3 commits into from
Sep 17, 2024
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
32 changes: 19 additions & 13 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,24 @@ WhitespaceSensitiveMacros:
- JSG_STRUCT_TS_DEFINE
AllowShortFunctionsOnASingleLine: Empty

# We should have "true" here but adding an include header would result in too many changed lines.
# Once we turn this on we should use IncludeCategories so that things are consistently sorted.
# For example, to protect against brittle headers (a header not including everything its using
# because existing users happened to include a dependency for it), one could use the following
# order:
# local folder files
# project files
# 3p dependency includes
# standard language headers (put kj/ here?)
# system headers
# While this would be ideal it's also important to note that this isn't the (non-documented) style
# that KJ uses, so it may be worth documenting the style & making it consistent.
SortIncludes: false
SortIncludes: true
IncludeBlocks: Regroup
IncludeCategories:
# c++ system headers
- Regex: <[a-zA-Z0-9_]+>
Priority: 5
# kj/capnp headers
- Regex: <(kj|capnp)/.+>
Priority: 4
# 3rd party headers
- Regex: <.+>
Priority: 3
# workerd headers
- Regex: <workerd/.+>
Priority: 2
# local headers
- Regex: '".*"'
Priority: 1

AllowShortIfStatementsOnASingleLine: true
AllowShortLoopsOnASingleLine: true
Expand Down Expand Up @@ -95,6 +100,7 @@ SpaceBeforeCtorInitializerColon: false
SpaceBeforeInheritanceColon: false
SpaceBeforeParens: ControlStatementsExceptControlMacros
SpaceBeforeRangeBasedForLoopColon: false
SpaceBeforeCpp11BracedList: false
SpacesBeforeTrailingComments: 2
---
# Some files with embedded typescript are incorrectly recognized by clang-format as Objective-C
Expand Down
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ f457f19039b82536b35659c1f9cb898a198e6cd1

# Apply ruff linter to the project
893774eab71fd7be5000436ff2ff0b5dd85ef073

# Use clang-format to sort includes.
ecb198077ba93a2579031d562cb2c70128bbef15
10 changes: 5 additions & 5 deletions src/workerd/api/actor-state-iocontext-test.c++
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
// Licensed under the Apache 2.0 license found in the LICENSE file or at:
// https://opensource.org/licenses/Apache-2.0

#include <algorithm>
#include <workerd/api/actor-state.h>
#include <workerd/io/actor-id.h>
#include <workerd/tests/test-fixture.h>

#include <kj/test.h>
#include <kj/encoding.h>
#include <kj/test.h>

#include <workerd/api/actor-state.h>
#include <workerd/tests/test-fixture.h>
#include <workerd/io/actor-id.h>
#include <algorithm>

namespace workerd::api {
namespace {
Expand Down
17 changes: 8 additions & 9 deletions src/workerd/api/actor-state-test.c++
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,21 @@
// Licensed under the Apache 2.0 license found in the LICENSE file or at:
// https://opensource.org/licenses/Apache-2.0

#include <kj/test.h>
#include <kj/encoding.h>

#include <fstream>
#include <iostream>

#include <workerd/api/util.h>
#include <workerd/api/actor-state.h>
#include <workerd/api/util.h>
#include <workerd/jsg/jsg-test.h>
#include <workerd/jsg/jsg.h>
#include <workerd/jsg/ser.h>
#include <workerd/jsg/setup.h>
#include <workerd/jsg/jsg-test.h>

#include <capnp/message.h>
#include <capnp/rpc.h>
#include <capnp/rpc-twoparty.h>
#include <capnp/rpc.h>
#include <kj/encoding.h>
#include <kj/test.h>

#include <fstream>
#include <iostream>

namespace workerd::api {
namespace {
Expand Down
16 changes: 9 additions & 7 deletions src/workerd/api/actor-state.c++
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,22 @@
// https://opensource.org/licenses/Apache-2.0

#include "actor-state.h"

#include "actor.h"
#include "sql.h"
#include "util.h"
#include <workerd/jsg/jsg.h>
#include <workerd/jsg/ser.h>
#include <workerd/jsg/util.h>

#include <v8.h>
#include <workerd/api/web-socket.h>
#include <workerd/io/actor-cache.h>
#include <workerd/io/actor-id.h>
#include <workerd/io/actor-storage.h>
#include <workerd/io/actor-sqlite.h>
#include "sql.h"
#include <workerd/api/web-socket.h>
#include <workerd/io/hibernation-manager.h>
#include <workerd/io/actor-storage.h>
#include <workerd/io/features.h>
#include <workerd/io/hibernation-manager.h>
#include <workerd/jsg/jsg.h>
#include <workerd/jsg/ser.h>
#include <workerd/jsg/util.h>

namespace workerd::api {

Expand Down
5 changes: 3 additions & 2 deletions src/workerd/api/actor-state.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
//
// See actor.h for APIs used by other Workers to talk to Actors.

#include <workerd/jsg/jsg.h>
#include <workerd/io/actor-cache.h>
#include <workerd/io/actor-id.h>
#include <workerd/io/compatibility-date.capnp.h>
#include <workerd/io/io-own.h>
#include <workerd/io/worker.h>
#include <workerd/jsg/jsg.h>

#include <kj/async.h>
#include <workerd/io/actor-cache.h>

namespace workerd::api {
class SqlStorage;
Expand Down
9 changes: 6 additions & 3 deletions src/workerd/api/actor.c++
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@
// https://opensource.org/licenses/Apache-2.0

#include "actor.h"

#include "util.h"

#include <workerd/io/features.h>
#include <kj/encoding.h>
#include <kj/compat/http.h>

#include <capnp/compat/byte-stream.h>
#include <capnp/compat/http-over-capnp.h>
#include <capnp/schema.h>
#include <capnp/message.h>
#include <capnp/schema.h>
#include <kj/compat/http.h>
#include <kj/encoding.h>

namespace workerd::api {

Expand Down
7 changes: 4 additions & 3 deletions src/workerd/api/actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@
// to expect something that looked more specifically like Erlang, whereas our actors are much more
// abstractly related.

#include <capnp/compat/byte-stream.h>
#include <capnp/compat/http-over-capnp.h>
#include <workerd/api/http.h>
#include <workerd/api/worker-rpc.h>
#include <workerd/jsg/jsg.h>
#include <workerd/io/actor-id.h>
#include <workerd/jsg/jsg.h>

#include <capnp/compat/byte-stream.h>
#include <capnp/compat/http-over-capnp.h>

namespace workerd {
template <typename T>
Expand Down
1 change: 1 addition & 0 deletions src/workerd/api/analytics-engine.c++
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// https://opensource.org/licenses/Apache-2.0

#include "analytics-engine.h"

#include <workerd/io/io-context.h>

namespace workerd::api {
Expand Down
4 changes: 2 additions & 2 deletions src/workerd/api/analytics-engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

#pragma once

#include <workerd/api/util.h>
#include <workerd/api/analytics-engine-impl.h>
#include <workerd/jsg/jsg.h>
#include <workerd/api/analytics-engine.capnp.h>
#include <workerd/api/util.h>
#include <workerd/jsg/jsg.h>

namespace workerd::api {

Expand Down
9 changes: 5 additions & 4 deletions src/workerd/api/api-rtti-test.c++
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
// Licensed under the Apache 2.0 license found in the LICENSE file or at:
// https://opensource.org/licenses/Apache-2.0

#include <kj/test.h>
#include <workerd/api/actor.h>
#include <workerd/api/actor-state.h>
#include <workerd/api/actor.h>
#include <workerd/api/cache.h>
#include <workerd/api/crypto/crypto.h>
#include <workerd/api/encoding.h>
Expand All @@ -14,15 +13,17 @@
#include <workerd/api/html-rewriter.h>
#include <workerd/api/queue.h>
#include <workerd/api/scheduled.h>
#include <workerd/api/streams.h>
#include <workerd/api/sockets.h>
#include <workerd/api/sql.h>
#include <workerd/api/streams.h>
#include <workerd/api/streams/standard.h>
#include <workerd/api/trace.h>
#include <workerd/api/url-standard.h>
#include <workerd/api/urlpattern.h>
#include <workerd/jsg/rtti.h>
#include <workerd/io/compatibility-date.h>
#include <workerd/jsg/rtti.h>

#include <kj/test.h>

// Test building rtti for various APIs.

Expand Down
10 changes: 5 additions & 5 deletions src/workerd/api/basics-test.c++
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
// test without pulling in the world.
#define WORKERD_API_BASICS_TEST 1

#include "basics.h"
#include "actor.h"
#include "actor-state.h"
#include "actor.h"
#include "basics.h"
#include "util.h"
#include <workerd/jsg/jsg.h>
#include <workerd/jsg/jsg-test.h>
#include <workerd/jsg/dom-exception.h>

#include <workerd/io/promise-wrapper.h>
#include <workerd/jsg/jsg-test.h>
#include <workerd/jsg/jsg.h>

namespace workerd::api {
namespace {
Expand Down
7 changes: 5 additions & 2 deletions src/workerd/api/basics.c++
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
// Licensed under the Apache 2.0 license found in the LICENSE file or at:
// https://opensource.org/licenses/Apache-2.0

#include "actor-state.h"
#include "basics.h"

#include "actor-state.h"
#include "global-scope.h"

#include <workerd/io/io-context.h>

#include <kj/async.h>
#include <kj/vector.h>
#include <workerd/io/io-context.h>

namespace workerd::api {

Expand Down
5 changes: 3 additions & 2 deletions src/workerd/api/basics.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
//
// TODO(cleanp): Rename to events.h?

#include <workerd/jsg/jsg.h>
#include <workerd/io/compatibility-date.capnp.h>
#include <workerd/io/io-own.h>
#include <workerd/jsg/jsg.h>
#include <workerd/util/canceler.h>

#include <kj/function.h>
#include <kj/map.h>
#include <workerd/io/compatibility-date.capnp.h>

namespace workerd::api {

Expand Down
2 changes: 2 additions & 0 deletions src/workerd/api/blob.c++
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
// https://opensource.org/licenses/Apache-2.0

#include "blob.h"

#include "util.h"

#include <workerd/api/streams/readable.h>
#include <workerd/io/observer.h>
#include <workerd/util/mimetype.h>
Expand Down
2 changes: 1 addition & 1 deletion src/workerd/api/blob.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

#pragma once

#include <workerd/jsg/jsg.h>
#include <workerd/io/compatibility-date.capnp.h>
#include <workerd/jsg/jsg.h>

namespace workerd::api {

Expand Down
5 changes: 4 additions & 1 deletion src/workerd/api/cache.c++
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
// https://opensource.org/licenses/Apache-2.0

#include "cache.h"

#include "util.h"
#include <kj/encoding.h>

#include <workerd/io/io-context.h>

#include <kj/encoding.h>

namespace workerd::api {

// =======================================================================================
Expand Down
3 changes: 2 additions & 1 deletion src/workerd/api/cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@

#pragma once

#include <workerd/jsg/jsg.h>
#include "http.h"

#include <workerd/jsg/jsg.h>

namespace workerd::api {

// =======================================================================================
Expand Down
1 change: 1 addition & 0 deletions src/workerd/api/cf-property-test.c++
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// https://opensource.org/licenses/Apache-2.0

#include "cf-property.h"

#include <workerd/jsg/jsg.h>
#include <workerd/tests/test-fixture.h>

Expand Down
1 change: 1 addition & 0 deletions src/workerd/api/cf-property.c++
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// https://opensource.org/licenses/Apache-2.0

#include "cf-property.h"

#include <workerd/io/features.h>

namespace workerd::api {
Expand Down
10 changes: 6 additions & 4 deletions src/workerd/api/crypto/aes-test.c++
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
// Licensed under the Apache 2.0 license found in the LICENSE file or at:
// https://opensource.org/licenses/Apache-2.0

#include <kj/test.h>

#include "impl.h"
#include "crypto.h"
#include "impl.h"

#include <workerd/api/util.h>
#include <workerd/jsg/jsg-test.h>
#include <workerd/jsg/jsg.h>
#include <workerd/jsg/setup.h>
#include <workerd/jsg/jsg-test.h>

#include <kj/test.h>

#include <array>

namespace workerd::api {
Expand Down
6 changes: 4 additions & 2 deletions src/workerd/api/crypto/aes.c++
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@
// https://opensource.org/licenses/Apache-2.0

#include "impl.h"
#include <algorithm>
#include <cstdint>

#include <openssl/aes.h>
#include <openssl/base.h>
#include <openssl/bn.h>
#include <openssl/cipher.h>
#include <openssl/mem.h>
#include <workerd/io/io-context.h>

#include <algorithm>
#include <cstdint>

namespace workerd::api {
namespace {
auto lookupAesCbcType(uint bitLength) {
Expand Down
Loading
Loading