History log of /openbmc/docs/style/cpp/.clang-tidy (Results 1 – 7 of 7)
Revision Date Author Comments
# ba560cc3 13-Aug-2025 Ed Tanous <ed@tanous.net>

Remove size checks from .clang-tidy

These two checks around cognative complexity and function size were put
in this file aspirationally. To date no repositories have been able to
successfully enabl

Remove size checks from .clang-tidy

These two checks around cognative complexity and function size were put
in this file aspirationally. To date no repositories have been able to
successfully enable these two checks. This maintainer has personally
tried and we'd either have to bypass so many functions that the check
became more cumbersome to maintain, or we'd have to raise the limits to
where they were not useful. While I'm hopeful that these checks could
be enabled in the future, they don't match the reality of where tidy is
at.

As a side note, one thing asio-based repos suffer from is overly large
inline lambdas. cognative complexity and length checks do not take
those into account when measuring line count, and in some cases seem to
actively disable the checks, so even if we were able to enable these
checks, as implemented in clang they're not useful in a lot of scenarios
today.

To ensure that the content is not lost, these two checks are moved into
documentation (tidy-desired.md) that can track the desire to enable
these checks, even if we're not able to do so today.

Change-Id: Ic86066f21f0c01a4d7b27a02829564f693f8b00b
Signed-off-by: Ed Tanous <etanous@nvidia.com>

show more ...


# 04408ef5 23-May-2025 Patrick Williams <patrick@stwcx.xyz>

clang-tidy: adjust format to match config-clang-tidy tool

The tool introduced by Ib338f7dcbc7f1049122399e0b616f77ec5eb7dc2
creates clang-tidy files in a format / layout that is different
stylistical

clang-tidy: adjust format to match config-clang-tidy tool

The tool introduced by Ib338f7dcbc7f1049122399e0b616f77ec5eb7dc2
creates clang-tidy files in a format / layout that is different
stylistically from the one here. Adjust the format here to match
the style generated by that tool.

Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I1989fe7e914ee7b1fab8bfb1a083c59f62c38bed

show more ...


# 12cf111b 21-Mar-2025 Jayanth Othayoth <ojayanth@gmail.com>

clang-tidy: Add modernize-use-nullptr

Adding the modernize-use-nullptr check in clang-tidy provides several
benefits like
- Consistency with Modern C++ Standards
- Reduced Ambiguity
- Improved Co

clang-tidy: Add modernize-use-nullptr

Adding the modernize-use-nullptr check in clang-tidy provides several
benefits like
- Consistency with Modern C++ Standards
- Reduced Ambiguity
- Improved Code Safety

Change-Id: I9938fd024215338d87eec313e86111844c2dd91a
Signed-off-by: Jayanth Othayoth <ojayanth@gmail.com>

show more ...


# 278f19d4 13-Mar-2025 Alexander Hansen <alexander.hansen@9elements.com>

.clang-tidy: fix typo

Should be 'HeaderFilterRegex' [1]

References:
[1] https://clang.llvm.org/extra/clang-tidy/

Change-Id: I3bdf2616d6f5dad98fe43cc799c4bb69f1f2e867
Signed-off-by: Alexander Hanse

.clang-tidy: fix typo

Should be 'HeaderFilterRegex' [1]

References:
[1] https://clang.llvm.org/extra/clang-tidy/

Change-Id: I3bdf2616d6f5dad98fe43cc799c4bb69f1f2e867
Signed-off-by: Alexander Hansen <alexander.hansen@9elements.com>

show more ...


# e6185cf8 07-Feb-2025 Patrick Williams <patrick@stwcx.xyz>

clang-tidy: add default settings for headers

Add two settings to the default clang-tidy:

1. Set WarningsAsErrors - for strictness.
2. Set HeaderFilterRegex - to assist with meson subproject builds.

clang-tidy: add default settings for headers

Add two settings to the default clang-tidy:

1. Set WarningsAsErrors - for strictness.
2. Set HeaderFilterRegex - to assist with meson subproject builds.

Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I69cd2d5e7c816bc9fb433a810bc9f997e7721834

show more ...


# 90629cc4 06-Feb-2025 Lei YU <yulei.sh@bytedance.com>

clang-tidy: Add bugprone-unchecked-optional-access

Starting from meson 1.4.0[1], `-D_GLIBCXX_ASSERTIONS=1` is set if
`ndebug` is disabled.

This unveals a bug in the OpenBMC code, that it uses the s

clang-tidy: Add bugprone-unchecked-optional-access

Starting from meson 1.4.0[1], `-D_GLIBCXX_ASSERTIONS=1` is set if
`ndebug` is disabled.

This unveals a bug in the OpenBMC code, that it uses the std::optional
value without checking if it's empty.
It is undefined behavior, and without `-D_GLIBCXX_ASSERTIONS=1`, the
code runs OK to access the "default" value; And it gets assertion and
crash if `-D_GLIBCXX_ASSERTIONS=1` is set.

It is possible to use clang-tidy's `bugprone-unchecked-optional-access`
option to detect such issue in the build time.

[1]: https://mesonbuild.com/Release-notes-for-1-4-0.html#ndebug-setting-now-controls-c-stdlib-assertions

Signed-off-by: Lei YU <yulei.sh@bytedance.com>
Change-Id: I32f64b02b9593a6af6c26af66c386689717336dd

show more ...


# 5ae48158 28-Sep-2023 Alexander Hansen <alexander.hansen@9elements.com>

clang-tidy: propose a base .clang-tidy

When there is a specific recommendation, it is taken from Cpp Core
guidelines [1] or clang-tidy defaults.

- readability-function-size.LineThreshold
was chos

clang-tidy: propose a base .clang-tidy

When there is a specific recommendation, it is taken from Cpp Core
guidelines [1] or clang-tidy defaults.

- readability-function-size.LineThreshold
was chosen to support
[ F.3 Keep functions short and simple ]

They recommend 60 lines to flag functions which would not fit on a
screen.

- readability-function-size.ParameterThreshold
was chosen to support
[ F.2: A function should perform a single logical operation ]

They recommend to be suspicious of functions with 7 or more
parameters.

- readability-function-cognitive-complexity.Threshold
was chosen to support
[ F.3: Keep functions short and simple ]

They recommend a cyclomatic complexity of 10 or less.
However, cyclomatic complexity is not implemented in clang-tidy,
therefore going with the clang-tidy default.

What is the goal of this change?

- making it easier for people to read the code.

- making it easier to perform refactorings without breaking stuff

- making it easier to review changes

Who will be responsible for making the required changes?

- Everyone who is interested. The plan is to atleast get some of the
most important pieces into a more readable state. Examples are
dbus-sensors, entity-manager, x86-power-control.

- The plan is to enable some of these checks as errors once a repo
comes into compliance. After that, contributors will be responsible
to ensure their changes meet these checks.

Tradeoffs:

- There might be more code overall, as functions will be smaller.
- People might be required to do another (refactoring) iteration on
their changes if some of these checks become hard errors.
- Refactoring code to meet these checks might introduce bugs.

[1] https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines

Change-Id: Icbdd55d2f672037a57d8ed08d52b20427e9e1e4f
Signed-off-by: Alexander Hansen <alexander.hansen@9elements.com>

show more ...