From 8fadbdae37bbc4c1538f4d8a85aecb6b5aef1bdf Mon Sep 17 00:00:00 2001 From: Jorijn van der Graaf Date: Sat, 31 Oct 2026 02:58:41 +0100 Subject: [PATCH] refactor(lint): check this tree with the lite house rules Crafter.LintRules now has AddLiteRules: the house rules without the ones that only decide layout, whitespace and naming. This tree switches to it. The full set's naming rule now wants camelCase statics and constants, which this tree spells PascalCase throughout, so `lint` with it reported 49 findings on code that follows the documented convention; with the lite set `lint` and `format --check` are clean. AGENTS.md described the 17 rules as the enforced style and told contributors to let `format` restyle their code. It now says which 8 rules `lint` enforces, that `format` only rewrites string concatenation and builtin integer types, and lists layout and naming as conventions kept by hand. Co-Authored-By: Claude Opus 5.5 --- AGENTS.md | 11 +++++++---- project.cpp | 12 ++++++++---- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 6bdde3b..ffd0057 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -95,14 +95,17 @@ Cross-target runs use `test --target=` with `--runner=local` or `--runne ## Code style -Style is enforced by the 17 rules in [Crafter.LintRules](https://forgejo.catcrafts.net/Catcrafts/Crafter.LintRules), which `project.cpp` pulls in through `#pragma crafter dependency` and applies with `crafter-build format` and `lint`. Most rules are transforms, so run `format` and let it restyle rather than hand-formatting. In short: +`project.cpp` pulls in [Crafter.LintRules](https://forgejo.catcrafts.net/Catcrafts/Crafter.LintRules) through `#pragma crafter dependency` and applies its lite set, `LintRules::AddLiteRules`: the 8 rules that ask for different code, without the ones that only decide layout, whitespace and naming. `lint` reports all 8; `format` applies the two transforms among them, `format-concat` and `fixed-width-types`, and leaves everything else as written. Enforced: - The first three lines of every source: `// SPDX-License-Identifier: LGPL-3.0-only`, `// SPDX-FileCopyrightText: Copyright (C) 2026 Catcrafts®`, blank. Examples use MIT. +- `enum class` only. `std::println` instead of iostream. `std::format` instead of string concatenation. `std::int32_t` and friends instead of `int` or `long` (exempt: `main`, `argc`/`argv`, `extern "C"` and foreign API signatures). No `char*` outside C interop. +- `const` on scalar locals that are never written; `constexpr` on constants with constant initialisers. + +Not checked, so match the surrounding code: + - Four-space indentation, no tabs, no trailing whitespace, final newline. - `PascalCase` for types, functions, statics and constants; `camelCase` for variables; a trailing `_` is allowed. -- `enum class` only. `std::println` instead of iostream. `std::format` instead of string concatenation. `std::int32_t` and friends instead of `int` or `long` (exempt: `main`, `argc`/`argv`, `extern "C"` and foreign API signatures). No `char*` outside C interop. -- One declaration per statement. K&R braces. `if (x) return;` on one line when it fits. The formatter joins wrapped statements that fit on one line, so do not hand-wrap short ones. `if (` and `for (` with a space; no space before a call's `(`. -- `const` on scalar locals that are never written; `constexpr` on constants with constant initialisers. +- One declaration per statement. K&R braces. `if (x) return;` on one line when it fits, and no hand-wrapping of a statement that fits on one line. `if (` and `for (` with a space; no space before a call's `(`. Suppress one finding with `// lint-disable-next-line ` or a whole file with `// lint-disable-file `. Both are rare in this tree and need a reason. diff --git a/project.cpp b/project.cpp index 85b72f2..4ea9679 100644 --- a/project.cpp +++ b/project.cpp @@ -288,10 +288,14 @@ extern "C" Configuration CrafterBuildProject(std::span a cfg.AddTest("Lint").Dependencies({ CrafterBuildLib.get() }); } - // Dogfood: the house-style rules, imported from their own repo through - // the pragma above. Report rules gate `crafter-build lint`; transform - // rules also auto-fix under `crafter-build format`. - LintRules::AddRules(cfg); + // Dogfood: the lite house rules, imported from their own repo through + // the pragma above. Lite is the house rules without the ones that only + // decide layout, whitespace and naming, which this tree keeps by hand: + // the full set's naming rule, for one, wants camelCase where this tree + // spells its statics and constants PascalCase. Report rules gate + // `crafter-build lint`; the two transforms also auto-fix under + // `crafter-build format`. + LintRules::AddLiteRules(cfg); // See the top of this file. cfg.scripts.push_back({"flatpak", BuildFlatpak});