The linter rules all catcrafts projects use
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Jorijn van der Graaf e906f797da
fix: wire the HouseRules test only when this is the top-level project
crafter-build loads this project file as a `#pragma crafter dependency`
of its own project.cpp. The HouseRules test pulls crafter-build in via
GitProject so it can run the linter in-process, which from inside
crafter-build means loading crafter-build's project.cpp a second time,
which loads this file a second time, and the cycle guard throws. Every
crafter-build invocation that loads its project.cpp has failed since
the test was wired.

Guard the test with IsTopLevelProject(), which crafter-build exposes
for exactly this: it is false while a project file runs as somebody
else's dependency. Consumers never needed the test; only `crafter-build
test` run in this repository does.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-02 21:58:44 +02:00
interfaces changed rule 2026-10-02 20:42:21 +02:00
tests/HouseRules changed rule 2026-10-02 20:42:21 +02:00
.gitignore Initial import: the house-style lint rules as a crafter-build module 2026-10-02 20:03:24 +02:00
LICENSE Initial import: the house-style lint rules as a crafter-build module 2026-10-02 20:03:24 +02:00
LICENSE.GPL Initial import: the house-style lint rules as a crafter-build module 2026-10-02 20:03:24 +02:00
project.cpp fix: wire the HouseRules test only when this is the top-level project 2026-10-02 21:58:44 +02:00
README.md final new line 2026-10-02 20:43:43 +02:00

Crafter.LintRules

The Catcrafts house-style lint rules for crafter-build projects, packaged as one C++ module.

Use

In a project.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:

#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
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