Skip to content

Satisfy clang-tidy-21 - #171

Closed
christophfroehlich wants to merge 15 commits into
mainfrom
satisfy-clang-tidy-21
Closed

christophfroehlich wants to merge 15 commits into
mainfrom
satisfy-clang-tidy-21

Conversation

@christophfroehlich

Copy link
Copy Markdown
Collaborator

No description provided.

@christophfroehlich christophfroehlich linked an issue Jun 29, 2026 that may be closed by this pull request
Comment thread include/rsl/algorithm.hpp
Comment on lines +1 to +2
#ifndef RSL_ALGORITHM_HPP_
#define RSL_ALGORITHM_HPP_

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why are you replacing pragma once with define guards? Is this still a problem for someone in 2026?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

There’s a new-ish clang-tidy check in the portability-* family for removing #pragma once. We obviously don’t want to use that check.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I only use this for ROS packages and there the define include guards are de facto standard afaik? That's the only reason, I don't care at all, I just wanted to satisfy all the checks.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I would not say either is a de facto standard, although I do think #pragma once has been the more popular choice in the greater C++ community for years. It’s a lot nicer to read and write and lacks some of the common pitfalls of header guards, namely how you can accidentally give two headers the same guard name.

I just wanted to satisfy all the checks.

Many clang-tidy checks exist to enforce particular opinions. It’s a misconception that all clang-tidy checks will improve your code. We should only enable checks that improve our code or codify existing opinions we hold. I don’t think any of the new checks that got implicitly enabled are worth fixing. We should amend the .clang-tidy file to disable them.

@tylerjw
tylerjw requested a review from ChrisThrasher October 15, 2026 16:12
Comment thread include/rsl/monad.hpp

#include <tl/expected.hpp>

#if defined(__cpp_concepts) && (__cpp_concepts >= 201907L)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I’d much rather just upgrade the whole library to C++20 than conditionally use it. I don’t like this half measure.

Comment thread include/rsl/queue.hpp
*/
[[nodiscard]] auto size() const noexcept {
auto const lock = std::lock_guard(mutex_);
auto const lock = std::scoped_lock(mutex_);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is also a clang-tidy warning I have disabled recently. I don’t think scoped_lock is an improvement. It’s not worse either.

Comment thread src/random.cpp
namespace {

#if defined(__cpp_lib_math_constants) && (__cpp_lib_math_constants >= 201907L)
constexpr auto k_pi = std::numbers::pi_v<double>;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Either upgrade to C++20 or not. Let’s not try to flirt between both standards. This is not making the code any better.

Comment thread tests/queue.cpp
for (auto& consumer : consumers) consumer.join();

CHECK(queue.size() == thread_count * item_count - items_removed);
CHECK(queue.size() == (thread_count * item_count) - items_removed);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The clang-tidy check about adding parens for readability’s sake isn’t one I’m a fan of either. C++ operator precedence is well-defined. I’m fine depending on it.

@ChrisThrasher

Copy link
Copy Markdown
Collaborator

I don’t think any of these checks are worth addressing. Some are totally irrelevant, notably anything involving C++20 since to my knowledge this library still uses C++17. However, it should upgrade to C++20. There’s no good reason to avoid C++20 anymore these days (as long as you don’t touch named modules or header units).

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.

Fix clang-tidy errors

3 participants