2026-10-02 19:57:28 +02:00
# Crafter.LintRules
2026-10-02 20:42:21 +02:00
The Catcrafts house-style lint rules for [crafter-build ](https://forgejo.catcrafts.net/Catcrafts/Crafter.Build ) projects, packaged as one C++ module.
2026-10-02 19:57:28 +02:00
## Use
In a `project.cpp` :
```cpp
import std;
import Crafter.Build;
#pragma crafter dependency "https://forgejo.catcrafts.net/Catcrafts/Crafter.LintRules.git"
import Crafter.LintRules;
using namespace Crafter;
extern "C" Configuration CrafterBuildProject(std::span<const std::string_view> args) {
Configuration cfg;
// ...
LintRules::AddRules(cfg);
return cfg;
}
```
Then `crafter-build lint` reports, `crafter-build format` rewrites, and `crafter-build format --check` gates CI. Pin a revision for reproducible builds:
```cpp
#pragma crafter dependency "https://forgejo.catcrafts.net/Catcrafts/Crafter.LintRules.git" commit "<sha>"
```
Suppress a finding with `// lint-disable-next-line <rule>` or a whole file with `// lint-disable-file <rule>` .
## 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 |
2026-10-02 20:42:21 +02:00
| `naming` | report, AST | PascalCase types and functions; camelCase variables, including statics and constants |
2026-10-02 19:57:28 +02:00
| `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 |
2026-10-02 20:43:43 +02:00
| `final-newline` | transform | files end with a newline |