diff --git a/.github/workflows/analyzers.yml b/.github/workflows/analyzers.yml index 8531a16032..52d9bb3829 100644 --- a/.github/workflows/analyzers.yml +++ b/.github/workflows/analyzers.yml @@ -1,36 +1,51 @@ name: Static Analyzers -on: [push, pull_request] +on: [ push, pull_request ] jobs: clang_format: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository steps: - - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 #v3.1.0 - - name: Installing clang-format 12 + - name: Checkout + uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 #v3.1.0 + + - name: Installing clang-format env: DEBIAN_FRONTEND: noninteractive - run: sudo apt-get install clang-format-12 + run: | + wget https://apt.llvm.org/llvm.sh + chmod +x llvm.sh + sudo ./llvm.sh 17 + sudo apt install clang-format-17 + - name: Check clang-format run: ci/clang-format-check.sh - + + cmake_format: runs-on: ubuntu-20.04 if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository steps: - - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 #v3.1.0 - - uses: actions/setup-python@13ae5bb136fac2878aff31522b9efb785519f984 #v4.3.0 - with: + - name: Checkout + uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 #v3.1.0 + + - name: Setup Python + uses: actions/setup-python@13ae5bb136fac2878aff31522b9efb785519f984 #v4.3.0 + with: python-version: '3.x' architecture: 'x64' - - uses: BSFishy/pip-action@8f2d471d809dc20b6ada98c91910b6ae6243f318 - with: + + - name: Install cmake-format + uses: BSFishy/pip-action@8f2d471d809dc20b6ada98c91910b6ae6243f318 + with: packages: | cmake-format + - name: Check cmake-format run: ci/cmake-format-check.sh + code_inspector: runs-on: ubuntu-20.04 if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository diff --git a/ci/impl/clang-format.sh b/ci/impl/clang-format.sh index 3a3d69626e..bae7ad070f 100644 --- a/ci/impl/clang-format.sh +++ b/ci/impl/clang-format.sh @@ -3,7 +3,7 @@ ################################################################################################### CLANG_FORMAT="" -CLANG_FORMAT_VERSION="12" +CLANG_FORMAT_VERSION="17" ################################################################################################### diff --git a/nano/lib/errors.cpp b/nano/lib/errors.cpp index 822722be62..ffcb10a82b 100644 --- a/nano/lib/errors.cpp +++ b/nano/lib/errors.cpp @@ -373,9 +373,9 @@ nano::error::operator std::string () const } /** - * Get error message, or an empty string if there's no error. If a custom error message is set, - * that will be returned, otherwise the error_code#message() is returned. - */ + * Get error message, or an empty string if there's no error. If a custom error message is set, + * that will be returned, otherwise the error_code#message() is returned. + */ std::string nano::error::get_message () const { std::string res = message; diff --git a/nano/lib/ipc_client.hpp b/nano/lib/ipc_client.hpp index b3f5f93e1a..b0e2277fc3 100644 --- a/nano/lib/ipc_client.hpp +++ b/nano/lib/ipc_client.hpp @@ -84,7 +84,7 @@ namespace ipc } /** - * Returns a buffer with an IPC preamble for the given \p encoding_a followed by the payload. Depending on encoding, + * Returns a buffer with an IPC preamble for the given \p encoding_a followed by the payload. Depending on encoding, * the buffer may contain a payload length or end sentinel. */ nano::shared_const_buffer prepare_request (nano::ipc::payload_encoding encoding_a, std::string const & payload_a); diff --git a/nano/lib/jsonconfig.cpp b/nano/lib/jsonconfig.cpp index fb5a857d25..74523154c2 100644 --- a/nano/lib/jsonconfig.cpp +++ b/nano/lib/jsonconfig.cpp @@ -21,7 +21,7 @@ nano::jsonconfig::jsonconfig (boost::property_tree::ptree & tree_a, std::shared_ } /** - * Reads a json object from the stream + * Reads a json object from the stream * @return nano::error&, including a descriptive error message if the config file is malformed. */ nano::error & nano::jsonconfig::read (std::filesystem::path const & path_a) diff --git a/nano/lib/locks.hpp b/nano/lib/locks.hpp index cb490e455c..f8447edff4 100644 --- a/nano/lib/locks.hpp +++ b/nano/lib/locks.hpp @@ -179,7 +179,7 @@ class unique_lock final }; /** Assumes std implementations of std::condition_variable never actually call nano::unique_lock::lock/unlock, - but instead use OS intrinsics with the mutex handle directly. Due to this we also do not account for any + but instead use OS intrinsics with the mutex handle directly. Due to this we also do not account for any time the condition variable is blocked on another holder of the mutex. */ class condition_variable final { @@ -283,7 +283,7 @@ class locked owner->mutex.unlock (); } - T * operator-> () + T * operator->() { return &owner->obj; } @@ -301,7 +301,7 @@ class locked locked * owner{ nullptr }; }; - scoped_lock operator-> () + scoped_lock operator->() { return scoped_lock (this); } diff --git a/nano/lib/memory.hpp b/nano/lib/memory.hpp index 6a484540d3..333a5ff980 100644 --- a/nano/lib/memory.hpp +++ b/nano/lib/memory.hpp @@ -16,8 +16,8 @@ bool get_use_memory_pools (); void set_use_memory_pools (bool use_memory_pools); /** This makes some heuristic assumptions about the implementation defined shared_ptr internals. - Should only be used in the memory pool purge functions at exit, which doesn't matter much if - it is incorrect (other than reports from heap memory analysers) */ + Should only be used in the memory pool purge functions at exit, which doesn't matter much if + it is incorrect (other than reports from heap memory analysers) */ template constexpr size_t determine_shared_ptr_pool_size () { diff --git a/nano/lib/optional_ptr.hpp b/nano/lib/optional_ptr.hpp index 56695fc3ed..8c5fdc2fe7 100644 --- a/nano/lib/optional_ptr.hpp +++ b/nano/lib/optional_ptr.hpp @@ -55,14 +55,14 @@ class optional_ptr return *ptr; } - T * const operator-> () + T * const operator->() { - return ptr.operator-> (); + return ptr.operator->(); } - T const * const operator-> () const + T const * const operator->() const { - return ptr.operator-> (); + return ptr.operator->(); } T const * const get () const diff --git a/nano/lib/tomlconfig.cpp b/nano/lib/tomlconfig.cpp index bf1bd13eff..ee8d9e6f28 100644 --- a/nano/lib/tomlconfig.cpp +++ b/nano/lib/tomlconfig.cpp @@ -166,8 +166,8 @@ std::shared_ptr nano::tomlconfig::create_array (std::string cons } /** - * Erase keys whose values are equal to the one in \p defaults - */ + * Erase keys whose values are equal to the one in \p defaults + */ void nano::tomlconfig::erase_default_values (tomlconfig & defaults_a) { std::shared_ptr clone = std::dynamic_pointer_cast (tree->clone ()); diff --git a/nano/slow_test/bootstrap.cpp b/nano/slow_test/bootstrap.cpp index b500e4a009..070da58f5a 100644 --- a/nano/slow_test/bootstrap.cpp +++ b/nano/slow_test/bootstrap.cpp @@ -77,7 +77,7 @@ TEST (bootstrap_ascending, profile) flags_server.disable_ongoing_bootstrap = true; flags_server.disable_ascending_bootstrap = true; auto data_path_server = nano::working_path (network); - //auto data_path_server = ""; + // auto data_path_server = ""; auto server = std::make_shared (system.io_ctx, data_path_server, config_server, system.work, flags_server); system.nodes.push_back (server); server->start (); @@ -93,10 +93,10 @@ TEST (bootstrap_ascending, profile) config_client.ipc_config.transport_tcp.enabled = true; // Disable database integrity safety for higher throughput config_client.lmdb_config.sync = nano::lmdb_config::sync_strategy::nosync_unsafe; - //auto client = system.add_node (config_client, flags_client); + // auto client = system.add_node (config_client, flags_client); // macos 16GB RAM disk: diskutil erasevolume HFS+ "RAMDisk" `hdiutil attach -nomount ram://33554432` - //auto data_path_client = "/Volumes/RAMDisk"; + // auto data_path_client = "/Volumes/RAMDisk"; auto data_path_client = nano::unique_path (); auto client = std::make_shared (system.io_ctx, data_path_client, config_client, system.work, flags_client); system.nodes.push_back (client); @@ -186,7 +186,7 @@ TEST (bootstrap_ascending, profile) rate.observe (*client, nano::stat::type::ledger, nano::stat::detail::gap_previous, nano::stat::dir::in); rate.background_print (3s); - //wait_for_key (); + // wait_for_key (); while (true) { nano::test::establish_tcp (system, *client, server->network.endpoint ()); diff --git a/nano/store/iterator.hpp b/nano/store/iterator.hpp index 00f2ab7f93..aef5cc709f 100644 --- a/nano/store/iterator.hpp +++ b/nano/store/iterator.hpp @@ -45,7 +45,7 @@ class iterator final return *this; } iterator & operator= (iterator const &) = delete; - std::pair * operator-> () + std::pair * operator->() { return ¤t; } diff --git a/nano/store/lmdb/account.hpp b/nano/store/lmdb/account.hpp index 9c3284b482..6faaf3cfe8 100644 --- a/nano/store/lmdb/account.hpp +++ b/nano/store/lmdb/account.hpp @@ -29,27 +29,27 @@ class account : public nano::store::account void for_each_par (std::function, store::iterator)> const & action_a) const override; /** - * Maps account v1 to account information, head, rep, open, balance, timestamp and block count. (Removed) - * nano::account -> nano::block_hash, nano::block_hash, nano::block_hash, nano::amount, uint64_t, uint64_t - */ + * Maps account v1 to account information, head, rep, open, balance, timestamp and block count. (Removed) + * nano::account -> nano::block_hash, nano::block_hash, nano::block_hash, nano::amount, uint64_t, uint64_t + */ MDB_dbi accounts_v0_handle{ 0 }; /** - * Maps account v0 to account information, head, rep, open, balance, timestamp and block count. (Removed) - * nano::account -> nano::block_hash, nano::block_hash, nano::block_hash, nano::amount, uint64_t, uint64_t - */ + * Maps account v0 to account information, head, rep, open, balance, timestamp and block count. (Removed) + * nano::account -> nano::block_hash, nano::block_hash, nano::block_hash, nano::amount, uint64_t, uint64_t + */ MDB_dbi accounts_v1_handle{ 0 }; /** - * Maps account v0 to account information, head, rep, open, balance, timestamp, block count and epoch - * nano::account -> nano::block_hash, nano::block_hash, nano::block_hash, nano::amount, uint64_t, uint64_t, nano::epoch - */ + * Maps account v0 to account information, head, rep, open, balance, timestamp, block count and epoch + * nano::account -> nano::block_hash, nano::block_hash, nano::block_hash, nano::amount, uint64_t, uint64_t, nano::epoch + */ MDB_dbi accounts_handle{ 0 }; /** - * Representative weights. (Removed) - * nano::account -> nano::uint128_t - */ + * Representative weights. (Removed) + * nano::account -> nano::uint128_t + */ MDB_dbi representation_handle{ 0 }; }; } // amespace nano::store::lmdb diff --git a/nano/store/lmdb/block.hpp b/nano/store/lmdb/block.hpp index a16f213859..b9ccc3b475 100644 --- a/nano/store/lmdb/block.hpp +++ b/nano/store/lmdb/block.hpp @@ -37,9 +37,9 @@ class block : public nano::store::block void for_each_par (std::function, store::iterator)> const & action_a) const override; /** - * Contains block_sideband and block for all block types (legacy send/change/open/receive & state blocks) - * nano::block_hash -> nano::block_sideband, nano::block - */ + * Contains block_sideband and block for all block types (legacy send/change/open/receive & state blocks) + * nano::block_hash -> nano::block_sideband, nano::block + */ MDB_dbi blocks_handle{ 0 }; protected: diff --git a/nano/store/lmdb/confirmation_height.hpp b/nano/store/lmdb/confirmation_height.hpp index 738c8482c6..4674f81137 100644 --- a/nano/store/lmdb/confirmation_height.hpp +++ b/nano/store/lmdb/confirmation_height.hpp @@ -29,9 +29,9 @@ class confirmation_height : public nano::store::confirmation_height void for_each_par (std::function, store::iterator)> const & action_a) const override; /* - * Confirmation height of an account, and the hash for the block at that height - * nano::account -> uint64_t, nano::block_hash - */ + * Confirmation height of an account, and the hash for the block at that height + * nano::account -> uint64_t, nano::block_hash + */ MDB_dbi confirmation_height_handle{ 0 }; }; } // namespace nano::store::lmdb diff --git a/nano/store/lmdb/final_vote.hpp b/nano/store/lmdb/final_vote.hpp index b7c06c62fd..92fc5253fd 100644 --- a/nano/store/lmdb/final_vote.hpp +++ b/nano/store/lmdb/final_vote.hpp @@ -29,9 +29,9 @@ class final_vote : public nano::store::final_vote void for_each_par (std::function, store::iterator)> const & action_a) const override; /** - * Maps root to block hash for generated final votes. - * nano::qualified_root -> nano::block_hash - */ + * Maps root to block hash for generated final votes. + * nano::qualified_root -> nano::block_hash + */ MDB_dbi final_votes_handle{ 0 }; }; } // namespace nano::store::lmdb diff --git a/nano/store/lmdb/frontier.hpp b/nano/store/lmdb/frontier.hpp index 6bf71068bf..95205d4cd0 100644 --- a/nano/store/lmdb/frontier.hpp +++ b/nano/store/lmdb/frontier.hpp @@ -26,9 +26,9 @@ class frontier : public nano::store::frontier void for_each_par (std::function, store::iterator)> const & action_a) const override; /** - * Maps head block to owning account - * nano::block_hash -> nano::account - */ + * Maps head block to owning account + * nano::block_hash -> nano::account + */ MDB_dbi frontiers_handle{ 0 }; }; } // namespace nano::store::lmdb diff --git a/nano/store/lmdb/iterator.hpp b/nano/store/lmdb/iterator.hpp index e8230fd73f..ff7cb0977c 100644 --- a/nano/store/lmdb/iterator.hpp +++ b/nano/store/lmdb/iterator.hpp @@ -95,7 +95,7 @@ class iterator : public iterator_impl return *this; } - std::pair, store::db_val> * operator-> () + std::pair, store::db_val> * operator->() { return ¤t; } @@ -213,9 +213,9 @@ class merge_iterator : public iterator_impl return *this; } - std::pair, store::db_val> * operator-> () + std::pair, store::db_val> * operator->() { - return least_iterator ().operator-> (); + return least_iterator ().operator->(); } bool operator== (merge_iterator const & other) const diff --git a/nano/store/lmdb/online_weight.hpp b/nano/store/lmdb/online_weight.hpp index df70dfb9d0..0567c63d9b 100644 --- a/nano/store/lmdb/online_weight.hpp +++ b/nano/store/lmdb/online_weight.hpp @@ -22,9 +22,9 @@ class online_weight : public nano::store::online_weight void clear (store::write_transaction const & transaction_a) override; /** - * Samples of online vote weight - * uint64_t -> nano::amount - */ + * Samples of online vote weight + * uint64_t -> nano::amount + */ MDB_dbi online_weight_handle{ 0 }; }; } // namespace nano::store::lmdb diff --git a/nano/store/lmdb/peer.hpp b/nano/store/lmdb/peer.hpp index 7519908eee..13ae1b59f3 100644 --- a/nano/store/lmdb/peer.hpp +++ b/nano/store/lmdb/peer.hpp @@ -22,9 +22,9 @@ class peer : public nano::store::peer store::iterator end () const override; /* - * Endpoints for peers - * nano::endpoint_key -> no_value - */ + * Endpoints for peers + * nano::endpoint_key -> no_value + */ MDB_dbi peers_handle{ 0 }; }; } // namespace nano::store::lmdb diff --git a/nano/store/lmdb/pending.hpp b/nano/store/lmdb/pending.hpp index 7b39a9132c..1c110fa186 100644 --- a/nano/store/lmdb/pending.hpp +++ b/nano/store/lmdb/pending.hpp @@ -28,21 +28,21 @@ class pending : public nano::store::pending void for_each_par (std::function, store::iterator)> const & action_a) const override; /** - * Maps min_version 0 (destination account, pending block) to (source account, amount). (Removed) - * nano::account, nano::block_hash -> nano::account, nano::amount - */ + * Maps min_version 0 (destination account, pending block) to (source account, amount). (Removed) + * nano::account, nano::block_hash -> nano::account, nano::amount + */ MDB_dbi pending_v0_handle{ 0 }; /** - * Maps min_version 1 (destination account, pending block) to (source account, amount). (Removed) - * nano::account, nano::block_hash -> nano::account, nano::amount - */ + * Maps min_version 1 (destination account, pending block) to (source account, amount). (Removed) + * nano::account, nano::block_hash -> nano::account, nano::amount + */ MDB_dbi pending_v1_handle{ 0 }; /** - * Maps (destination account, pending block) to (source account, amount, version). (Removed) - * nano::account, nano::block_hash -> nano::account, nano::amount, nano::epoch - */ + * Maps (destination account, pending block) to (source account, amount, version). (Removed) + * nano::account, nano::block_hash -> nano::account, nano::amount, nano::epoch + */ MDB_dbi pending_handle{ 0 }; }; } // namespace nano::store::lmdb diff --git a/nano/store/lmdb/pruned.hpp b/nano/store/lmdb/pruned.hpp index d0c3c5d075..0aa2d7fc20 100644 --- a/nano/store/lmdb/pruned.hpp +++ b/nano/store/lmdb/pruned.hpp @@ -25,9 +25,9 @@ class pruned : public nano::store::pruned void for_each_par (std::function, store::iterator)> const & action_a) const override; /** - * Pruned blocks hashes - * nano::block_hash -> none - */ + * Pruned blocks hashes + * nano::block_hash -> none + */ MDB_dbi pruned_handle{ 0 }; }; } // namespace nano::store::lmdb diff --git a/nano/store/lmdb/version.hpp b/nano/store/lmdb/version.hpp index fa9cb04298..7ec10b8183 100644 --- a/nano/store/lmdb/version.hpp +++ b/nano/store/lmdb/version.hpp @@ -17,9 +17,9 @@ class version : public nano::store::version int get (store::transaction const & transaction_a) const override; /** - * Meta information about block store, such as versions. - * nano::uint256_union (arbitrary key) -> blob - */ + * Meta information about block store, such as versions. + * nano::uint256_union (arbitrary key) -> blob + */ MDB_dbi meta_handle{ 0 }; }; } // namespace nano::store::lmdb diff --git a/nano/store/rocksdb/iterator.hpp b/nano/store/rocksdb/iterator.hpp index 0351367828..ec4865e526 100644 --- a/nano/store/rocksdb/iterator.hpp +++ b/nano/store/rocksdb/iterator.hpp @@ -129,7 +129,7 @@ class iterator : public iterator_impl return *this; } - std::pair * operator-> () + std::pair * operator->() { return ¤t; }