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

Sort includes by category using clang-format #2023

Merged
merged 1 commit into from
May 24, 2019
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
18 changes: 18 additions & 0 deletions .clang-format.base
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,22 @@ BraceWrapping:
BeforeElse: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
SortIncludes: true
IncludeBlocks: Regroup
IncludeCategories:
# Headers in <> without extension.
- Regex: '<([A-Za-z0-9\/-_])+>'
Priority: 5
# Headers in the boost library.
- Regex: '<boost/.*>'
Priority: 4
# Headers in other third party libraries
- Regex: '<(gtest|crypto)/([A-Za-z0-9.\/-_])+>'
Priority: 3
# Headers from nano workspace.
- Regex: '<nano/([A-Za-z0-9.\/-_])+>'
Priority: 2
# Headers in ""
- Regex: '"([A-Za-z0-9.\/-_])+"'
Priority: 1
...
3 changes: 2 additions & 1 deletion nano/core_test/active_transactions.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#include <gtest/gtest.h>
#include <nano/core_test/testutil.hpp>
#include <nano/lib/jsonconfig.hpp>
#include <nano/node/testing.hpp>

#include <gtest/gtest.h>

using namespace std::chrono_literals;

TEST (transaction_counter, validate)
Expand Down
12 changes: 6 additions & 6 deletions nano/core_test/block.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#include <boost/property_tree/json_parser.hpp>

#include <fstream>

#include <gtest/gtest.h>
#include <nano/core_test/testutil.hpp>

#include <nano/lib/interface.h>
#include <nano/node/common.hpp>
#include <nano/node/node.hpp>

#include <gtest/gtest.h>

#include <boost/property_tree/json_parser.hpp>

#include <fstream>

#include <crypto/ed25519-donna/ed25519.h>

TEST (ed25519, signing)
Expand Down
3 changes: 2 additions & 1 deletion nano/core_test/block_store.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#include <gtest/gtest.h>
#include <nano/core_test/testutil.hpp>
#include <nano/crypto_lib/random_pool.hpp>
#include <nano/lib/utility.hpp>
#include <nano/node/common.hpp>
#include <nano/node/node.hpp>
#include <nano/secure/versioning.hpp>

#include <gtest/gtest.h>

#include <fstream>

namespace
Expand Down
3 changes: 2 additions & 1 deletion nano/core_test/conflicts.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#include <gtest/gtest.h>
#include <nano/core_test/testutil.hpp>
#include <nano/node/testing.hpp>

#include <gtest/gtest.h>

using namespace std::chrono_literals;

TEST (conflicts, start_stop)
Expand Down
4 changes: 2 additions & 2 deletions nano/core_test/difficulty.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <gtest/gtest.h>

#include <nano/lib/numbers.hpp>

#include <gtest/gtest.h>

TEST (difficulty, multipliers)
{
{
Expand Down
3 changes: 2 additions & 1 deletion nano/core_test/gap_cache.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#include <gtest/gtest.h>
#include <nano/core_test/testutil.hpp>
#include <nano/node/testing.hpp>

#include <gtest/gtest.h>

using namespace std::chrono_literals;

TEST (gap_cache, add_new)
Expand Down
8 changes: 4 additions & 4 deletions nano/core_test/interface.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#include <gtest/gtest.h>

#include <memory>

#include <nano/lib/blocks.hpp>
#include <nano/lib/interface.h>
#include <nano/lib/numbers.hpp>
#include <nano/lib/work.hpp>

#include <gtest/gtest.h>

#include <memory>

TEST (interface, xrb_uint128_to_dec)
{
nano::uint128_union zero (0);
Expand Down
11 changes: 7 additions & 4 deletions nano/core_test/ipc.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
#include <boost/property_tree/json_parser.hpp>
#include <chrono>
#include <gtest/gtest.h>
#include <memory>
#include <nano/core_test/testutil.hpp>
#include <nano/lib/ipc_client.hpp>
#include <nano/node/ipc.hpp>
#include <nano/node/testing.hpp>
#include <nano/rpc/rpc.hpp>

#include <gtest/gtest.h>

#include <boost/property_tree/json_parser.hpp>

#include <chrono>
#include <memory>
#include <sstream>
#include <vector>

Expand Down
7 changes: 4 additions & 3 deletions nano/core_test/ledger.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#include <crypto/cryptopp/filters.h>
#include <crypto/cryptopp/randpool.h>
#include <gtest/gtest.h>
#include <nano/core_test/testutil.hpp>
#include <nano/node/stats.hpp>
#include <nano/node/testing.hpp>

#include <crypto/cryptopp/filters.h>
#include <crypto/cryptopp/randpool.h>
#include <gtest/gtest.h>

using namespace std::chrono_literals;

// Init returns an error if it can't open files at the path
Expand Down
9 changes: 6 additions & 3 deletions nano/core_test/logger.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
#include <boost/log/utility/setup/console.hpp>
#include <chrono>
#include <gtest/gtest.h>
#include <nano/core_test/testutil.hpp>
#include <nano/node/logging.hpp>
#include <nano/secure/utility.hpp>

#include <gtest/gtest.h>

#include <boost/log/utility/setup/console.hpp>

#include <chrono>
#include <regex>

using namespace std::chrono_literals;
Expand Down
4 changes: 2 additions & 2 deletions nano/core_test/message.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <gtest/gtest.h>

#include <nano/node/common.hpp>

#include <gtest/gtest.h>

TEST (message, keepalive_serialization)
{
nano::keepalive request1;
Expand Down
3 changes: 2 additions & 1 deletion nano/core_test/message_parser.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <gtest/gtest.h>
#include <nano/node/testing.hpp>

#include <gtest/gtest.h>

namespace
{
class test_visitor : public nano::message_visitor
Expand Down
8 changes: 5 additions & 3 deletions nano/core_test/network.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#include <boost/iostreams/stream_buffer.hpp>
#include <boost/thread.hpp>
#include <gtest/gtest.h>
#include <nano/core_test/testutil.hpp>
#include <nano/node/testing.hpp>
#include <nano/node/transport/udp.hpp>

#include <gtest/gtest.h>

#include <boost/iostreams/stream_buffer.hpp>
#include <boost/thread.hpp>

using namespace std::chrono_literals;

TEST (network, tcp_connection)
Expand Down
6 changes: 4 additions & 2 deletions nano/core_test/node.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
#include <gtest/gtest.h>
#include <nano/core_test/testutil.hpp>
#include <nano/lib/jsonconfig.hpp>
#include <nano/node/testing.hpp>
#include <nano/node/transport/udp.hpp>
#include <nano/node/working.hpp>
#include <numeric>

#include <gtest/gtest.h>

#include <boost/make_shared.hpp>
#include <boost/polymorphic_cast.hpp>

#include <numeric>

using namespace std::chrono_literals;

namespace
Expand Down
3 changes: 2 additions & 1 deletion nano/core_test/peer_container.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#include <gtest/gtest.h>
#include <nano/node/node.hpp>
#include <nano/node/testing.hpp>

#include <gtest/gtest.h>

TEST (peer_container, empty_peers)
{
nano::system system (24000, 1);
Expand Down
3 changes: 2 additions & 1 deletion nano/core_test/processor_service.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#include <gtest/gtest.h>
#include <nano/core_test/testutil.hpp>
#include <nano/node/node.hpp>

#include <gtest/gtest.h>

#include <atomic>
#include <condition_variable>
#include <future>
Expand Down
4 changes: 2 additions & 2 deletions nano/core_test/signing.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <gtest/gtest.h>

#include <nano/node/node.hpp>

#include <gtest/gtest.h>

TEST (signature_checker, empty)
{
nano::signature_checker checker (0);
Expand Down
6 changes: 4 additions & 2 deletions nano/core_test/socket.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#include <boost/thread.hpp>
#include <gtest/gtest.h>
#include <nano/core_test/testutil.hpp>
#include <nano/node/socket.hpp>
#include <nano/node/testing.hpp>

#include <gtest/gtest.h>

#include <boost/thread.hpp>

using namespace std::chrono_literals;

TEST (socket, concurrent_writes)
Expand Down
6 changes: 4 additions & 2 deletions nano/core_test/testutil.hpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
#pragma once

#include <atomic>
#include <nano/lib/timer.hpp>

#include <boost/iostreams/concepts.hpp>
#include <boost/log/sources/logger.hpp>
#include <boost/log/utility/setup/console.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <atomic>
#include <condition_variable>
#include <mutex>
#include <nano/lib/timer.hpp>
#include <string>

#define GTEST_TEST_ERROR_CODE(expression, text, actual, expected, fail) \
Expand Down
6 changes: 4 additions & 2 deletions nano/core_test/timer.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#include <chrono>
#include <gtest/gtest.h>
#include <nano/core_test/testutil.hpp>
#include <nano/lib/timer.hpp>

#include <gtest/gtest.h>

#include <chrono>
#include <thread>

/* Tests for the timer utility. Note that we use sleep_for in the tests, which
Expand Down
4 changes: 2 additions & 2 deletions nano/core_test/uint256_union.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#include <gtest/gtest.h>

#include <nano/core_test/testutil.hpp>
#include <nano/lib/interface.h>
#include <nano/lib/jsonconfig.hpp>
#include <nano/secure/common.hpp>

#include <gtest/gtest.h>

namespace
{
template <typename Union, typename Bound>
Expand Down
4 changes: 2 additions & 2 deletions nano/core_test/versioning.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include <gtest/gtest.h>

#include <nano/secure/blockstore.hpp>
#include <nano/secure/versioning.hpp>

#include <gtest/gtest.h>

TEST (versioning, account_info_v1)
{
auto file (nano::unique_path ());
Expand Down
7 changes: 4 additions & 3 deletions nano/core_test/wallet.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#include <gtest/gtest.h>

#include <fstream>
#include <nano/core_test/testutil.hpp>
#include <nano/crypto_lib/random_pool.hpp>
#include <nano/node/testing.hpp>

#include <gtest/gtest.h>

#include <fstream>

using namespace std::chrono_literals;

TEST (wallet, no_key)
Expand Down
4 changes: 2 additions & 2 deletions nano/core_test/wallets.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#include <gtest/gtest.h>

#include <nano/core_test/testutil.hpp>
#include <nano/node/node.hpp>
#include <nano/node/testing.hpp>
#include <nano/secure/versioning.hpp>

#include <gtest/gtest.h>

#include <boost/polymorphic_cast.hpp>

using namespace std::chrono_literals;
Expand Down
13 changes: 8 additions & 5 deletions nano/core_test/websocket.cpp
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
#include <nano/core_test/testutil.hpp>
#include <nano/crypto_lib/random_pool.hpp>
#include <nano/node/testing.hpp>
#include <nano/node/websocket.hpp>

#include <gtest/gtest.h>

#include <boost/asio.hpp>
#include <boost/asio/connect.hpp>
#include <boost/asio/ip/tcp.hpp>
#include <boost/beast/core.hpp>
#include <boost/beast/websocket.hpp>
#include <boost/property_tree/json_parser.hpp>

#include <chrono>
#include <condition_variable>
#include <cstdlib>
#include <gtest/gtest.h>
#include <iostream>
#include <memory>
#include <nano/core_test/testutil.hpp>
#include <nano/crypto_lib/random_pool.hpp>
#include <nano/node/testing.hpp>
#include <nano/node/websocket.hpp>
#include <sstream>
#include <string>
#include <vector>
Expand Down
4 changes: 2 additions & 2 deletions nano/core_test/work_pool.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#include <gtest/gtest.h>

#include <nano/crypto_lib/random_pool.hpp>
#include <nano/lib/jsonconfig.hpp>
#include <nano/lib/timer.hpp>
#include <nano/node/node.hpp>
#include <nano/node/wallet.hpp>

#include <gtest/gtest.h>

TEST (work, one)
{
nano::network_constants network_constants;
Expand Down
3 changes: 2 additions & 1 deletion nano/crypto_lib/interface.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <crypto/blake2/blake2.h>
#include <nano/crypto_lib/random_pool.hpp>

#include <crypto/blake2/blake2.h>

extern "C" {
#include <crypto/ed25519-donna/ed25519-hash-custom.h>
void ed25519_randombytes_unsafe (void * out, size_t outlen)
Expand Down
Loading