Sponsored Content
Skip to content

refactor: Rename static constants - #7120

Merged
bthomee merged 13 commits into
XRPLF:developfrom
godexsoft:refactor/clang-tidy-rename-statics
May 15, 2026
Merged

refactor: Rename static constants#7120
bthomee merged 13 commits into
XRPLF:developfrom
godexsoft:refactor/clang-tidy-rename-statics

Conversation

@godexsoft

@godexsoft godexsoft commented May 12, 2026

Copy link
Copy Markdown
Contributor

High Level Overview of Change

In #6571 we merged clang-tidy's readability-identifier-naming check but used kALL_CAPS for statics and global constants. This style did not receive too much love and kCamelCase is here to replace it.

Other than the renames this PR also reorders 'static constexpr Type' and adds static to missing constexpr constants that can be made static.

API Impact

No impact.

@godexsoft godexsoft added the DraftRunCI Normally CI does not run on draft PRs. This opts in. label May 12, 2026
@codecov

codecov Bot commented May 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.89617% with 78 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.0%. Comparing base (028f0cb) to head (e1e454d).

Files with missing lines Patch % Lines
src/libxrpl/protocol/STAmount.cpp 85.9% 9 Missing ⚠️
src/libxrpl/tx/paths/MPTEndpointStep.cpp 25.0% 9 Missing ⚠️
src/libxrpl/shamap/SHAMapTreeNode.cpp 66.7% 7 Missing ⚠️
include/xrpl/protocol/AmountConversions.h 14.3% 6 Missing ⚠️
src/libxrpl/ledger/ApplyView.cpp 75.0% 4 Missing ⚠️
src/libxrpl/ledger/helpers/LendingHelpers.cpp 87.5% 4 Missing ⚠️
src/libxrpl/tx/paths/DirectStep.cpp 50.0% 4 Missing ⚠️
include/xrpl/resource/detail/Logic.h 82.4% 3 Missing ⚠️
src/libxrpl/server/Vacuum.cpp 0.0% 3 Missing ⚠️
src/libxrpl/tx/paths/XRPEndpointStep.cpp 25.0% 3 Missing ⚠️
... and 21 more
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##           develop   #7120     +/-   ##
=========================================
- Coverage     82.1%   82.0%   -0.0%     
=========================================
  Files         1010    1010             
  Lines        76224   76151     -73     
  Branches      7419    7418      -1     
=========================================
- Hits         62553   62479     -74     
- Misses       13671   13672      +1     
Files with missing lines Coverage Δ
include/xrpl/basics/IntrusivePointer.h 91.7% <ø> (ø)
include/xrpl/basics/IntrusivePointer.ipp 85.6% <100.0%> (ø)
include/xrpl/basics/LocalValue.h 100.0% <100.0%> (ø)
include/xrpl/basics/Log.h 71.4% <ø> (ø)
include/xrpl/basics/Number.h 98.7% <100.0%> (ø)
include/xrpl/basics/StringUtilities.h 100.0% <100.0%> (ø)
include/xrpl/basics/chrono.h 100.0% <100.0%> (ø)
include/xrpl/basics/hardened_hash.h 100.0% <100.0%> (ø)
include/xrpl/basics/random.h 100.0% <100.0%> (ø)
include/xrpl/basics/safe_cast.h 88.9% <100.0%> (ø)
... and 273 more

... and 33 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.

@github-actions

Copy link
Copy Markdown

This PR has conflicts, please resolve them in order for the PR to be reviewed.

@github-actions

Copy link
Copy Markdown

All conflicts have been resolved. Assigned reviewers can now start or resume their review.

@godexsoft
godexsoft marked this pull request as ready for review May 14, 2026 14:08
@godexsoft godexsoft removed the DraftRunCI Normally CI does not run on draft PRs. This opts in. label May 14, 2026
@godexsoft
godexsoft requested a review from ximinez May 14, 2026 14:09

@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.

While we're doing this, let's also unify the order in which we declare static, constexpr and type or auto to be: static constexpr type|auto

It's easy to fix via replace, I suppose, and touches exactly the same lines, so better be done here.

@godexsoft

Copy link
Copy Markdown
Contributor Author

While we're doing this, let's also unify the order in which we declare static, constexpr and type or auto to be: static constexpr type|auto

It's easy to fix via replace, I suppose, and touches exactly the same lines, so better be done here.

I initially thought this would be a separate PR later but i agree we may as well do it here.

@ximinez ximinez 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.

I used Copilot to help find changes that aren't just renames, and it found these.

Comment thread include/xrpl/tx/applySteps.h Outdated
Comment thread include/xrpl/tx/transactors/bridge/XChainBridge.h Outdated
Comment thread include/xrpl/tx/transactors/bridge/XChainBridge.h Outdated
Comment thread include/xrpl/tx/transactors/bridge/XChainBridge.h Outdated
Comment thread include/xrpl/tx/transactors/bridge/XChainBridge.h Outdated
Comment thread src/test/app/AmendmentTable_test.cpp
Comment thread src/libxrpl/tx/paths/OfferStream.cpp Outdated
@godexsoft
godexsoft requested a review from ximinez May 15, 2026 11:45
@godexsoft
godexsoft dismissed ximinez’s stale review May 15, 2026 13:56

Addressed all issues

@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 May 15, 2026
@bthomee
bthomee enabled auto-merge May 15, 2026 13:58
@bthomee
bthomee added this pull request to the merge queue May 15, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch May 15, 2026
@github-actions

Copy link
Copy Markdown

This PR has conflicts, please resolve them in order for the PR to be reviewed.

@github-actions

Copy link
Copy Markdown

All conflicts have been resolved. Assigned reviewers can now start or resume their review.

@bthomee
bthomee added this pull request to the merge queue May 15, 2026
Merged via the queue into XRPLF:develop with commit 5b6e8b6 May 15, 2026
3 checks passed

@ximinez ximinez 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.

It occurred to me overnight to ask if we could change the format of local constexprs & statics to be camelBack style (e.g. ManagerImp::instance() would be inst instead of kInst, but this got merged before I had a chance. Not a deal breaker.

I also wanted to share that I asked Claude yesterday to:

Find any changes in #7120 that aren't limited to renaming a variable, changing formatting and whitespace, or reordering the constexpr keyword in variable declarations. Take the time to review all changes.

This is the report it gave me back. Since we squash, the concerns about intermediate commits are moot. Otherwise, it's pretty neat.

Substantive Changes in PR #7120

1. Bugs Introduced by the Rename Script — Fixed by Commit 06d3d0f

The rename automation and a bad merge-conflict resolution in earlier commits introduced four real bugs,
which commit 06d3d0f
("Fix introduced issues unrelated to renames") corrected. The net PR diff is correct for all of
these, but the intermediate history is messy.

include/xrpl/tx/transactors/bridge/XChainBridge.h — Four wrong ConsequencesFactoryType values

Flagged by @ximinez in 4 review comments.
Merge commit a49d8d1a6 accidentally reset every XChain transactor's kConsequencesFactory to
Normal. The values that were wrong mid-PR:

Class Correct value Broken intermediate
XChainClaim Blocker Normal
XChainCommit Custom Normal
XChainAddClaimAttestation Blocker Normal
XChainAddAccountCreateAttestation Blocker Normal

These affect transaction queuing behavior and are semantically significant. 06d3d0f restored the
correct values, so the final net diff is a pure rename.

include/xrpl/tx/applySteps.h — Spurious {} initializer

Flagged by @ximinez in 1 review comment.
The rename script changed XRPAmount fee_; to XRPAmount fee_{};, adding value-initialization where
none existed. 06d3d0f removed it. Net PR diff for this file is zero (unchanged from base).

include/xrpl/resource/detail/Tuning.h — Dropped static

The rename script dropped static from a constant declaration and misplaced constexpr. 06d3d0f
restored static. Net diff is a pure rename.

src/libxrpl/nodestore/ManagerImp.cpp — Non-mechanical rename

A local static k_ was renamed to kInst rather than a strict kFooBar-style conversion. This is
a rename, but to a semantically new name.


2. Unrelated Changes Pulled In via develop Merges

The PR merged develop twice during its lifetime, bundling in the following unrelated changes.

src/xrpld/rpc/detail/Role.cpp — Security fix in Forwarded header parsing

The forwardedFor() function was substantially refactored (from PR #7126 in develop):

  • Added boundary-checking logic so "for=" only matches at a directive boundary, not inside tokens
    like "before="
  • Changed to a while(true) loop with explicit boundary checking
  • Changed kFOR_STR type from std::string to std::string_view

The rename (kFOR_STRkForStr) is layered on top of this security/correctness fix.

src/libxrpl/tx/transactors/lending/LoanPay.cpp — Logic changes from develop

Includes a fix for a funds-are-conserved assertion and a rename of the feature flag
fixSecurity3_1_3fixCleanup3_1_3.

.clang-tidy — Intentional rule changes (the point of the PR)

  • StaticVariableCase: UPPER_CASEcamelBack (dropping the k prefix requirement)
  • ConstexprVariableCase: UPPER_CASEcamelBack (dropping the k prefix requirement)

Infrastructure / CI

  • .github/workflows/build-nix-image.yml — New nix-based Dockerfile CI workflow
  • conan/global.conf — Added retry settings for Conan downloads
  • .pre-commit-config.yaml — Updated cspell exclude pattern
  • .github/scripts/rename/config.sh and docs.sh — Updated to reference the renamed constant
    kConfigLegacyName (was kCONFIG_LEGACY_NAME)

Bottom Line

The final state of the PR is clean — all constant values and runtime behavior are preserved relative
to the base branch. However, the intermediate history contained genuinely dangerous bugs (the wrong
ConsequencesFactoryType values would have misclassified XChain transactions in the queue), and the
diff bundles several unrelated changes that arrived via develop merges, making it harder to review
in isolation.

@dangell7

Copy link
Copy Markdown
Contributor

High Level Overview of Change

In #6571 we merged clang-tidy's readability-identifier-naming check but used kALL_CAPS for statics and global constants. This style did not receive too much love and kCamelCase is here to replace it.

Other than the renames this PR also reorders 'static constexpr Type' and adds static to missing constexpr constants that can be made static.

API Impact

No impact.

High Level Overview of Change

In #6571 we merged clang-tidy's readability-identifier-naming check but used kALL_CAPS for statics and global constants. This style did not receive too much love and kCamelCase is here to replace it.

Other than the renames this PR also reorders 'static constexpr Type' and adds static to missing constexpr constants that can be made static.

API Impact

No impact.

Are we going back to Hungarian notation?

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.

6 participants