Skip to content
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
  •  
  •  
  •  
10 changes: 5 additions & 5 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,19 @@ Checks: "-*,
# cppcoreguidelines-use-default-member-init, # has issues
# cppcoreguidelines-virtual-class-destructor, # has issues
hicpp-ignored-remove-result,
# misc-definitions-in-headers, # has issues
misc-const-correctness,
misc-definitions-in-headers,
misc-header-include-cycle,
misc-misplaced-const,
misc-redundant-expression,
misc-static-assert,
# misc-throw-by-value-catch-by-reference, # has issues
misc-throw-by-value-catch-by-reference,
misc-unused-alias-decls,
misc-unused-using-decls,
modernize-deprecated-headers,
modernize-make-shared,
modernize-make-unique,
llvm-namespace-comment,
performance-faster-string-find,
performance-for-range-copy,
performance-implicit-conversion-in-loop,
Expand Down Expand Up @@ -134,10 +137,7 @@ Checks: "-*,
# ---
# other checks that have issues that need to be resolved:
#
# llvm-namespace-comment,
# misc-const-correctness,
# misc-include-cleaner,
# misc-redundant-expression,
#
# readability-inconsistent-declaration-parameter-name, # in this codebase this check will break a lot of arg names
# readability-static-accessed-through-instance, # this check is probably unnecessary. it makes the code less readable
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reusable-clang-tidy-files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ jobs:
env:
TARGETS: ${{ inputs.files != '' && inputs.files || 'src tests' }}
run: |
run-clang-tidy -j ${{ steps.nproc.outputs.nproc }} -p "${BUILD_DIR}" ${TARGETS} 2>&1 | tee clang-tidy-output.txt
run-clang-tidy -j ${{ steps.nproc.outputs.nproc }} -p "${BUILD_DIR}" -quiet -allow-no-checks ${TARGETS} 2>&1 | tee clang-tidy-output.txt

- name: Upload clang-tidy output
if: ${{ github.event.repository.visibility == 'public' && steps.run_clang_tidy.outcome != 'success' }}
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -270,14 +270,14 @@ Before running clang-tidy, you must build the project to generate required files
Then run clang-tidy on your local changes:

```
run-clang-tidy -p build src include tests
run-clang-tidy -p build -allow-no-checks src tests
```

This will check all source files in the `src`, `include` and `tests` directories using the compile commands from your `build` directory.
If you wish to automatically fix whatever clang-tidy finds _and_ is capable of fixing, add `-fix` to the above command:

```
run-clang-tidy -p build -fix src include tests
run-clang-tidy -p build -quiet -fix -allow-no-checks src tests
```

## Contracts and instrumentation
Expand Down
2 changes: 1 addition & 1 deletion include/xrpl/basics/BasicConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ template <class T>
bool
set(T& target, T const& defaultValue, std::string const& name, Section const& section)
{
bool found_and_valid = set<T>(target, name, section);
bool const found_and_valid = set<T>(target, name, section);
if (!found_and_valid)
target = defaultValue;
return found_and_valid;
Expand Down
2 changes: 1 addition & 1 deletion include/xrpl/basics/IntrusiveRefCounts.h
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ inline void
partialDestructorFinished(T** o)
{
T& self = **o;
IntrusiveRefCounts::RefCountPair p =
IntrusiveRefCounts::RefCountPair const p =
self.refCounts.fetch_or(IntrusiveRefCounts::partialDestroyFinishedMask);
XRPL_ASSERT(
(!p.partialDestroyFinishedBit && p.partialDestroyStartedBit && !p.strong),
Expand Down
6 changes: 3 additions & 3 deletions include/xrpl/basics/SlabAllocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class SlabAllocator
std::uint8_t* ret;

{
std::lock_guard l(m_);
std::lock_guard const l(m_);

ret = l_;

Expand Down Expand Up @@ -123,7 +123,7 @@ class SlabAllocator
{
XRPL_ASSERT(own(ptr), "xrpl::SlabAllocator::SlabBlock::deallocate : own input");

std::lock_guard l(m_);
std::lock_guard const l(m_);

// Use memcpy to avoid unaligned UB
// (will optimize to equivalent code)
Expand Down Expand Up @@ -210,7 +210,7 @@ class SlabAllocator

// No slab can satisfy our request, so we attempt to allocate a new
// one here:
std::size_t size = slabSize_;
std::size_t const size = slabSize_;

// We want to allocate the memory at a 2 MiB boundary, to make it
// possible to use hugepage mappings on Linux:
Expand Down
4 changes: 2 additions & 2 deletions include/xrpl/basics/StringUtilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ strUnHex(std::size_t strSize, Iterator begin, Iterator end)

while (iter != end)
{
int cHigh = digitLookupTable[*iter++];
int const cHigh = digitLookupTable[*iter++];

if (cHigh < 0)
return {};

int cLow = digitLookupTable[*iter++];
int const cLow = digitLookupTable[*iter++];

if (cLow < 0)
return {};
Expand Down
4 changes: 2 additions & 2 deletions include/xrpl/basics/base_uint.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ class base_uint
while (in != sv.end())
{
std::uint32_t accum = {};
for (std::uint32_t shift : {4u, 0u, 12u, 8u, 20u, 16u, 28u, 24u})
for (std::uint32_t const shift : {4u, 0u, 12u, 8u, 20u, 16u, 28u, 24u})
{
if (auto const result = hexCharToUInt(*in++, shift, accum);
result != ParseResult::okay)
Expand Down Expand Up @@ -444,7 +444,7 @@ class base_uint

for (int i = WIDTH; i--;)
{
std::uint64_t n = carry + boost::endian::big_to_native(data_[i]) +
std::uint64_t const n = carry + boost::endian::big_to_native(data_[i]) +
boost::endian::big_to_native(b.data_[i]);

data_[i] = boost::endian::native_to_big(static_cast<std::uint32_t>(n));
Expand Down
2 changes: 1 addition & 1 deletion include/xrpl/basics/contract.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Throw(Args&&... args)

E e(std::forward<Args>(args)...);
LogThrow(std::string("Throwing exception of type " + beast::type_name<E>() + ": ") + e.what());
throw e;
throw std::move(e);
}

/** Called when faulty logic causes a broken invariant. */
Expand Down
2 changes: 1 addition & 1 deletion include/xrpl/basics/hardened_hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ make_seed_pair() noexcept
// state_t& operator=(state_t const&) = delete;
};
static state_t state;
std::lock_guard lock(state.mutex);
std::lock_guard const lock(state.mutex);
return {state.dist(state.gen), state.dist(state.gen)};
}

Expand Down
4 changes: 3 additions & 1 deletion include/xrpl/basics/random.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ namespace xrpl {

#ifndef __INTELLISENSE__
static_assert(
// NOLINTNEXTLINE(misc-redundant-expression)
std::is_integral<beast::xor_shift_engine::result_type>::value &&
std::is_unsigned<beast::xor_shift_engine::result_type>::value,
"The Ripple default PRNG engine must return an unsigned integral type.");

static_assert(
// NOLINTNEXTLINE(misc-redundant-expression)
std::numeric_limits<beast::xor_shift_engine::result_type>::max() >=
std::numeric_limits<std::uint64_t>::max(),
"The Ripple default PRNG engine return must be at least 64 bits wide.");
Expand Down Expand Up @@ -58,7 +60,7 @@ default_prng()
thread_local beast::xor_shift_engine engine = [] {
std::uint64_t seed;
{
std::lock_guard lk(m);
std::lock_guard const lk(m);
std::uniform_int_distribution<std::uint64_t> distribution{1};
seed = distribution(seeder);
}
Expand Down
10 changes: 5 additions & 5 deletions include/xrpl/beast/asio/io_latency_probe.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class io_latency_probe
void
sample_one(Handler&& handler)
{
std::lock_guard lock(m_mutex);
std::lock_guard const lock(m_mutex);
if (m_cancel)
throw std::logic_error("io_latency_probe is canceled");
boost::asio::post(
Expand All @@ -98,7 +98,7 @@ class io_latency_probe
void
sample(Handler&& handler)
{
std::lock_guard lock(m_mutex);
std::lock_guard const lock(m_mutex);
if (m_cancel)
throw std::logic_error("io_latency_probe is canceled");
boost::asio::post(
Expand All @@ -122,14 +122,14 @@ class io_latency_probe
void
addref()
{
std::lock_guard lock(m_mutex);
std::lock_guard const lock(m_mutex);
++m_count;
}

void
release()
{
std::lock_guard lock(m_mutex);
std::lock_guard const lock(m_mutex);
if (--m_count == 0)
m_cond.notify_all();
}
Expand Down Expand Up @@ -192,7 +192,7 @@ class io_latency_probe
m_handler(elapsed);

{
std::lock_guard lock(m_probe->m_mutex);
std::lock_guard const lock(m_probe->m_mutex);
if (m_probe->m_cancel)
return;
}
Expand Down
2 changes: 1 addition & 1 deletion include/xrpl/beast/container/aged_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ template <
class Allocator = std::allocator<std::pair<Key const, T>>>
using aged_map = detail::aged_ordered_container<false, true, Key, T, Clock, Compare, Allocator>;

}
} // namespace beast
2 changes: 1 addition & 1 deletion include/xrpl/beast/container/aged_multimap.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ template <
class Allocator = std::allocator<std::pair<Key const, T>>>
using aged_multimap = detail::aged_ordered_container<true, true, Key, T, Clock, Compare, Allocator>;

}
} // namespace beast
2 changes: 1 addition & 1 deletion include/xrpl/beast/container/aged_multiset.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ template <
class Allocator = std::allocator<Key>>
using aged_multiset =
detail::aged_ordered_container<true, false, Key, void, Clock, Compare, Allocator>;
}
} // namespace beast
2 changes: 1 addition & 1 deletion include/xrpl/beast/container/aged_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ template <
class Allocator = std::allocator<Key>>
using aged_set = detail::aged_ordered_container<false, false, Key, void, Clock, Compare, Allocator>;

}
} // namespace beast
2 changes: 1 addition & 1 deletion include/xrpl/beast/container/aged_unordered_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ template <
class Allocator = std::allocator<std::pair<Key const, T>>>
using aged_unordered_map =
detail::aged_unordered_container<false, true, Key, T, Clock, Hash, KeyEqual, Allocator>;
}
} // namespace beast
2 changes: 1 addition & 1 deletion include/xrpl/beast/container/aged_unordered_multimap.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ template <
class Allocator = std::allocator<std::pair<Key const, T>>>
using aged_unordered_multimap =
detail::aged_unordered_container<true, true, Key, T, Clock, Hash, KeyEqual, Allocator>;
}
} // namespace beast
2 changes: 1 addition & 1 deletion include/xrpl/beast/container/aged_unordered_multiset.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ template <
using aged_unordered_multiset =
detail::aged_unordered_container<true, false, Key, void, Clock, Hash, KeyEqual, Allocator>;

}
} // namespace beast
2 changes: 1 addition & 1 deletion include/xrpl/beast/container/aged_unordered_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ template <
class Allocator = std::allocator<Key>>
using aged_unordered_set =
detail::aged_unordered_container<false, false, Key, void, Clock, Hash, KeyEqual, Allocator>;
}
} // namespace beast
2 changes: 1 addition & 1 deletion include/xrpl/beast/core/List.h
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ class List
iterator
erase(iterator pos) noexcept
{
Node* node = &*pos;
Node const* node = &*pos;
++pos;
node->m_next->m_prev = node->m_prev;
node->m_prev->m_next = node->m_next;
Expand Down
2 changes: 1 addition & 1 deletion include/xrpl/beast/test/yield_to.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ enable_yield_to::spawn(F0&& f, FN&&... fn)
boost::context::fixedsize_stack(2 * 1024 * 1024),
[&](yield_context yield) {
f(yield);
std::lock_guard lock{m_};
std::lock_guard const lock{m_};
if (--running_ == 0)
cv_.notify_all();
},
Expand Down
8 changes: 4 additions & 4 deletions include/xrpl/beast/unit_test/runner.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ template <class>
void
runner::testcase(std::string const& name)
{
std::lock_guard lock(mutex_);
std::lock_guard const lock(mutex_);
// Name may not be empty
BOOST_ASSERT(default_ || !name.empty());
// Forgot to call pass or fail
Expand All @@ -244,7 +244,7 @@ template <class>
void
runner::pass()
{
std::lock_guard lock(mutex_);
std::lock_guard const lock(mutex_);
if (default_)
testcase("");
on_pass();
Expand All @@ -255,7 +255,7 @@ template <class>
void
runner::fail(std::string const& reason)
{
std::lock_guard lock(mutex_);
std::lock_guard const lock(mutex_);
if (default_)
testcase("");
on_fail(reason);
Expand All @@ -267,7 +267,7 @@ template <class>
void
runner::log(std::string const& s)
{
std::lock_guard lock(mutex_);
std::lock_guard const lock(mutex_);
if (default_)
testcase("");
on_log(s);
Expand Down
2 changes: 1 addition & 1 deletion include/xrpl/beast/unit_test/suite.h
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ class suite
static suite**
p_this_suite()
{
static suite* pts = nullptr;
static suite* pts = nullptr; // NOLINT(misc-const-correctness)
return &pts;
}

Expand Down
2 changes: 1 addition & 1 deletion include/xrpl/beast/utility/Zero.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct Zero

namespace {
static constexpr Zero zero{};
}
} // namespace

/** Default implementation of signum calls the method on the class. */
template <typename T>
Expand Down
6 changes: 3 additions & 3 deletions include/xrpl/core/ClosureCounter.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class ClosureCounter
// a lock. This removes a small timing window that occurs if the
// waiting thread is handling a spurious wakeup when closureCount_
// drops to zero.
std::lock_guard lock{mutex_};
std::lock_guard const lock{mutex_};

// Update closureCount_. Notify if stopping and closureCount_ == 0.
if ((--closureCount_ == 0) && waitForClosures_)
Expand Down Expand Up @@ -168,7 +168,7 @@ class ClosureCounter
{
std::optional<Substitute<Closure>> ret;

std::lock_guard lock{mutex_};
std::lock_guard const lock{mutex_};
if (!waitForClosures_)
ret.emplace(*this, std::forward<Closure>(closure));

Expand All @@ -191,7 +191,7 @@ class ClosureCounter
bool
joined() const
{
std::lock_guard lock{mutex_};
std::lock_guard const lock{mutex_};
return waitForClosures_;
}
};
Expand Down
2 changes: 1 addition & 1 deletion include/xrpl/core/JobQueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace xrpl {

namespace perf {
class PerfLog;
}
} // namespace perf

class Logs;
struct Coro_create_t
Expand Down
2 changes: 1 addition & 1 deletion include/xrpl/core/JobTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class JobTypes
std::chrono::milliseconds{0})
{
using namespace std::chrono_literals;
int maxLimit = std::numeric_limits<int>::max();
int const maxLimit = std::numeric_limits<int>::max();

auto add = [this](
JobType jt,
Expand Down
2 changes: 1 addition & 1 deletion include/xrpl/core/PeerReservationTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class PeerReservationTable final
bool
contains(PublicKey const& nodeId)
{
std::lock_guard lock(this->mutex_);
std::lock_guard const lock(this->mutex_);
return table_.find({nodeId}) != table_.end();
}

Expand Down
Loading
Loading