From 6f0f5b8bb36c30c2578a62d1b2a5befa736da4c4 Mon Sep 17 00:00:00 2001 From: Ayaz Salikhov Date: Thu, 2 Jul 2026 17:26:09 +0100 Subject: [PATCH] chore: Make clang-tidy happy on macOS (#7701) --- BUILD.md | 2 +- bin/pre-commit/clang_tidy_check.py | 8 +++++--- include/xrpl/beast/unit_test/suite_list.h | 6 +++--- include/xrpl/ledger/ApplyView.h | 2 +- include/xrpl/ledger/ReadView.h | 2 +- include/xrpl/ledger/helpers/LendingHelpers.h | 2 +- include/xrpl/protocol/AmountConversions.h | 2 +- include/xrpl/tx/paths/detail/EitherAmount.h | 2 +- src/libxrpl/ledger/helpers/NFTokenHelpers.cpp | 2 +- src/libxrpl/ledger/helpers/OfferHelpers.cpp | 2 +- src/libxrpl/ledger/helpers/VaultHelpers.cpp | 2 +- src/libxrpl/protocol/Quality.cpp | 4 ++-- src/libxrpl/protocol/STInteger.cpp | 2 +- src/libxrpl/protocol/STTx.cpp | 1 + src/libxrpl/protocol/STValidation.cpp | 2 +- src/libxrpl/tx/transactors/vault/VaultWithdraw.cpp | 2 +- src/test/app/PayChan_test.cpp | 2 +- src/test/app/Vault_test.cpp | 2 +- src/test/beast/beast_io_latency_probe_test.cpp | 2 +- src/test/jtx/impl/amount.cpp | 2 +- src/test/rpc/DepositAuthorized_test.cpp | 2 +- src/xrpld/app/ledger/detail/BuildLedger.cpp | 4 ++-- src/xrpld/app/ledger/detail/InboundLedger.cpp | 4 ++-- src/xrpld/app/ledger/detail/LedgerPersistence.cpp | 4 ++-- src/xrpld/app/ledger/detail/OpenLedger.cpp | 2 +- src/xrpld/app/main/Application.cpp | 4 ++-- src/xrpld/app/misc/FeeVoteImpl.cpp | 2 +- src/xrpld/overlay/detail/PeerImp.cpp | 1 + 28 files changed, 39 insertions(+), 35 deletions(-) diff --git a/BUILD.md b/BUILD.md index 6ccdde12d5..a15c94edc9 100644 --- a/BUILD.md +++ b/BUILD.md @@ -25,7 +25,7 @@ You can verify that the required tools are installed and runnable with: | ----------- | --------------- | | GCC | 15.2 | | Clang | 22 | -| Apple Clang | 17 | +| Apple Clang | 21 | | MSVC | 19.44[^windows] | ## Operating Systems diff --git a/bin/pre-commit/clang_tidy_check.py b/bin/pre-commit/clang_tidy_check.py index d074c56acf..5b5792b405 100755 --- a/bin/pre-commit/clang_tidy_check.py +++ b/bin/pre-commit/clang_tidy_check.py @@ -17,9 +17,11 @@ import subprocess import sys from pathlib import Path +CLANG_TIDY_VERSION = 22 + def find_run_clang_tidy() -> str | None: - for candidate in ("run-clang-tidy-21", "run-clang-tidy"): + for candidate in (f"run-clang-tidy-{CLANG_TIDY_VERSION}", "run-clang-tidy"): if path := shutil.which(candidate): return path return None @@ -44,8 +46,8 @@ def main(): run_clang_tidy = find_run_clang_tidy() if not run_clang_tidy: print( - "clang-tidy check failed: TIDY is enabled but neither " - "'run-clang-tidy-21' nor 'run-clang-tidy' was found in PATH.", + f"clang-tidy check failed: TIDY is enabled but neither " + f"'run-clang-tidy-{CLANG_TIDY_VERSION}' nor 'run-clang-tidy' was found in PATH.", file=sys.stderr, ) return 1 diff --git a/include/xrpl/beast/unit_test/suite_list.h b/include/xrpl/beast/unit_test/suite_list.h index cf9fb9c5b1..7dd0dd80f0 100644 --- a/include/xrpl/beast/unit_test/suite_list.h +++ b/include/xrpl/beast/unit_test/suite_list.h @@ -10,9 +10,9 @@ #include #include -#include -#include -#include +#include // IWYU pragma: keep +#include // IWYU pragma: keep +#include // IWYU pragma: keep namespace beast::unit_test { diff --git a/include/xrpl/ledger/ApplyView.h b/include/xrpl/ledger/ApplyView.h index 3bf5d479d1..e519013d9a 100644 --- a/include/xrpl/ledger/ApplyView.h +++ b/include/xrpl/ledger/ApplyView.h @@ -5,7 +5,7 @@ #include #include #include -#include +#include // IWYU pragma: keep #include #include #include diff --git a/include/xrpl/ledger/ReadView.h b/include/xrpl/ledger/ReadView.h index 8bbd3e06cb..724533039b 100644 --- a/include/xrpl/ledger/ReadView.h +++ b/include/xrpl/ledger/ReadView.h @@ -7,7 +7,7 @@ #include #include #include -#include +#include // IWYU pragma: keep #include #include #include diff --git a/include/xrpl/ledger/helpers/LendingHelpers.h b/include/xrpl/ledger/helpers/LendingHelpers.h index c21e5bf0ce..873abae272 100644 --- a/include/xrpl/ledger/helpers/LendingHelpers.h +++ b/include/xrpl/ledger/helpers/LendingHelpers.h @@ -8,7 +8,7 @@ #include #include #include -#include +#include // IWYU pragma: keep #include #include #include diff --git a/include/xrpl/protocol/AmountConversions.h b/include/xrpl/protocol/AmountConversions.h index 66ada68d6f..3bcd80e827 100644 --- a/include/xrpl/protocol/AmountConversions.h +++ b/include/xrpl/protocol/AmountConversions.h @@ -13,7 +13,7 @@ #include #include -#include +#include // IWYU pragma: keep #include #include diff --git a/include/xrpl/tx/paths/detail/EitherAmount.h b/include/xrpl/tx/paths/detail/EitherAmount.h index 68ad90d2d4..bc9488d5db 100644 --- a/include/xrpl/tx/paths/detail/EitherAmount.h +++ b/include/xrpl/tx/paths/detail/EitherAmount.h @@ -6,7 +6,7 @@ #include // IWYU pragma: keep #include -#include +#include // IWYU pragma: keep #include #include diff --git a/src/libxrpl/ledger/helpers/NFTokenHelpers.cpp b/src/libxrpl/ledger/helpers/NFTokenHelpers.cpp index af429358bb..6dca715a8c 100644 --- a/src/libxrpl/ledger/helpers/NFTokenHelpers.cpp +++ b/src/libxrpl/ledger/helpers/NFTokenHelpers.cpp @@ -24,7 +24,7 @@ #include #include #include -#include +#include // IWYU pragma: keep #include #include #include diff --git a/src/libxrpl/ledger/helpers/OfferHelpers.cpp b/src/libxrpl/ledger/helpers/OfferHelpers.cpp index 5249870143..6e72b71564 100644 --- a/src/libxrpl/ledger/helpers/OfferHelpers.cpp +++ b/src/libxrpl/ledger/helpers/OfferHelpers.cpp @@ -6,7 +6,7 @@ #include #include #include -#include +#include // IWYU pragma: keep #include #include // IWYU pragma: keep #include diff --git a/src/libxrpl/ledger/helpers/VaultHelpers.cpp b/src/libxrpl/ledger/helpers/VaultHelpers.cpp index 3a3a756499..b5b076d1cb 100644 --- a/src/libxrpl/ledger/helpers/VaultHelpers.cpp +++ b/src/libxrpl/ledger/helpers/VaultHelpers.cpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include // IWYU pragma: keep #include #include #include diff --git a/src/libxrpl/protocol/Quality.cpp b/src/libxrpl/protocol/Quality.cpp index 7ad426bef7..dde7921a76 100644 --- a/src/libxrpl/protocol/Quality.cpp +++ b/src/libxrpl/protocol/Quality.cpp @@ -1,12 +1,12 @@ #include -#include +#include // IWYU pragma: keep #include #include #include #include -#include +#include // IWYU pragma: keep namespace xrpl { diff --git a/src/libxrpl/protocol/STInteger.cpp b/src/libxrpl/protocol/STInteger.cpp index 5f3fb6ffa4..b65504dd5f 100644 --- a/src/libxrpl/protocol/STInteger.cpp +++ b/src/libxrpl/protocol/STInteger.cpp @@ -16,7 +16,7 @@ #include #include #include -#include +#include // IWYU pragma: keep namespace xrpl { diff --git a/src/libxrpl/protocol/STTx.cpp b/src/libxrpl/protocol/STTx.cpp index cd2da12316..b3de717da8 100644 --- a/src/libxrpl/protocol/STTx.cpp +++ b/src/libxrpl/protocol/STTx.cpp @@ -596,6 +596,7 @@ STTx::getBatchTransactionIDs() const XRPL_ASSERT( batchTxnIds_->size() == getFieldArray(sfRawTransactions).size(), "STTx::getBatchTransactionIDs : batch transaction IDs size mismatch"); + // NOLINTNEXTLINE(bugprone-unchecked-optional-access): guarded by assert above return *batchTxnIds_; } diff --git a/src/libxrpl/protocol/STValidation.cpp b/src/libxrpl/protocol/STValidation.cpp index 5eafb407ec..1656aad3a2 100644 --- a/src/libxrpl/protocol/STValidation.cpp +++ b/src/libxrpl/protocol/STValidation.cpp @@ -6,7 +6,7 @@ #include #include #include -#include +#include // IWYU pragma: keep #include #include #include diff --git a/src/libxrpl/tx/transactors/vault/VaultWithdraw.cpp b/src/libxrpl/tx/transactors/vault/VaultWithdraw.cpp index 3d30005876..ad91c55723 100644 --- a/src/libxrpl/tx/transactors/vault/VaultWithdraw.cpp +++ b/src/libxrpl/tx/transactors/vault/VaultWithdraw.cpp @@ -11,7 +11,7 @@ #include #include #include -#include +#include // IWYU pragma: keep #include #include #include diff --git a/src/test/app/PayChan_test.cpp b/src/test/app/PayChan_test.cpp index fd2c7790d5..f1a9506e0c 100644 --- a/src/test/app/PayChan_test.cpp +++ b/src/test/app/PayChan_test.cpp @@ -19,7 +19,7 @@ #include #include #include -#include +#include // IWYU pragma: keep #include #include #include diff --git a/src/test/app/Vault_test.cpp b/src/test/app/Vault_test.cpp index f6574872f9..3877e08f7e 100644 --- a/src/test/app/Vault_test.cpp +++ b/src/test/app/Vault_test.cpp @@ -7542,7 +7542,7 @@ class Vault_test : public beast::unit_test::Suite // Transaction fails if the data field is set, but is empty { testcase("VaultDelete memo data featureLendingProtocolV1_1 enabled data empty"); - delTx[sfMemoData] = strHex(std::string(0, 'A')); + delTx[sfMemoData] = strHex(std::string()); env(delTx, Ter(temMALFORMED)); env.close(); } diff --git a/src/test/beast/beast_io_latency_probe_test.cpp b/src/test/beast/beast_io_latency_probe_test.cpp index 9a93968dab..807ad81c49 100644 --- a/src/test/beast/beast_io_latency_probe_test.cpp +++ b/src/test/beast/beast_io_latency_probe_test.cpp @@ -8,7 +8,7 @@ #include #include -#include +#include // IWYU pragma: keep #include #include // IWYU pragma: keep #include diff --git a/src/test/jtx/impl/amount.cpp b/src/test/jtx/impl/amount.cpp index b07703dace..f90102245a 100644 --- a/src/test/jtx/impl/amount.cpp +++ b/src/test/jtx/impl/amount.cpp @@ -12,7 +12,7 @@ #include #include #include -#include +#include // IWYU pragma: keep #include #include #include diff --git a/src/test/rpc/DepositAuthorized_test.cpp b/src/test/rpc/DepositAuthorized_test.cpp index e6720602c9..6d6b54d70a 100644 --- a/src/test/rpc/DepositAuthorized_test.cpp +++ b/src/test/rpc/DepositAuthorized_test.cpp @@ -8,7 +8,7 @@ #include #include -#include +#include // IWYU pragma: keep #include #include #include diff --git a/src/xrpld/app/ledger/detail/BuildLedger.cpp b/src/xrpld/app/ledger/detail/BuildLedger.cpp index 038a7be4b7..d11e0610ba 100644 --- a/src/xrpld/app/ledger/detail/BuildLedger.cpp +++ b/src/xrpld/app/ledger/detail/BuildLedger.cpp @@ -13,10 +13,10 @@ #include #include #include -#include +#include // IWYU pragma: keep #include #include -#include +#include // IWYU pragma: keep #include #include diff --git a/src/xrpld/app/ledger/detail/InboundLedger.cpp b/src/xrpld/app/ledger/detail/InboundLedger.cpp index 4affffd1c1..4d34f60374 100644 --- a/src/xrpld/app/ledger/detail/InboundLedger.cpp +++ b/src/xrpld/app/ledger/detail/InboundLedger.cpp @@ -21,11 +21,11 @@ #include #include #include -#include +#include // IWYU pragma: keep #include #include #include -#include +#include // IWYU pragma: keep #include #include #include diff --git a/src/xrpld/app/ledger/detail/LedgerPersistence.cpp b/src/xrpld/app/ledger/detail/LedgerPersistence.cpp index 3561b66951..6baf64e923 100644 --- a/src/xrpld/app/ledger/detail/LedgerPersistence.cpp +++ b/src/xrpld/app/ledger/detail/LedgerPersistence.cpp @@ -8,9 +8,9 @@ #include #include #include -#include +#include // IWYU pragma: keep #include -#include +#include // IWYU pragma: keep #include #include diff --git a/src/xrpld/app/ledger/detail/OpenLedger.cpp b/src/xrpld/app/ledger/detail/OpenLedger.cpp index 60599c80d3..4d8a37cdf1 100644 --- a/src/xrpld/app/ledger/detail/OpenLedger.cpp +++ b/src/xrpld/app/ledger/detail/OpenLedger.cpp @@ -14,7 +14,7 @@ #include #include #include -#include +#include // IWYU pragma: keep #include #include #include diff --git a/src/xrpld/app/main/Application.cpp b/src/xrpld/app/main/Application.cpp index b99c98afa1..594195b93e 100644 --- a/src/xrpld/app/main/Application.cpp +++ b/src/xrpld/app/main/Application.cpp @@ -79,11 +79,11 @@ #include #include #include -#include +#include // IWYU pragma: keep #include #include #include -#include +#include // IWYU pragma: keep #include #include #include diff --git a/src/xrpld/app/misc/FeeVoteImpl.cpp b/src/xrpld/app/misc/FeeVoteImpl.cpp index 363c17f4fa..76a4d8f186 100644 --- a/src/xrpld/app/misc/FeeVoteImpl.cpp +++ b/src/xrpld/app/misc/FeeVoteImpl.cpp @@ -8,7 +8,7 @@ #include #include #include -#include +#include // IWYU pragma: keep #include #include // IWYU pragma: keep #include diff --git a/src/xrpld/overlay/detail/PeerImp.cpp b/src/xrpld/overlay/detail/PeerImp.cpp index 5ac61cfd91..83e4d9c851 100644 --- a/src/xrpld/overlay/detail/PeerImp.cpp +++ b/src/xrpld/overlay/detail/PeerImp.cpp @@ -2134,6 +2134,7 @@ PeerImp::onValidatorListMessage( publisherListSequences_[pubKey] = applyResult.sequence; } break; + // NOLINTNEXTLINE(bugprone-branch-clone): identical to the next branch only in Release case ListDisposition::SameSequence: case ListDisposition::KnownSequence: #ifndef NDEBUG