History log of /openbmc/docs/style/cpp/.clang-tidy (Results 1 – 3 of 3)
Revision Date Author Comments
# 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 ...