chore: Update tidy with new v22 checks (#3119)

This commit is contained in:
Ayaz Salikhov
2026-06-29 11:57:24 +01:00
committed by GitHub
parent 9da5f7a995
commit 36ec74415a
16 changed files with 193 additions and 196 deletions

View File

@@ -1,159 +1,161 @@
---
Checks: "-*,
bugprone-argument-comment,
bugprone-assert-side-effect,
bugprone-bad-signal-to-kill-thread,
bugprone-bool-pointer-implicit-conversion,
bugprone-capturing-this-in-member-variable,
bugprone-casting-through-void,
bugprone-chained-comparison,
bugprone-compare-pointer-to-member-virtual-function,
bugprone-copy-constructor-init,
bugprone-crtp-constructor-accessibility,
bugprone-dangling-handle,
bugprone-dynamic-static-initializers,
bugprone-empty-catch,
bugprone-fold-init-type,
bugprone-forward-declaration-namespace,
bugprone-inaccurate-erase,
bugprone-inc-dec-in-conditions,
bugprone-incorrect-enable-if,
bugprone-incorrect-roundings,
bugprone-infinite-loop,
bugprone-integer-division,
bugprone-lambda-function-name,
bugprone-macro-parentheses,
bugprone-macro-repeated-side-effects,
bugprone-misleading-setter-of-reference,
bugprone-misplaced-operator-in-strlen-in-alloc,
bugprone-misplaced-pointer-arithmetic-in-alloc,
bugprone-misplaced-widening-cast,
bugprone-move-forwarding-reference,
bugprone-multi-level-implicit-pointer-conversion,
bugprone-multiple-new-in-one-expression,
bugprone-multiple-statement-macro,
bugprone-no-escape,
bugprone-non-zero-enum-to-bool-conversion,
bugprone-optional-value-conversion,
bugprone-parent-virtual-call,
bugprone-pointer-arithmetic-on-polymorphic-object,
bugprone-posix-return,
bugprone-redundant-branch-condition,
bugprone-reserved-identifier,
bugprone-return-const-ref-from-parameter,
bugprone-shared-ptr-array-mismatch,
bugprone-signal-handler,
bugprone-signed-char-misuse,
bugprone-sizeof-container,
bugprone-sizeof-expression,
bugprone-spuriously-wake-up-functions,
bugprone-standalone-empty,
bugprone-string-constructor,
bugprone-string-integer-assignment,
bugprone-string-literal-with-embedded-nul,
bugprone-stringview-nullptr,
bugprone-suspicious-enum-usage,
bugprone-suspicious-include,
bugprone-suspicious-memory-comparison,
bugprone-suspicious-memset-usage,
bugprone-suspicious-missing-comma,
bugprone-suspicious-realloc-usage,
bugprone-suspicious-semicolon,
bugprone-suspicious-string-compare,
bugprone-suspicious-stringview-data-usage,
bugprone-swapped-arguments,
bugprone-switch-missing-default-case,
bugprone-terminating-continue,
bugprone-throw-keyword-missing,
bugprone-too-small-loop-variable,
bugprone-unchecked-optional-access,
bugprone-undefined-memory-manipulation,
bugprone-undelegated-constructor,
bugprone-unhandled-exception-at-new,
bugprone-unhandled-self-assignment,
bugprone-unique-ptr-array-mismatch,
bugprone-unsafe-functions,
bugprone-unused-local-non-trivial-variable,
bugprone-unused-raii,
bugprone-unused-return-value,
bugprone-use-after-move,
bugprone-virtual-near-miss,
cppcoreguidelines-init-variables,
cppcoreguidelines-misleading-capture-default-by-value,
cppcoreguidelines-no-suspend-with-lock,
cppcoreguidelines-pro-type-member-init,
cppcoreguidelines-pro-type-static-cast-downcast,
cppcoreguidelines-rvalue-reference-param-not-moved,
cppcoreguidelines-use-default-member-init,
cppcoreguidelines-use-enum-class,
cppcoreguidelines-virtual-class-destructor,
hicpp-ignored-remove-result,
bugprone-*,
-bugprone-assignment-in-if-condition,
-bugprone-bitwise-pointer-cast,
-bugprone-branch-clone,
-bugprone-command-processor,
-bugprone-copy-constructor-mutates-argument,
-bugprone-default-operator-new-on-overaligned-type,
-bugprone-easily-swappable-parameters,
-bugprone-exception-copy-constructor-throws,
-bugprone-exception-escape,
-bugprone-float-loop-counter,
-bugprone-forwarding-reference-overload,
-bugprone-implicit-widening-of-multiplication-result,
-bugprone-incorrect-enable-shared-from-this,
-bugprone-narrowing-conversions,
-bugprone-nondeterministic-pointer-iteration-order,
-bugprone-not-null-terminated-result,
-bugprone-random-generator-seed,
-bugprone-raw-memory-call-on-non-trivial-type,
-bugprone-std-namespace-modification,
-bugprone-tagged-union-member-count,
-bugprone-throwing-static-initialization,
-bugprone-unchecked-string-to-number-conversion,
-bugprone-unintended-char-ostream-output,
cppcoreguidelines-*,
-cppcoreguidelines-avoid-c-arrays,
-cppcoreguidelines-avoid-capturing-lambda-coroutines,
-cppcoreguidelines-avoid-const-or-ref-data-members,
-cppcoreguidelines-avoid-do-while,
-cppcoreguidelines-avoid-goto,
-cppcoreguidelines-avoid-magic-numbers,
-cppcoreguidelines-avoid-non-const-global-variables,
-cppcoreguidelines-avoid-reference-coroutine-parameters,
-cppcoreguidelines-c-copy-assignment-signature,
-cppcoreguidelines-explicit-virtual-functions,
-cppcoreguidelines-interfaces-global-init,
-cppcoreguidelines-macro-to-enum,
-cppcoreguidelines-macro-usage,
-cppcoreguidelines-missing-std-forward,
-cppcoreguidelines-narrowing-conversions,
-cppcoreguidelines-no-malloc,
-cppcoreguidelines-noexcept-destructor,
-cppcoreguidelines-noexcept-move-operations,
-cppcoreguidelines-noexcept-swap,
-cppcoreguidelines-non-private-member-variables-in-classes,
-cppcoreguidelines-owning-memory,
-cppcoreguidelines-prefer-member-initializer,
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
-cppcoreguidelines-pro-bounds-avoid-unchecked-container-access,
-cppcoreguidelines-pro-bounds-constant-array-index,
-cppcoreguidelines-pro-bounds-pointer-arithmetic,
-cppcoreguidelines-pro-type-const-cast,
-cppcoreguidelines-pro-type-cstyle-cast,
-cppcoreguidelines-pro-type-reinterpret-cast,
-cppcoreguidelines-pro-type-union-access,
-cppcoreguidelines-pro-type-vararg,
-cppcoreguidelines-slicing,
-cppcoreguidelines-special-member-functions,
llvm-namespace-comment,
misc-const-correctness,
misc-definitions-in-headers,
misc-header-include-cycle,
misc-include-cleaner,
misc-misplaced-const,
misc-redundant-expression,
misc-static-assert,
misc-throw-by-value-catch-by-reference,
misc-unused-alias-decls,
misc-unused-using-decls,
modernize-concat-nested-namespaces,
modernize-deprecated-headers,
modernize-make-shared,
modernize-make-unique,
modernize-pass-by-value,
modernize-type-traits,
modernize-use-designated-initializers,
modernize-use-emplace,
modernize-use-equals-default,
modernize-use-equals-delete,
modernize-use-nodiscard,
modernize-use-override,
modernize-use-ranges,
modernize-use-scoped-lock,
modernize-use-starts-ends-with,
modernize-use-std-numbers,
modernize-use-using,
performance-faster-string-find,
performance-for-range-copy,
performance-implicit-conversion-in-loop,
performance-inefficient-vector-operation,
performance-move-const-arg,
performance-move-constructor-init,
performance-no-automatic-move,
performance-trivially-destructible,
readability-ambiguous-smartptr-reset-call,
readability-avoid-nested-conditional-operator,
readability-avoid-return-with-void-value,
readability-braces-around-statements,
readability-const-return-type,
readability-container-contains,
readability-container-size-empty,
readability-convert-member-functions-to-static,
readability-duplicate-include,
readability-else-after-return,
readability-enum-initial-value,
readability-identifier-naming,
readability-implicit-bool-conversion,
readability-inconsistent-declaration-parameter-name,
readability-make-member-function-const,
readability-math-missing-parentheses,
readability-misleading-indentation,
readability-non-const-parameter,
readability-redundant-casting,
readability-redundant-declaration,
readability-redundant-inline-specifier,
readability-redundant-member-init,
readability-redundant-string-init,
readability-reference-to-constructed-temporary,
readability-simplify-boolean-expr,
readability-static-accessed-through-instance,
readability-static-definition-in-anonymous-namespace,
readability-suspicious-call-argument,
readability-use-std-min-max
misc-*,
-misc-anonymous-namespace-in-header,
-misc-confusable-identifiers,
-misc-coroutine-hostile-raii,
-misc-misleading-bidirectional,
-misc-misleading-identifier,
-misc-multiple-inheritance,
-misc-new-delete-overloads,
-misc-no-recursion,
-misc-non-copyable-objects,
-misc-non-private-member-variables-in-classes,
-misc-override-with-different-visibility,
-misc-predictable-rand,
-misc-unconventional-assign-operator,
-misc-uniqueptr-reset-release,
-misc-unused-parameters,
-misc-use-anonymous-namespace,
-misc-use-internal-linkage,
modernize-*,
-modernize-avoid-bind,
-modernize-avoid-c-arrays,
-modernize-avoid-c-style-cast,
-modernize-avoid-setjmp-longjmp,
-modernize-avoid-variadic-functions,
-modernize-deprecated-ios-base-aliases,
-modernize-loop-convert,
-modernize-macro-to-enum,
-modernize-min-max-use-initializer-list,
-modernize-raw-string-literal,
-modernize-redundant-void-arg,
-modernize-replace-auto-ptr,
-modernize-replace-disallow-copy-and-assign-macro,
-modernize-replace-random-shuffle,
-modernize-return-braced-init-list,
-modernize-shrink-to-fit,
-modernize-unary-static-assert,
-modernize-use-auto,
-modernize-use-bool-literals,
-modernize-use-constraints,
-modernize-use-default-member-init,
-modernize-use-integer-sign-comparison,
-modernize-use-noexcept,
-modernize-use-nullptr,
-modernize-use-std-format,
-modernize-use-std-print,
-modernize-use-trailing-return-type,
-modernize-use-transparent-functors,
-modernize-use-uncaught-exceptions,
performance-*,
-performance-avoid-endl,
-performance-enum-size,
-performance-inefficient-algorithm,
-performance-inefficient-string-concatenation,
-performance-no-int-to-ptr,
-performance-noexcept-destructor,
-performance-noexcept-move-constructor,
-performance-noexcept-swap,
-performance-type-promotion-in-math-fn,
-performance-unnecessary-copy-initialization,
-performance-unnecessary-value-param,
readability-*,
-readability-avoid-const-params-in-decls,
-readability-avoid-unconditional-preprocessor-if,
-readability-container-data-pointer,
-readability-delete-null-pointer,
-readability-function-cognitive-complexity,
-readability-function-size,
-readability-identifier-length,
-readability-isolate-declaration,
-readability-magic-numbers,
-readability-misplaced-array-index,
-readability-named-parameter,
-readability-operators-representation,
-readability-qualified-auto,
-readability-redundant-access-specifiers,
-readability-redundant-control-flow,
-readability-redundant-function-ptr-dereference,
-readability-redundant-preprocessor,
-readability-redundant-smartptr-get,
-readability-redundant-string-cstr,
-readability-simplify-subscript-expr,
-readability-string-compare,
-readability-uniqueptr-delete-release,
-readability-uppercase-literal-suffix,
-readability-use-anyofallof,
-readability-use-concise-preprocessor-directives
"
# ---
# bugprone-narrowing-conversions, # This will break a lot of code but we should enable it in the future because it can eliminate a lot of bugs
# misc-override-with-different-visibility, # Will be addressed in a future PR, but for now it generates too many warnings
# ---
CheckOptions:
bugprone-unsafe-functions.ReportMoreUnsafeFunctions: true

View File

@@ -44,12 +44,12 @@ jobs:
if: ${{ github.event_name == 'pull_request' }}
permissions:
contents: read
uses: XRPLF/actions/.github/workflows/determine-tidy-files.yml@224f3c48d3014d082a1129237b8291ff0b0a331f
uses: XRPLF/actions/.github/workflows/determine-tidy-files.yml@d041ac9f1fa9f07a4ba335eb4c1c82233fb3fef6
run-clang-tidy:
name: Run clang tidy
needs: [determine-files]
if: ${{ always() && !cancelled() && (github.event_name != 'pull_request' || needs.determine-files.outputs.cpp_changed_files != '' || needs.determine-files.outputs.clang_tidy_config_changed == 'true') }}
if: ${{ needs.determine-files.outputs.cpp_changed_files != '' || needs.determine-files.outputs.need_full_run == 'true' }}
runs-on: heavy
container:
image: ghcr.io/xrplf/xrpld/nix-ubuntu:sha-cb2642b
@@ -63,7 +63,7 @@ jobs:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Prepare runner
uses: XRPLF/actions/prepare-runner@90f11ee655d1687824fb8793db770477d52afbab
uses: XRPLF/actions/prepare-runner@9355d190fd7d4de80fadfd161e6edddc9702cd9f
with:
enable_ccache: false
@@ -98,7 +98,7 @@ jobs:
continue-on-error: true
id: run_clang_tidy
env:
TARGETS: ${{ (needs.determine-files.outputs.clang_tidy_config_changed != 'true' && github.event_name == 'pull_request') && needs.determine-files.outputs.cpp_changed_files || 'benchmarks src tests' }}
TARGETS: ${{ needs.determine-files.outputs.need_full_run != 'true' && needs.determine-files.outputs.cpp_changed_files || 'benchmarks src tests' }}
run: |
set -o pipefail
run-clang-tidy -j ${{ steps.nproc.outputs.nproc }} -p "${BUILD_DIR}" -quiet -fix -allow-no-checks ${TARGETS} 2>&1 | tee "${OUTPUT_FILE}"

View File

@@ -82,7 +82,7 @@ public:
void
run(std::size_t numThreads)
{
using OpType = typename CtxType::template StoppableOperation<void>;
using OpType = CtxType::template StoppableOperation<void>;
CtxType ctx{numThreads};
std::vector<OpType> operations;

View File

@@ -87,7 +87,7 @@ synchronous(FnType&& func)
{
boost::asio::io_context ctx;
using R = typename boost::result_of<FnType(boost::asio::yield_context)>::type;
using R = boost::result_of<FnType(boost::asio::yield_context)>::type;
if constexpr (!std::is_same_v<R, void>) {
R res;
util::spawn(ctx, [_ = boost::asio::make_work_guard(ctx), &func, &res](auto yield) {

View File

@@ -35,7 +35,7 @@ template <
SomeRetryPolicy RetryPolicyType = ExponentialBackoffRetryPolicy>
class AsyncExecutor : public std::enable_shared_from_this<
AsyncExecutor<StatementType, HandleType, RetryPolicyType>> {
using FutureWithCallbackType = typename HandleType::FutureWithCallbackType;
using FutureWithCallbackType = HandleType::FutureWithCallbackType;
using CallbackType = std::function<void(typename HandleType::ResultOrErrorType)>;
using RetryCallbackType = std::function<void()>;

View File

@@ -65,15 +65,15 @@ class DefaultExecutionStrategy {
std::reference_wrapper<HandleType const> handle_;
std::thread thread_;
typename BackendCountersType::PtrType counters_;
BackendCountersType::PtrType counters_;
public:
using ResultOrErrorType = typename HandleType::ResultOrErrorType;
using StatementType = typename HandleType::StatementType;
using PreparedStatementType = typename HandleType::PreparedStatementType;
using FutureType = typename HandleType::FutureType;
using FutureWithCallbackType = typename HandleType::FutureWithCallbackType;
using ResultType = typename HandleType::ResultType;
using ResultOrErrorType = HandleType::ResultOrErrorType;
using StatementType = HandleType::StatementType;
using PreparedStatementType = HandleType::PreparedStatementType;
using FutureType = HandleType::FutureType;
using FutureWithCallbackType = HandleType::FutureWithCallbackType;
using ResultType = HandleType::ResultType;
using CompletionTokenType = boost::asio::yield_context;
/**
@@ -83,7 +83,7 @@ public:
DefaultExecutionStrategy(
Settings const& settings,
HandleType const& handle,
typename BackendCountersType::PtrType counters = BackendCountersType::make()
BackendCountersType::PtrType counters = BackendCountersType::make()
)
: maxWriteRequestsOutstanding_{settings.maxWriteRequestsOutstanding}
, maxReadRequestsOutstanding_{settings.maxReadRequestsOutstanding}

View File

@@ -775,8 +775,9 @@ logDuration(
LOG(log.error()) << tag << msg;
} else if (seconds > 1) {
LOG(log.warn()) << tag << msg;
} else
} else {
LOG(log.info()) << tag << msg;
}
}
/**

View File

@@ -51,7 +51,7 @@ concept SomeProcessor = (SomeRequirement<T> or SomeModifier<T>);
*/
template <typename T>
concept SomeContextProcessWithInput =
requires(T a, typename T::Input const& in, typename T::Output out, Context const& ctx) {
requires(T a, T::Input const& in, T::Output out, Context const& ctx) {
{ a.process(in, ctx) } -> std::same_as<HandlerReturnType<decltype(out)>>;
};
@@ -59,7 +59,7 @@ concept SomeContextProcessWithInput =
* @brief A process function that expects no Input but does take a Context.
*/
template <typename T>
concept SomeContextProcessWithoutInput = requires(T a, typename T::Output out, Context const& ctx) {
concept SomeContextProcessWithoutInput = requires(T a, T::Output out, Context const& ctx) {
{ a.process(ctx) } -> std::same_as<HandlerReturnType<decltype(out)>>;
};

View File

@@ -14,7 +14,7 @@ class RandomGeneratorInterface {
public:
virtual ~RandomGeneratorInterface() = default;
using SeedType = typename std::mt19937_64::result_type;
using SeedType = std::mt19937_64::result_type;
/**
* @brief Generate a random number between min and max

View File

@@ -100,7 +100,7 @@ public:
template <typename Generator>
class TagDecorator final : public BaseTagDecorator {
using ParentType = std::optional<std::reference_wrapper<BaseTagDecorator const>>;
using TagType = typename Generator::TagType;
using TagType = Generator::TagType;
ParentType parent_ = std::nullopt;
TagType tag_ = Generator::next();

View File

@@ -28,7 +28,7 @@ protected:
std::future<typename OutcomeType::DataType> future_;
public:
using DataType = typename OutcomeType::DataType;
using DataType = OutcomeType::DataType;
explicit BasicOperation(OutcomeType* outcome) : future_{outcome->getStdFuture()}
{
@@ -77,7 +77,7 @@ struct BasicScheduledOperation : util::MoveTracker {
};
std::shared_ptr<State> state = std::make_shared<State>();
typename CtxType::Timer timer;
CtxType::Timer timer;
BasicScheduledOperation(auto& executor, auto delay, auto&& fn)
: timer(

View File

@@ -125,14 +125,14 @@ public:
using ContextHolderType = ContextType;
using ExecutorType = typename ContextHolderType::Executor;
using ExecutorType = ContextHolderType::Executor;
template <typename T>
using ValueType = std::expected<T, ExecutionError>;
using StopSource = StopSourceType;
using StopToken = typename StopSourceType::Token;
using StopToken = StopSourceType::Token;
template <typename T>
using StoppableOperation = StoppableOperation<ValueType<T>, StopSourceType>;
@@ -147,7 +147,7 @@ public:
TimerContextProvider,
ErrorHandlerType>;
using Timer = typename ContextHolderType::Timer;
using Timer = ContextHolderType::Timer;
// note: scheduled operations are always stoppable
template <typename T>
@@ -425,7 +425,7 @@ public:
*
* @return Reference to the underlying executor
*/
typename ContextType::Executor&
ContextType::Executor&
getExecutor()
{
return context_.getExecutor();

View File

@@ -23,17 +23,17 @@ template <
typename ErrorHandlerType = impl::DefaultErrorHandler>
class BasicStrand {
std::reference_wrapper<ParentContextType> parentContext_;
typename ParentContextType::ContextHolderType::Strand context_;
ParentContextType::ContextHolderType::Strand context_;
friend AssociatedExecutorExtractor;
public:
static constexpr bool kIsNoexcept = noexcept(ErrorHandlerType::wrap([](auto&) { throw 0; }));
using ContextHolderType = typename ParentContextType::ContextHolderType::Strand;
using ExecutorType = typename ContextHolderType::Executor;
using StopToken = typename StopSourceType::Token;
using Timer = typename ParentContextType::ContextHolderType::Timer; // timers are associated
// with the parent context
using ContextHolderType = ParentContextType::ContextHolderType::Strand;
using ExecutorType = ContextHolderType::Executor;
using StopToken = StopSourceType::Token;
using Timer = ParentContextType::ContextHolderType::Timer; // timers are associated
// with the parent context
using RepeatedOperation = RepeatingOperation<BasicStrand>;
BasicStrand(ParentContextType& parent, auto&& strand)

View File

@@ -16,7 +16,7 @@ namespace util::async::impl {
inline constexpr struct AssociatedExecutorExtractor {
template <typename CtxType>
[[nodiscard]] typename CtxType::ExecutorType&
[[nodiscard]] CtxType::ExecutorType&
operator()(CtxType& ctx) const noexcept
{
return ctx.context_.getExecutor();
@@ -31,7 +31,7 @@ getTimeoutHandleIfNeeded(
SomeStopSource auto& stopSource
)
{
using TimerType = typename CtxType::Timer;
using TimerType = CtxType::Timer;
std::optional<TimerType> timer;
if (timeout) {
timer.emplace(extractAssociatedExecutor(ctx), *timeout, [&stopSource](auto cancelled) {

View File

@@ -47,9 +47,10 @@ class ClioConfigDefinition;
* Note: Currently this introduces potential shadowing (unlikely).
*/
#ifndef COVERAGE_ENABLED
#define LOG(x) \
if (auto clio_pump__ = x; not clio_pump__) { \
} else \
#define LOG(x) \
if (auto clio_pump__ = x; not clio_pump__) \
; \
else \
clio_pump__
#else
#define LOG(x) x

View File

@@ -1,4 +1,3 @@
#include "util/LoggerBuffer.hpp"
#include "util/LoggerFixtures.hpp"
#include "util/config/Array.hpp"
#include "util/config/ConfigConstraints.hpp"
@@ -70,12 +69,6 @@ protected:
{"log.tag_style", ConfigValue{ConfigType::String}.defaultValue("none")},
};
std::string
getLoggerString()
{
return buffer_.getStrAndReset();
}
};
TEST_F(LogServiceInitTests, DefaultLogLevel)