chore: Enable clang-tidy readability checks - #6930
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ 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
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
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 redundantinline, make methodsconst/staticwhere applicable). - Added targeted
NOLINTsuppressions 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.
Co-authored-by: Ayaz Salikhov <mathbunnyru@users.noreply.github.com>
Co-authored-by: Ayaz Salikhov <mathbunnyru@users.noreply.github.com>
High Level Overview of Change
This PR enables the following clang-tidy checks:
Context of Change
Fix clang-tidy for all source.
API Impact
No impact.