chore: Enable most cppcoreguidelines checks (#7660)

This commit is contained in:
Ayaz Salikhov
2026-07-07 14:12:52 +01:00
committed by GitHub
parent f5e63f8a91
commit c5a6de6ef7
29 changed files with 86 additions and 74 deletions

View File

@@ -138,11 +138,8 @@ public:
{
}
ConstIterator(Iterator const& orig)
ConstIterator(Iterator const& orig) : map(orig.map), ait(orig.ait), mit(orig.mit)
{
map = orig.map;
ait = orig.ait;
mit = orig.mit;
}
const_reference
@@ -231,11 +228,11 @@ private:
public:
PartitionedUnorderedMap(std::optional<std::size_t> partitions = std::nullopt)
{
// Set partitions to the number of hardware threads if the parameter
// is either empty or set to 0.
partitions_ =
partitions && (*partitions != 0u) ? *partitions : std::thread::hardware_concurrency();
: partitions_(
partitions && (*partitions != 0u) ? *partitions : std::thread::hardware_concurrency())
{
map_.resize(partitions_);
XRPL_ASSERT(
partitions_,

View File

@@ -359,6 +359,7 @@ private:
deleteElement(Element const* p)
{
ElementAllocatorTraits::destroy(config_.alloc(), p);
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast)
ElementAllocatorTraits::deallocate(config_.alloc(), const_cast<Element*>(p), 1);
}

View File

@@ -528,6 +528,7 @@ private:
deleteElement(Element const* p)
{
ElementAllocatorTraits::destroy(config_.alloc(), p);
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast)
ElementAllocatorTraits::deallocate(config_.alloc(), const_cast<Element*>(p), 1);
}

View File

@@ -23,6 +23,7 @@ typeName()
if (auto s = abi::__cxa_demangle(name.c_str(), nullptr, nullptr, nullptr))
{
name = s;
// NOLINTNEXTLINE(cppcoreguidelines-no-malloc)
std::free(s);
}
#endif

View File

@@ -34,11 +34,11 @@ public:
createObject();
private:
bool success_;
bool success_{false};
void const* key_;
NodeObjectType objectType_;
unsigned char const* objectData_;
NodeObjectType objectType_{NodeObjectType::Unknown};
unsigned char const* objectData_{nullptr};
int dataBytes_;
};

View File

@@ -240,6 +240,9 @@ private:
inline STPathElement::STPathElement() : type_(TypeNone), isOffer_(true)
{
// hashValue_ is derived from the whole object, so it is computed in the body
// once every other member is initialized (as in the other constructors).
// NOLINTNEXTLINE(cppcoreguidelines-prefer-member-initializer)
hashValue_ = getHash(*this);
}
@@ -315,6 +318,9 @@ inline STPathElement::STPathElement(
assetID_.visit(
[&](Currency const&) { type_ = type_ & (~Type::TypeMpt); },
[&](MPTID const&) { type_ = type_ & (~Type::TypeCurrency); });
// hashValue_ must be computed after type_ is adjusted above, so this cannot
// be a member initializer.
// NOLINTNEXTLINE(cppcoreguidelines-prefer-member-initializer)
hashValue_ = getHash(*this);
}

View File

@@ -50,14 +50,13 @@ public:
STVar&
operator=(STVar&& rhs);
STVar(STBase&& t) // NOLINT(cppcoreguidelines-rvalue-reference-param-not-moved)
// NOLINTNEXTLINE(cppcoreguidelines-rvalue-reference-param-not-moved)
STVar(STBase&& t) : p_(t.move(kMaxSize, &d_))
{
p_ = t.move(kMaxSize, &d_);
}
STVar(STBase const& t)
STVar(STBase const& t) : p_(t.copy(kMaxSize, &d_))
{
p_ = t.copy(kMaxSize, &d_);
}
STVar(DefaultObjectT, SField const& name);

View File

@@ -138,6 +138,7 @@ intrusive_ptr_release(SHAMapItem const* x)
// If the slabber doesn't claim this pointer, it was allocated
// manually, so we free it manually.
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast)
if (!detail::gSlabber.deallocate(const_cast<std::uint8_t*>(p)))
delete[] p;
}

View File

@@ -92,6 +92,7 @@ public:
[[nodiscard]] TOffer<TIn, TOut>&
tip() const
{
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast)
return const_cast<TOfferStreamBase*>(this)->offer_;
}