lint rules lite
This commit is contained in:
parent
e906f797da
commit
42a27016e3
4 changed files with 213 additions and 111 deletions
40
README.md
40
README.md
|
|
@ -21,6 +21,8 @@ extern "C" Configuration CrafterBuildProject(std::span<const std::string_view> a
|
|||
}
|
||||
```
|
||||
|
||||
For a project that keeps its own formatting and naming, call `LintRules::AddLiteRules(cfg)` instead. It registers only the rules marked lite below, leaving layout, whitespace and naming alone; under `format` it still applies `format-concat` and `fixed-width-types`, and nothing else.
|
||||
|
||||
Then `crafter-build lint` reports, `crafter-build format` rewrites, and `crafter-build format --check` gates CI. Pin a revision for reproducible builds:
|
||||
|
||||
```cpp
|
||||
|
|
@ -31,22 +33,22 @@ Suppress a finding with `// lint-disable-next-line <rule>` or a whole file with
|
|||
|
||||
## Rules
|
||||
|
||||
| Rule | Kind | What it wants |
|
||||
| --- | --- | --- |
|
||||
| `spdx-header` | report | `// SPDX-License-Identifier:` on line 1, `// SPDX-FileCopyrightText:` on line 2, blank line 3 |
|
||||
| `no-tabs` | report | spaces |
|
||||
| `naming` | report, AST | PascalCase types and functions; camelCase variables, including statics and constants |
|
||||
| `enum-class` | report | `enum class`, never a plain `enum` |
|
||||
| `no-iostream-print` | report | `std::println` instead of `std::cout`/`std::cerr` streaming |
|
||||
| `no-char-pointer` | report, AST | `std::string` / `std::string_view` over `char*` outside C interop |
|
||||
| `const-local` | report, AST | `const` on a scalar local that is never written |
|
||||
| `constexpr-constant` | report, AST | `constexpr` on a constant with a constant initialiser |
|
||||
| `format-concat` | transform | `std::format` instead of `+` with string literals |
|
||||
| `fixed-width-types` | transform, AST | `std::int32_t` and friends instead of `int`, `long`, … |
|
||||
| `single-declaration` | transform, AST | one declaration per statement |
|
||||
| `brace-style` | transform | K&R braces |
|
||||
| `if-single-line` | transform | `if (x) return;` on one line when it fits |
|
||||
| `wrap-join` | transform | join wrapped statements that fit on one line |
|
||||
| `paren-spacing` | transform | `if (` and `for (`, no space before a call's `(` |
|
||||
| `trim-trailing-ws` | transform | no trailing whitespace |
|
||||
| `final-newline` | transform | files end with a newline |
|
||||
| Rule | Kind | Lite | What it wants |
|
||||
| --- | --- | --- | --- |
|
||||
| `spdx-header` | report | ✓ | `// SPDX-License-Identifier:` on line 1, `// SPDX-FileCopyrightText:` on line 2, blank line 3 |
|
||||
| `no-tabs` | report | | spaces |
|
||||
| `naming` | report, AST | | PascalCase types and functions; camelCase variables, including statics and constants |
|
||||
| `enum-class` | report | ✓ | `enum class`, never a plain `enum` |
|
||||
| `no-iostream-print` | report | ✓ | `std::println` instead of `std::cout`/`std::cerr` streaming |
|
||||
| `no-char-pointer` | report, AST | ✓ | `std::string` / `std::string_view` over `char*` outside C interop |
|
||||
| `const-local` | report, AST | ✓ | `const` on a scalar local that is never written |
|
||||
| `constexpr-constant` | report, AST | ✓ | `constexpr` on a constant with a constant initialiser |
|
||||
| `format-concat` | transform | ✓ | `std::format` instead of `+` with string literals |
|
||||
| `fixed-width-types` | transform, AST | ✓ | `std::int32_t` and friends instead of `int`, `long`, … |
|
||||
| `single-declaration` | transform, AST | | one declaration per statement |
|
||||
| `brace-style` | transform | | K&R braces |
|
||||
| `if-single-line` | transform | | `if (x) return;` on one line when it fits |
|
||||
| `wrap-join` | transform | | join wrapped statements that fit on one line |
|
||||
| `paren-spacing` | transform | | `if (` and `for (`, no space before a call's `(` |
|
||||
| `trim-trailing-ws` | transform | | no trailing whitespace |
|
||||
| `final-newline` | transform | | files end with a newline |
|
||||
|
|
|
|||
Loading…
Reference in a new issue