Skip to content

Commit

Permalink
clang-tidy
Browse files Browse the repository at this point in the history
Signed-off-by: iceseer <[email protected]>
  • Loading branch information
iceseer committed Dec 13, 2024
1 parent e535e58 commit 9123f53
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
3 changes: 2 additions & 1 deletion core/parachain/approval/knowledge.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "common/visitor.hpp"
#include "consensus/timeline/types.hpp"
#include "outcome/outcome.hpp"
#include "parachain/approval/approval.hpp"
#include "parachain/approval/state.hpp"
#include "parachain/types.hpp"

Expand Down Expand Up @@ -86,7 +87,7 @@ namespace kagome::parachain::approval {

// Generate the knowledge keys for querying if an approval is known by peer.
static std::pair<MessageSubject, MessageKind> generate_approval_key(
const approval::IndirectSignedApprovalVoteV2 &approval) {
const IndirectSignedApprovalVoteV2 &approval) {
return {
std::make_tuple(approval.payload.payload.block_hash,
approval.payload.payload.candidate_indices,
Expand Down
3 changes: 2 additions & 1 deletion core/scale/encoder/concepts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@

#pragma once

#include <cstdint>
#include <type_traits>

namespace kagome::scale {
template <typename F>
concept Invocable = std::is_invocable_v<F, const uint8_t *const, size_t>;
concept Invocable = std::is_invocable_v<F, const uint8_t *const, std::size_t>;

template <typename T>
concept IsEnum = std::is_enum_v<std::decay_t<T>>;
Expand Down
13 changes: 8 additions & 5 deletions core/scale/encoder/primitives.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <any>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <optional>
#include <scale/outcome/outcome_throw.hpp>
Expand All @@ -19,6 +20,7 @@
#include <type_traits>
#include <vector>
#include "crypto/ecdsa_types.hpp"
#include "primitives/math.hpp"
#include "scale/encoder/concepts.hpp"
#include "utils/struct_to_tuple.hpp"

Expand Down Expand Up @@ -52,6 +54,7 @@ namespace kagome::scale {
const std::array<T, size> &c);

template <typename T, size_t N>
// NOLINTNEXTLINE(cppcoreguidelines-avoid-c-arrays)
constexpr void encode(const Invocable auto &func, const T (&c)[N]);

template <typename K, typename V>
Expand Down Expand Up @@ -134,6 +137,7 @@ namespace kagome::scale {
kagome::scale::encode(func, args...);
}

// NOLINTBEGIN(cppcoreguidelines-pro-bounds-pointer-arithmetic)
template <typename... Args>
outcome::result<std::vector<uint8_t>> encode(const Args &...args) {
std::vector<uint8_t> res;
Expand Down Expand Up @@ -185,6 +189,7 @@ namespace kagome::scale {
}
return counter;
}
// NOLINTEND(cppcoreguidelines-pro-bounds-pointer-arithmetic)

constexpr void putByte(const Invocable auto &func,
const uint8_t *const val,
Expand All @@ -206,6 +211,7 @@ namespace kagome::scale {
}

template <typename T, size_t N>
// NOLINTNEXTLINE(cppcoreguidelines-avoid-c-arrays)
constexpr void encode(const Invocable auto &func, const T (&c)[N]) {
using E = std::decay_t<T>;
if constexpr (std::is_integral_v<E> && sizeof(E) == 1u) {
Expand Down Expand Up @@ -472,15 +478,12 @@ namespace kagome::scale {

void encode(const Invocable auto &func, const crypto::EcdsaSignature &data) {
kagome::scale::encode(
func,
static_cast<const crypto::EcdsaSignature::Base &>(data));
func, static_cast<const crypto::EcdsaSignature::Base &>(data));
}

void encode(const Invocable auto &func, const crypto::EcdsaPublicKey &data) {
kagome::scale::encode(
func,
static_cast<
const crypto::EcdsaPublicKey::Base &>(data));
func, static_cast<const crypto::EcdsaPublicKey::Base &>(data));
}

} // namespace kagome::scale
Expand Down
3 changes: 2 additions & 1 deletion core/scale/kagome_scale.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,8 @@ namespace kagome::scale {
}

constexpr void encode(const Invocable auto &func, const network::Roles &c) {
kagome::scale::encode(func, c.value);
kagome::scale::encode(
func, c.value); // NOLINT(cppcoreguidelines-pro-type-union-access)
}

constexpr void encode(const Invocable auto &func,
Expand Down

0 comments on commit 9123f53

Please sign in to comment.