mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-09-11 21:20:39 +02:00
doc: Regroup clang-tidy rules
* Remove the explicit modernize-use-nullptr rule mention, which has not been needed for years. * Encourage devs to refer to the upstream clang-tidy rules documentation. * Move NOLINTNEXTLINE(misc-no-recursion) into a subsection under the new clang-tidy section.
This commit is contained in:
@@ -55,7 +55,6 @@ code.
|
||||
|
||||
- **Miscellaneous**
|
||||
- `++i` is preferred over `i++`.
|
||||
- `nullptr` is preferred over `NULL` or `(void*)0`.
|
||||
- `static_assert` is preferred over `assert` where possible. Generally; compile-time checking is preferred over run-time checking.
|
||||
- Use a named cast or functional cast, not a C-Style cast. When casting
|
||||
between integer types, use functional casts such as `int(x)` or `int{x}`
|
||||
@@ -63,8 +62,6 @@ code.
|
||||
Use `reinterpret_cast` and `const_cast` as appropriate.
|
||||
- Prefer [`list initialization ({})`](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#res-list) where possible.
|
||||
For example `int x{0};` instead of `int x = 0;` or `int x(0);`
|
||||
- Recursion is checked by clang-tidy and thus must be made explicit. Use
|
||||
`NOLINTNEXTLINE(misc-no-recursion)` to suppress the check.
|
||||
|
||||
For function calls a namespace should be specified explicitly, unless such functions have been declared within it.
|
||||
Otherwise, [argument-dependent lookup](https://en.cppreference.com/w/cpp/language/adl), also known as ADL, could be
|
||||
@@ -140,7 +137,18 @@ public:
|
||||
non-optional in-out and output parameters should usually be references, as
|
||||
they cannot be null.
|
||||
|
||||
### Coding Style (C++ named arguments)
|
||||
### Coding Style (clang-tidy rules)
|
||||
|
||||
The clang-tidy tool is used to check some rules. Please refer to the [upstream
|
||||
documentation](https://clang.llvm.org/extra/clang-tidy/checks/list.html) about
|
||||
the details and rationale for each rule.
|
||||
|
||||
#### C++ Recursive Functions
|
||||
|
||||
Recursion is checked by clang-tidy and thus must be made explicit. Use
|
||||
`NOLINTNEXTLINE(misc-no-recursion)` to suppress the check.
|
||||
|
||||
#### C++ named arguments
|
||||
|
||||
When passing named arguments, use a format that clang-tidy understands. The
|
||||
argument names can otherwise not be verified by clang-tidy.
|
||||
@@ -156,7 +164,7 @@ int main()
|
||||
}
|
||||
```
|
||||
|
||||
### Running clang-tidy
|
||||
#### Running clang-tidy
|
||||
|
||||
To run clang-tidy on Ubuntu/Debian, install the dependencies:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user