Skip to content

Fix a number of clang-tidy detected defects#22416

Open
jblomer wants to merge 37 commits into
root-project:masterfrom
jblomer:tidy
Open

Fix a number of clang-tidy detected defects#22416
jblomer wants to merge 37 commits into
root-project:masterfrom
jblomer:tidy

Conversation

@jblomer
Copy link
Copy Markdown
Contributor

@jblomer jblomer commented May 28, 2026

A test run of clang-tidy on the RNTuple code with the following checks

Checks: 'bugprone-*,-bugprone-assignment-in-if-condition,-bugprone-branch-clone,-bugprone-derived-method-shadowing-base-method,-bugprone-easily-swappable-parameters,-bugprone-implicit-widening-of-multiplication-result,-bugprone-incorrect-enable-if,-bugprone-macro-parentheses,-bugprone-multi-level-implicit-pointer-conversion,-bugprone-narrowing-conversions,-bugprone-not-null-terminated-result,-bugprone-random-generator-seed,-bugprone-reserved-identifier,-bugprone-signed-char-misuse,-bugprone-std-namespace-modification,-bugprone-switch-missing-default-case,-bugprone-throwing-static-initialization,-bugprone-too-small-loop-variable,-bugprone-unchecked-optional-access,-bugprone-unhandled-self-assignment,-bugprone-unused-return-value,-bugprone-virtual-near-miss,cppcoreguidelines-virtual-class-destructor,misc-*,-misc-non-private-member-variables-in-classes,-misc-include-cleaner,-misc-misplaced-const,-misc-multiple-inheritance,-misc-no-recursion,misc-non-copyable-objects,-misc-non-private-member-variables-in-classes,-misc-predictable-rand,-misc-unconventional-assign-operator,-misc-use-anonymous-namespace,performance-*,-performance-enum-size,-performance-inefficient-string-concatenation,-performance-no-int-to-ptr,-performance-noexcept-swap,readability-duplicate-include,readability-delete-null-pointer,readability-misleading-indentation,readability-redundant-control-flow,readability-redundant-declaration,readability-redundant-function-ptr-dereference,readability-reference-to-constructed-temporary'

@jblomer jblomer self-assigned this May 28, 2026
@jblomer jblomer requested review from dpiparo and pcanal as code owners May 28, 2026 12:14
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 28, 2026

Test Results

    21 files      21 suites   3d 11h 4m 24s ⏱️
 3 864 tests  3 566 ✅   0 💤 298 ❌
73 365 runs  72 513 ✅ 259 💤 593 ❌

For more details on these failures, see this check.

Results for commit 0aaf399.

♻️ This comment has been updated with latest results.

jblomer added 25 commits June 2, 2026 13:45
With commit c5ee8b5 (enable unique_ptr
support for nested STL collections), the method
TClassEdit::GetUniquePtrType() became obsolete.
Copy link
Copy Markdown
Member

@dpiparo dpiparo left a comment

Choose a reason for hiding this comment

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

Thanks for these changes! Would it be useful to expand this kind of campaigns to other portions of the codebase, e.g. roofit or RDF, or explore other checks?

{
return 0 == name.compare(0, 17, "std::__pair_base<") || 0 == name.compare(0, 12, "__pair_base<");
}
inline std::string GetUniquePtrType(std::string_view name)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

TClassEdit is a public interface and thus this 'could' be used outside of ROOT. Should we deprecated it instead of removing it?

Copy link
Copy Markdown
Member

@pcanal pcanal left a comment

Choose a reason for hiding this comment

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

LGTM.

@ferdymercury
Copy link
Copy Markdown
Collaborator

Thanks for this, it's great!

Thanks for these changes! Would it be useful to expand this kind of campaigns to other portions of the codebase, e.g. roofit or RDF, or explore other checks?

Yes. Maybe even sth like:
https://github.com/HorstBaerbel/action-clang-tidy
or
https://github.com/marketplace/actions/clang-tidy-review
https://github.com/marketplace/actions/c-c-linter

@hahnjo hahnjo self-requested a review June 4, 2026 11:32
RException(const RException &other) noexcept : std::runtime_error(other)
{
try {
fError = other.fError;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This could throw because of std::string and std::vector in RError? Maybe add a comment, and a mention in the commit message why exceptions should be nothrow copy constructible.

Also, I think implementing the copy constructor deletes the move constructor and assignment operators, so they must be implemented explicitly (rule of five).

@@ -147,9 +147,9 @@ public:
static RError ForwardError(RResultBase &&result, RError::RLocation &&sourceLocation)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should these methods also take const ref?

{
// Avoid frequent reallocations as we move up the call stack
fStackTrace.reserve(32);
AddFrame(std::move(sourceLocation));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hm, is this moving a const ref? 🤔

@jblomer
Copy link
Copy Markdown
Contributor Author

jblomer commented Jun 5, 2026

Thanks for this, it's great!

Thanks for these changes! Would it be useful to expand this kind of campaigns to other portions of the codebase, e.g. roofit or RDF, or explore other checks?

Yes. Maybe even sth like: https://github.com/HorstBaerbel/action-clang-tidy or https://github.com/marketplace/actions/clang-tidy-review https://github.com/marketplace/actions/c-c-linter

Maybe. I think the next step would be a regular clang-tidy check for RNTuple as part of the CI. Looking into it.

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