Sponsored Content
Skip to content

chore: Enable clang-tidy readability checks - #6930

Merged
bthomee merged 11 commits into
XRPLF:developfrom
godexsoft:chore/clang-tidy-readability2
Apr 17, 2026
Merged

chore: Enable clang-tidy readability checks#6930
bthomee merged 11 commits into
XRPLF:developfrom
godexsoft:chore/clang-tidy-readability2

Conversation

@godexsoft

@godexsoft godexsoft commented Apr 13, 2026

Copy link
Copy Markdown
Contributor

High Level Overview of Change

This PR enables the following clang-tidy checks:

  • readability-avoid-nested-conditional-operator
  • readability-avoid-return-with-void-value
  • readability-braces-around-statements
  • readability-const-return-type
  • readability-container-size-empty
  • readability-convert-member-functions-to-static
  • readability-else-after-return
  • readability-enum-initial-value
  • readability-implicit-bool-conversion
  • readability-make-member-function-const
  • readability-math-missing-parentheses
  • readability-non-const-parameter
  • readability-redundant-casting
  • readability-redundant-inline-specifier
  • readability-redundant-member-init
  • readability-simplify-boolean-expr
  • readability-static-definition-in-anonymous-namespace
  • readability-suspicious-call-argument

Context of Change

Fix clang-tidy for all source.

API Impact

No impact.

@godexsoft godexsoft added the DraftRunCI Normally CI does not run on draft PRs. This opts in. label Apr 13, 2026
@godexsoft godexsoft changed the title Enable checks and fix compilation chore: Enable clang-tidy readability checks Apr 13, 2026
@codecov

codecov Bot commented Apr 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.30769% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.6%. Comparing base (4a73be4) to head (ded6378).

Files with missing lines Patch % Lines
include/xrpl/nodestore/detail/codec.h 0.0% 4 Missing ⚠️
src/xrpld/app/misc/detail/WorkPlain.h 0.0% 2 Missing ⚠️
include/xrpl/core/PeerReservationTable.h 0.0% 1 Missing ⚠️
include/xrpl/tx/paths/detail/Steps.h 66.7% 1 Missing ⚠️
src/xrpld/overlay/detail/PeerReservationTable.cpp 0.0% 1 Missing ⚠️
src/xrpld/overlay/predicates.h 0.0% 1 Missing ⚠️
src/xrpld/peerfinder/detail/Counts.h 0.0% 1 Missing ⚠️
src/xrpld/peerfinder/detail/Logic.h 75.0% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##           develop   #6930     +/-   ##
=========================================
- Coverage     81.6%   81.6%   -0.0%     
=========================================
  Files         1010    1010             
  Lines        75972   75992     +20     
  Branches      7610    7610             
=========================================
+ Hits         61984   61996     +12     
- Misses       13988   13996      +8     
Files with missing lines Coverage Δ
include/xrpl/basics/BasicConfig.h 89.7% <ø> (ø)
include/xrpl/basics/Buffer.h 100.0% <100.0%> (ø)
include/xrpl/basics/CompressionAlgorithms.h 0.0% <ø> (ø)
include/xrpl/basics/DecayingSample.h 88.2% <100.0%> (ø)
include/xrpl/basics/IntrusiveRefCounts.h 92.7% <100.0%> (ø)
include/xrpl/basics/LocalValue.h 100.0% <100.0%> (ø)
include/xrpl/basics/Number.h 98.7% <100.0%> (+<0.1%) ⬆️
include/xrpl/basics/RangeSet.h 90.7% <ø> (ø)
include/xrpl/basics/SlabAllocator.h 93.4% <100.0%> (ø)
include/xrpl/basics/Slice.h 96.8% <100.0%> (ø)
... and 111 more

... and 3 files with indirect coverage changes

Impacted file tree graph

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@godexsoft
godexsoft requested a review from mathbunnyru April 14, 2026 12:55
Comment thread include/xrpl/basics/Number.h
Comment thread include/xrpl/core/PeerReservationTable.h
Comment thread include/xrpl/tx/paths/detail/StepChecks.h
Comment thread include/xrpl/basics/base_uint.h Outdated
Comment thread include/xrpl/basics/CompressionAlgorithms.h Outdated
Comment thread include/xrpl/basics/LocalValue.h
Comment thread include/xrpl/beast/container/detail/aged_container_iterator.h Outdated
Comment thread include/xrpl/beast/utility/Journal.h Outdated
Comment thread include/xrpl/beast/utility/Zero.h
Comment thread include/xrpl/protocol/Asset.h
@godexsoft
godexsoft requested a review from mathbunnyru April 14, 2026 14:35
@mathbunnyru
mathbunnyru requested a review from Copilot April 14, 2026 14:53

@mathbunnyru mathbunnyru left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I asked Copilot to review (just to check if there are no mistype errors)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enables a set of clang-tidy readability checks and applies the corresponding mechanical refactors across xrpld, libxrpl, and the test suite to bring the codebase into compliance (e.g., braces, contains(), const correctness, static conversions, and boolean/nullable clarity).

Changes:

  • Enabled additional readability-* clang-tidy checks in .clang-tidy.
  • Applied repo-wide readability-driven edits (e.g., add braces, simplify boolean expressions, use contains(), remove redundant inline, make methods const/static where applicable).
  • Added targeted NOLINT suppressions where clang-tidy would otherwise require non-idiomatic changes.

Reviewed changes

Copilot reviewed 150 out of 150 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/xrpld/rpc/json_body.h Convert eligible member function to static per readability check.
src/xrpld/rpc/handlers/server_info/Version.h Make check() static; mark writeResult() const.
src/xrpld/rpc/detail/Tuning.h Remove redundant inline on constexpr function.
src/xrpld/rpc/detail/TrustLine.h Make implicit-bool-from-bitmask checks explicit.
src/xrpld/rpc/Status.h Add braces to satisfy readability-braces-around-statements.
src/xrpld/rpc/Context.h Remove redundant default member initializers for smart pointers.
src/xrpld/rpc/BookChanges.h Simplify nested conditional logic; use contains(); add braces.
src/xrpld/peerfinder/detail/Logic.h Use contains(); add braces; simplify control flow.
src/xrpld/peerfinder/detail/Livecache.h Simplify else if chain per readability rules.
src/xrpld/peerfinder/detail/Counts.h Simplify boolean logic; mark onWrite() const; add braces.
src/xrpld/peerfinder/detail/Bootcache.h Simplify comparison operator implementation.
src/xrpld/overlay/predicates.h Simplify boolean returns; use contains().
src/xrpld/overlay/detail/TrafficCount.h Make implicit bool conversion explicit for counters.
src/xrpld/overlay/detail/ProtocolVersion.h Remove redundant inline on constexpr function.
src/xrpld/overlay/detail/ProtocolMessage.h Add braces around single-statement branch.
src/xrpld/overlay/detail/PeerReservationTable.cpp Use designated initializer for key lookup.
src/xrpld/overlay/detail/PeerImp.h Add NOLINT for redundant member init flagged by clang-tidy.
src/xrpld/overlay/Squelch.h Simplify else if chain per readability checks.
src/xrpld/overlay/Slot.h Use empty()/contains(); add braces around single-statement blocks.
src/xrpld/overlay/Compression.h Restructure invalid-enum handling; add braces per readability.
src/xrpld/overlay/ClusterNode.h Remove redundant default member initializer.
src/xrpld/core/TimeKeeper.h (Bug risk) Removed atomic value-initialization (needs fix).
src/xrpld/consensus/Validations.h Add braces; make optional-handling explicit.
src/xrpld/consensus/LedgerTrie.h Replace !ptr with explicit ptr == nullptr; add braces.
src/xrpld/consensus/DisputedTx.h Make zero checks explicit; flatten else if chains; add braces.
src/xrpld/consensus/Consensus.h Add braces; simplify boolean/zero comparisons.
src/xrpld/app/misc/detail/WorkPlain.h Avoid return void_expr; split into call + return.
src/xrpld/app/misc/detail/WorkFile.h Add braces; adjust early return structure.
src/xrpld/app/misc/detail/WorkBase.h Add braces around early-return posting path.
src/xrpld/app/misc/TxQ.h Replace nested ternary with lambda; make empty() explicit.
src/xrpld/app/misc/Transaction.h Mark eligible getters const.
src/xrpld/app/misc/SHAMapStoreImp.h (Bug risk) Removed atomic value-initialization (needs fix).
src/xrpld/app/ledger/detail/LedgerDeltaAcquire.h Remove redundant shared_ptr default initializers.
src/xrpld/app/ledger/LedgerToJson.h Make pointer null check explicit.
src/xrpld/app/ledger/LedgerReplayTask.h Remove redundant default initializers for members.
src/xrpld/app/ledger/LedgerMaster.h Remove redundant default initializer.
src/xrpld/app/consensus/RCLCxPeerPos.h Remove redundant cast flagged by readability checks.
src/test/unit_test/SuiteJournal.h Remove redundant inline in class definitions.
src/test/unit_test/FileDirGuard.h Add braces to single-statement branches.
src/test/nodestore/TestBase.h Convert eligible helper to static.
src/test/jtx/xchain_bridge.h Mark helper const.
src/test/jtx/vault.h Add NOLINT for redundant optional initialization.
src/test/jtx/mpt.h Add NOLINT for redundant member init per clang-tidy.
src/test/jtx/amount.h Remove redundant inline; convert eligible functions to static.
src/test/jtx/TrustedPublisherServer.h Add braces throughout request handling; readability compliance.
src/test/jtx/TestHelpers.h Remove redundant string initialization; add NOLINT for members.
src/test/jtx/Oracle.h Add NOLINT for redundant member init per clang-tidy.
src/test/jtx/ManualTimeKeeper.h (Bug risk) Removed atomic value-initialization (needs fix).
src/test/jtx/Env.h Add braces; add NOLINTNEXTLINE where const-qualification is blocked by design.
src/test/jtx/AMM.h Mark accessors const; add braces for output formatting branches.
src/test/csf/random.h Remove redundant inline.
src/test/csf/collectors.h Add braces around single-statement branch.
src/test/csf/Tx.h Add braces around comma-formatting logic.
src/test/csf/Scheduler.h Add braces around loop body.
src/test/csf/Peer.h Convert eligible methods to static; use contains(); add braces.
src/test/csf/BasicNetwork.h Remove redundant default initializer.
src/test/app/Vault_test.cpp Make locals const where appropriate.
src/test/app/AMM_test.cpp Add NOLINTNEXTLINE for non-static test method.
src/libxrpl/tx/transactors/vault/VaultCreate.cpp Explicitly populate optional fields when constructing args.
src/libxrpl/ledger/PaymentSandbox.cpp Use contains() for map lookup.
include/xrpl/tx/transactors/token/MPTokenIssuanceCreate.h Add NOLINT for redundant optional initialization.
include/xrpl/tx/transactors/token/MPTokenAuthorize.h Remove redundant optional default initializer.
include/xrpl/tx/paths/detail/StrandFlow.h Add braces; refactor if constexpr chains for readability.
include/xrpl/tx/paths/detail/Steps.h Refactor init-statement if; add braces; simplify returns.
include/xrpl/tx/paths/detail/StepChecks.h Make bitmask-to-bool explicit.
include/xrpl/tx/paths/detail/FlowDebugInfo.h Add braces around nested conditional formatting.
include/xrpl/tx/paths/Offer.h Add braces; make amendment-guarded branch explicit.
include/xrpl/tx/invariants/VaultInvariant.h Remove redundant member initializers for aggregates.
include/xrpl/tx/applySteps.h Make bit-test explicit with == 0u.
include/xrpl/shamap/SHAMapInnerNode.h Remove redundant inline for static constexpr.
include/xrpl/shamap/SHAMap.h Remove redundant inline for static constexpr; add braces in iterator++.
include/xrpl/server/detail/io_list.h Add braces around loop body.
include/xrpl/server/detail/ServerImpl.h Make “port set” check explicit against 0u.
include/xrpl/server/detail/Door.h Make count-to-bool explicit; add braces; simplify FD throttle return.
include/xrpl/server/detail/BaseWSPeer.h Add braces around if/else write paths.
include/xrpl/server/detail/BaseHTTPPeer.h Add braces; simplify if/else into early-return patterns.
include/xrpl/server/NetworkOPs.h Remove redundant inline on static helper.
include/xrpl/server/LoadFeeTrack.h Convert eligible method to static.
include/xrpl/resource/detail/Logic.h Add braces; convert eligible helper to static.
include/xrpl/resource/detail/Import.h Remove redundant member init from constructor initializer list.
include/xrpl/resource/detail/Entry.h Remove redundant member init from constructor initializer list.
include/xrpl/protocol/digest.h Remove redundant inline on private helpers.
include/xrpl/protocol/detail/b58_utils.h Make arithmetic grouping explicit; use empty() and explicit zero checks.
include/xrpl/protocol/detail/STVar.h Add braces around if constexpr branches.
include/xrpl/protocol/XRPAmount.h Expand nested ternary; make zero-divisor check explicit.
include/xrpl/protocol/Units.h Expand nested ternary in signum().
include/xrpl/protocol/Serializer.h Make size check explicit != 0u.
include/xrpl/protocol/SecretKey.h Remove redundant inline on deleted operators.
include/xrpl/protocol/STVector256.h Avoid return void_expr pattern.
include/xrpl/protocol/STValidation.h Remove redundant default initializer.
include/xrpl/protocol/STObject.h Make pointer checks explicit; add braces around branches.
include/xrpl/protocol/STCurrency.h Remove redundant default initializer.
include/xrpl/protocol/STBlob.h Remove redundant cast; return underlying pointer directly.
include/xrpl/protocol/STAmount.h Add parentheses; add braces; simplify signum().
include/xrpl/protocol/Quality.h Make zero check explicit != 0.
include/xrpl/protocol/PublicKey.h Convert constant-size accessor to static.
include/xrpl/protocol/PathAsset.h Add braces around if constexpr branches.
include/xrpl/protocol/MultiApiJson.h Replace nested ternary with explicit branching; add braces.
include/xrpl/protocol/MPTIssue.h Convert eligible methods to static; remove redundant inline on deleted overloads.
include/xrpl/protocol/MPTAmount.h Expand nested ternary; make zero-divisor check explicit.
include/xrpl/protocol/LedgerHeader.h Remove redundant time_point default initializers.
include/xrpl/protocol/Issue.h Remove redundant default initializers; remove redundant inline on constexpr op.
include/xrpl/protocol/IOUAmount.h Expand nested ternary.
include/xrpl/protocol/Feature.h Assign explicit enum values; add braces in iteration helper.
include/xrpl/protocol/Book.h Remove redundant inline on constexpr comparisons.
include/xrpl/protocol/Asset.h Add braces in variant visitors; remove duplicate/now-inlined JSON decls.
include/xrpl/protocol/AmountConversions.h Add braces in if constexpr chains.
include/xrpl/nodestore/detail/varint.h Add braces around loop body.
include/xrpl/nodestore/detail/codec.h Add braces around error checks; parenthesize arithmetic.
include/xrpl/nodestore/Types.h Assign explicit enum values.
include/xrpl/net/HTTPClientSSLContext.h Add braces around exception-throwing branches.
include/xrpl/net/AutoSocket.h Mark isSecure() const; add braces around secure/plain branches.
include/xrpl/ledger/helpers/DirectoryHelpers.h Avoid return void_expr pattern.
include/xrpl/ledger/helpers/AMMHelpers.h Refactor init-statement if; add braces; simplify returns.
include/xrpl/ledger/PendingSaves.h Use contains() for map lookup.
include/xrpl/ledger/CanonicalTXSet.h Remove redundant inline on friend operators.
include/xrpl/ledger/AmendmentTable.h Add braces around delegated call branch.
include/xrpl/json/to_string.h Switch to including json_writer.h; remove duplicate stream-op decls.
include/xrpl/core/PeerReservationTable.h Use contains(); add NOLINT for redundant member init.
include/xrpl/core/ClosureCounter.h Remove redundant default initializers for synchronization primitives.
include/xrpl/conditions/detail/utils.h Make bitmask-to-bool explicit.
include/xrpl/beast/utility/Zero.h Remove redundant static in unnamed-namespace constant.
include/xrpl/beast/utility/Journal.h Make enum values explicit; modernize type trait checks with _v.
include/xrpl/beast/unit_test/suite.h Make propagate_abort() const; add braces.
include/xrpl/beast/unit_test/runner.h Add braces around loops/conditionals.
include/xrpl/beast/unit_test/recorder.h Use empty() instead of size() > 0.
include/xrpl/beast/type_name.h Add braces around reference-qualifier appends.
include/xrpl/beast/test/yield_to.h Make decrement-to-bool explicit.
include/xrpl/beast/rfc2616.h Add braces around loops/conditionals.
include/xrpl/beast/net/IPEndpoint.h Remove pointless const on by-value returns.
include/xrpl/beast/net/IPAddress.h Add braces in hash_append branching.
include/xrpl/beast/hash/xxhasher.h Make null/len checks explicit; simplify branching.
include/xrpl/beast/core/SemanticVersion.h Remove redundant inline.
include/xrpl/beast/container/detail/aged_container_iterator.h Modernize enable_if / type traits (_t, _v) and conditional type usage.
include/xrpl/beast/asio/io_latency_probe.h Make null checks explicit; parenthesize arithmetic.
include/xrpl/basics/safe_cast.h Remove redundant inline on constexpr templates.
include/xrpl/basics/partitioned_unordered_map.h Make zero comparisons explicit.
include/xrpl/basics/base_uint.h Add braces; adjust loop style; remove pointless const by-value returns.
include/xrpl/basics/algorithm.h Add braces around single-statement branch.
include/xrpl/basics/Slice.h Use empty() instead of size() == 0.
include/xrpl/basics/SlabAllocator.h Make null/zero comparisons explicit.
include/xrpl/basics/RangeSet.h Add braces around parse branches.
include/xrpl/basics/Number.h Parenthesize arithmetic; expand ternaries; remove redundant inline on constexpr.
include/xrpl/basics/LocalValue.h Make null checks explicit; remove redundant inline.
include/xrpl/basics/IntrusiveRefCounts.h Replace while(1) with while(true); make bit checks explicit.
include/xrpl/basics/DecayingSample.h Make decrement-to-bool explicit.
include/xrpl/basics/CompressionAlgorithms.h Add NOLINTNEXTLINE and braces around failure branch.
include/xrpl/basics/Buffer.h Make zero checks explicit; use empty(); avoid return void_expr.
include/xrpl/basics/BasicConfig.h Add braces around branches; make error path clearer.
.clang-tidy Enable new readability checks in clang-tidy configuration.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/test/jtx/ManualTimeKeeper.h
Comment thread src/xrpld/app/misc/SHAMapStoreImp.h
Comment thread src/xrpld/core/TimeKeeper.h
@godexsoft godexsoft removed the DraftRunCI Normally CI does not run on draft PRs. This opts in. label Apr 14, 2026
Comment thread include/xrpl/beast/container/detail/aged_container_iterator.h Outdated
Comment thread include/xrpl/beast/container/detail/aged_container_iterator.h Outdated
Comment thread include/xrpl/beast/container/detail/aged_container_iterator.h Outdated
Comment thread include/xrpl/protocol/Issue.h
Comment thread src/xrpld/overlay/detail/PeerImp.h Outdated
Comment thread src/xrpld/app/misc/detail/WorkFile.h Outdated
@godexsoft
godexsoft requested a review from a1q123456 April 16, 2026 16:27
@godexsoft godexsoft added the Ready to merge *PR author* thinks it's ready to merge. Has passed code review. Perf sign-off may still be required. label Apr 17, 2026
@bthomee
bthomee added this pull request to the merge queue Apr 17, 2026
Merged via the queue into XRPLF:develop with commit f1a5ba4 Apr 17, 2026
3 checks passed
marek-foss-neti pushed a commit to marek-foss-neti/rippled that referenced this pull request May 5, 2026
Co-authored-by: Ayaz Salikhov <mathbunnyru@users.noreply.github.com>
beartec-jpg pushed a commit to beartec-jpg/FalconLedger that referenced this pull request Jun 1, 2026
Co-authored-by: Ayaz Salikhov <mathbunnyru@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ready to merge *PR author* thinks it's ready to merge. Has passed code review. Perf sign-off may still be required.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants