chore: Fix most possible clang-tidy autofixes#6422
chore: Fix most possible clang-tidy autofixes#6422godexsoft wants to merge 19 commits intoXRPLF:developfrom
Conversation
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>
9f0a5bd to
c6ff6b6
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ 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
🚀 New features to boost your workflow:
|
kuznetsss
left a comment
There was a problem hiding this comment.
So far got to the src/libxrpl/beast/net/IPAddressConversion.cpp, will continue later 😄
A few questions:
| class AsyncObject | ||
| { | ||
| protected: | ||
| private: |
There was a problem hiding this comment.
I don't see this code in my version anymore.. i think it's outdated.
| { | ||
| } | ||
|
|
||
| protected: |
| compare(SemanticVersion const& lhs, SemanticVersion const& rhs) | ||
| { | ||
| if (lhs.majorVersion > rhs.majorVersion) | ||
| { |
There was a problem hiding this comment.
Looks like curly brackets are not needed here anymore, but it's ok to leave tham
There was a problem hiding this comment.
I don't have them already in my code.
| } | ||
|
|
||
| ~GroupsImp() = default; | ||
| ~GroupsImp() override = default; |
There was a problem hiding this comment.
Do we need to define this destructor at all?
| private: | ||
| NullHookImpl& | ||
| operator=(NullHookImpl const&); | ||
| operator=(NullHookImpl const&) = delete; |
There was a problem hiding this comment.
Then it doesn't need to be private
| private: | ||
| StatsDCounterImpl& | ||
| operator=(StatsDCounterImpl const&); | ||
| operator=(StatsDCounterImpl const&) = delete; |
There was a problem hiding this comment.
Same, doesn't need to be private
bthomee
left a comment
There was a problem hiding this comment.
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_, | |||
There was a problem hiding this comment.
Shouldn't this STAmount const& sendingAmount_ also be changed like rewardAmount_?
There was a problem hiding this comment.
I don't understand the question. Renaming variables is not something clang-tidy would do by itself :)
| uint256 m_dir; | ||
| uint256 m_index; |
There was a problem hiding this comment.
Shouldn't these bool and uint256 variables be initialized similarly? e.g. uint256 m_index{};
There was a problem hiding this comment.
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.
| int result = 0; | ||
| struct archive_entry* entry = nullptr; |
There was a problem hiding this comment.
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}
There was a problem hiding this comment.
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 != '=') |
There was a problem hiding this comment.
| while (((len--) != 0u) && *in != '=') | |
| while ((len--) != 0u && *in != '=') |
Unnecessary extra parentheses.
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Were these parentheses really added by clang-tidy auto-fixes? They are totally unnecessary from a functional point of view.
There was a problem hiding this comment.
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 👍
High Level Overview of Change
This PR enabled all checks in clang-tidy (other than include cleaner and identifier-naming) and ran
-fixon 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
.gitignore, formatting, dropping support for older tooling)API Impact
libxrplchange (any change that may affectlibxrplor dependents oflibxrpl)