Skip to content

chore: Fix most possible clang-tidy autofixes#6422

Open
godexsoft wants to merge 19 commits intoXRPLF:developfrom
godexsoft:chore/clang-tidy-checks-autofixes
Open

chore: Fix most possible clang-tidy autofixes#6422
godexsoft wants to merge 19 commits intoXRPLF:developfrom
godexsoft:chore/clang-tidy-checks-autofixes

Conversation

@godexsoft
Copy link
Collaborator

High Level Overview of Change

This PR enabled all checks in clang-tidy (other than include cleaner and identifier-naming) and ran -fix on all of them. Then i fixed all compilation errors, sometimes bringing back old code.
Note that the clang-tidy config is not modified in this PR. The idea is to be a bit more prepared for the upcoming one-by-one fixes of each clang-tidy check.

Context of Change

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactor (non-breaking change that only restructures code)
  • Performance (increase or change in throughput and/or latency)
  • Tests (you added tests for code that already exists, or your new feature included in this PR)
  • Documentation update
  • Chore (no impact to binary, e.g. .gitignore, formatting, dropping support for older tooling)
  • Release

API Impact

  • Public API: New feature (new methods and/or new fields)
  • Public API: Breaking change (in general, breaking changes should only impact the next api_version)
  • libxrpl change (any change that may affect libxrpl or dependents of libxrpl)
  • Peer protocol change (must be backward compatible or bump the peer protocol version)

godexsoft and others added 10 commits February 24, 2026 14:53
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Ayaz Salikhov <mathbunnyru@users.noreply.github.com>
Co-authored-by: Ayaz Salikhov <mathbunnyru@users.noreply.github.com>
Co-authored-by: Ayaz Salikhov <mathbunnyru@users.noreply.github.com>
@godexsoft godexsoft added the DraftRunCI Normally CI does not run on draft PRs. This opts in. label Feb 25, 2026
@godexsoft godexsoft force-pushed the chore/clang-tidy-checks-autofixes branch from 9f0a5bd to c6ff6b6 Compare February 26, 2026 18:58
@codecov
Copy link

codecov bot commented Feb 27, 2026

Codecov Report

❌ Patch coverage is 90.73924% with 114 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.7%. Comparing base (2e595b6) to head (4d7d753).
⚠️ Report is 1 commits behind head on develop.

Files with missing lines Patch % Lines
src/libxrpl/beast/insight/StatsDCollector.cpp 0.0% 16 Missing ⚠️
src/libxrpl/shamap/SHAMapDelta.cpp 59.0% 16 Missing ⚠️
src/libxrpl/shamap/SHAMapSync.cpp 75.5% 12 Missing ⚠️
src/libxrpl/basics/Archive.cpp 0.0% 7 Missing ⚠️
src/libxrpl/json/json_reader.cpp 79.4% 7 Missing ⚠️
src/libxrpl/nodestore/backend/RocksDBFactory.cpp 54.5% 5 Missing ⚠️
src/libxrpl/rdb/SociDB.cpp 37.5% 5 Missing ⚠️
src/libxrpl/nodestore/DatabaseRotatingImp.cpp 55.6% 4 Missing ⚠️
src/libxrpl/basics/Log.cpp 66.7% 3 Missing ⚠️
src/libxrpl/beast/utility/beast_PropertyStream.cpp 81.2% 3 Missing ⚠️
... and 24 more
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##           develop   #6422     +/-   ##
=========================================
- Coverage     79.8%   79.7%   -0.1%     
=========================================
  Files          848     848             
  Lines        67757   67948    +191     
  Branches      7554    7561      +7     
=========================================
+ Hits         54073   54163     +90     
- Misses       13684   13785    +101     
Files with missing lines Coverage Δ
include/xrpl/basics/BasicConfig.h 89.7% <100.0%> (ø)
include/xrpl/basics/Log.h 71.4% <ø> (ø)
include/xrpl/beast/net/IPEndpoint.h 94.4% <ø> (ø)
include/xrpl/beast/utility/PropertyStream.h 11.5% <ø> (ø)
include/xrpl/core/JobQueue.h 100.0% <ø> (ø)
include/xrpl/core/detail/Workers.h 100.0% <ø> (ø)
include/xrpl/json/json_value.h 98.5% <ø> (ø)
include/xrpl/json/json_writer.h 100.0% <ø> (ø)
include/xrpl/ledger/OpenView.h 100.0% <ø> (ø)
include/xrpl/protocol/PublicKey.h 80.5% <ø> (ø)
... and 193 more

... and 111 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 marked this pull request as ready for review February 27, 2026 16:48
Copilot AI review requested due to automatic review settings February 27, 2026 16:48
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot wasn't able to review this pull request because it exceeds the maximum number of files (300). Try reducing the number of changed files and requesting a review from Copilot again.

@godexsoft godexsoft removed the DraftRunCI Normally CI does not run on draft PRs. This opts in. label Feb 27, 2026
Copy link
Collaborator

@kuznetsss kuznetsss left a comment

Choose a reason for hiding this comment

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

So far got to the src/libxrpl/beast/net/IPAddressConversion.cpp, will continue later 😄
A few questions:

class AsyncObject
{
protected:
private:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it correct?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't see this code in my version anymore.. i think it's outdated.

{
}

protected:
Copy link
Collaborator

Choose a reason for hiding this comment

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

And this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Same.

compare(SemanticVersion const& lhs, SemanticVersion const& rhs)
{
if (lhs.majorVersion > rhs.majorVersion)
{
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like curly brackets are not needed here anymore, but it's ok to leave tham

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't have them already in my code.

}

~GroupsImp() = default;
~GroupsImp() override = default;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need to define this destructor at all?

private:
NullHookImpl&
operator=(NullHookImpl const&);
operator=(NullHookImpl const&) = delete;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Then it doesn't need to be private

private:
StatsDCounterImpl&
operator=(StatsDCounterImpl const&);
operator=(StatsDCounterImpl const&) = delete;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same, doesn't need to be private

Copy link
Collaborator

@bthomee bthomee left a comment

Choose a reason for hiding this comment

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

I think I only got through 10% but your responses to my comments will help me review the rest better.

@@ -169,7 +169,7 @@ struct AttestationCreateAccount : AttestationBase
Buffer signature_,
AccountID const& sendingAccount_,
STAmount const& sendingAmount_,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't this STAmount const& sendingAmount_ also be changed like rewardAmount_?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't understand the question. Renaming variables is not something clang-tidy would do by itself :)

Comment on lines 22 to 23
uint256 m_dir;
uint256 m_index;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't these bool and uint256 variables be initialized similarly? e.g. uint256 m_index{};

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Since uint256 is a user type (vector) so it does not need explicit initialization, unlike say an int would. I think clang-tidy only adds those when otherwise you would have something unintialized.

Comment on lines +55 to +56
int result = 0;
struct archive_entry* entry = nullptr;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Here and elsewhere, given the modern C++ convention of uniform initialization, wouldn't it be better to have something like the following instead of using copy initialization?

int result{};
struct archive_entry* entry{}

or if you want to be explicit:

int result{0};
struct archive_entry* entry{nullptr}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's the same from language perspective (no copy). I suspect clang-tidy prefers to use curlies for members but assignment for normal variables. I'm not aware if we can control this. Worth checking when we are working on the relevant clang-tidy check.

auto const inverse = base64::get_inverse();

while (len-- && *in != '=')
while (((len--) != 0u) && *in != '=')
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
while (((len--) != 0u) && *in != '=')
while ((len--) != 0u && *in != '=')

Unnecessary extra parentheses.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

clang-tidy isolates the refactored condition, hence the extra parens. We can use https://clang.llvm.org/extra/clang-tidy/checks/readability/redundant-parentheses.html to clean up later on i think. Don't think we should do this manually.


// Quadratic least squares curve fit of f^(1/d) in the range [0, 1]
auto const D = ((6 * di + 11) * di + 6) * di + 1;
auto const D = (((6 * di + 11) * di + 6) * di) + 1;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Were these parentheses really added by clang-tidy auto-fixes? They are totally unnecessary from a functional point of view.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I believe this is to do with arithmetic operators precedence. There was a clang-tidy check that makes sure there are parens around math where you have to know/guess what comes first. Parens make it obvious. Yes, no functional difference - it's a refactoring 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants