# What checks what

> Every rule of the Guidelines and the tool that holds it — a check of clang-tidy, a gate of rmp test, clang-format or the compiler — with where it holds: the framework, its examples, a game; and every check the framework switches off, with the reason.

Source: https://omardev29.github.io/rmp-docs/guidelines/enforcement.html

A rule that only a document states lasts until the day somebody has not read the document. So each rule on these pages names the tool that refuses its mistake, and this page puts them in one table, with where each one holds: in the framework (its `include/`, `src/` and `tests/`), in its examples, and in a game made with `rmp new`. The build of this site holds the table to the framework's own configuration, so a check that is said to run runs.

## The tools

clang-tidy, which `rmp lint` runs

The checks of the framework's `.clang-tidy` over the sources of `src/`, `tests/` and `examples/`, and the headers they reach, with the flags each file is built with. Whole families run — `bugprone`, `clang-analyzer`, `performance`, `portability`, `misc`, `modernize`, `readability` — minus what is switched off below, and the style guide's checks are named one by one. Two of them are queries the framework writes itself, which clang-tidy runs only with `--experimental-custom-checks`, and `rmp lint` passes it.

`examples/.clang-tidy`

The same file for the examples, narrowed: it switches off the `modernize` and `readability` families, which push a more elaborate spelling of correct code at someone learning raylib, and takes back the ones that are rules of these pages. An example teaches the C++ a game should write.

What the tree still owes

clang-tidy's warnings that the framework has not yet paid are listed in `tools/lint_debt.txt`, a count per check and file. `rmp lint` fails on a warning the list does not owe and on a count that grew, and the list only shrinks. A new warning is fixed, or carries a `NOLINT` with its reason on the line.

The text gates, stages of `rmp test`

What clang-tidy cannot see, because it parses one branch of every `#if` or because no check of its says it: `tools/naming_check.sh` (rules R1 to R8, the `naming` stage), `tools/style_check.sh` (S1 to S9, `style`), `tools/ownership_check.sh` (O1 to O3, `ownership`), `tools/pointer_check.py`, which reads the public headers' declarations (`pointers`), and `tools/cppcheck_check.sh`, a second analyser over `src/rmp` (`cppcheck`).

`.clang-format`, which `rmp fmt` applies

The layout of the code. The framework's CI fails on a file it would change; in a game, `rmp fmt` formats and `rmp fmt check` refuses a file it would change, when the game runs them: its `rmp test` and its CI do not.

The compiler

Every target CMake builds from the framework's sources and a game's is compiled with `-Wall
-Wextra` under GCC and Clang: the desktop and the web, and not Android's or iOS's own projects. The framework's own checks build with `RMP_WERROR`, which makes a warning an error; a game's warnings stay warnings unless it asks for the same. Designated initialisers out of order are an error everywhere.

## Rule by rule

"Yes" in a column says the rule is checked there; what follows it says how far. A game gets `.clang-format` and the compiler's flags: `rmp lint` and the text gates are commands of the framework's own repository, and a game chooses its own checks.

| Rule | Checked by | Framework | Examples | A game |
|---|---|---|---|---|
| [Names spelled by kind](https://omardev29.github.io/rmp-docs/guidelines/naming.html): types, constants, functions and variables, private members, the eight hooks | `readability-identifier-naming` | yes | yes | no |
| [A local never hides a name around it](https://omardev29.github.io/rmp-docs/guidelines/naming.html) | `clang-diagnostic-shadow`, which is `-Wshadow` given to clang-tidy | yes | yes | no |
| [No `g_` name, no `kName`, no underscore touching a dot, no trailing underscore](https://omardev29.github.io/rmp-docs/guidelines/naming.html), in every branch | `tools/naming_check.sh` `R1` `R2` `R3` `R4` `R8` | yes | yes | no |
| [Every macro starts with `RMP_`](https://omardev29.github.io/rmp-docs/guidelines/macros.html#prefix) | `readability-identifier-naming`; `tools/naming_check.sh` `R5` in every branch | yes | yes | no |
| [No constant named like somebody else's macro](https://omardev29.github.io/rmp-docs/guidelines/macros.html#names) | `tools/naming_check.sh` `R6` | yes | yes | no |
| [No retired name](https://omardev29.github.io/rmp-docs/guidelines/macros.html#retired) | `tools/naming_check.sh` `R7` | yes | yes | no |
| [The layout](https://omardev29.github.io/rmp-docs/guidelines/formatting.html): 4 spaces, 90 columns, `char *p`, no alignment, includes in the order written | `.clang-format` | yes, in CI | yes, in CI | yes: `rmp fmt` formats and `rmp fmt check` refuses, when the game runs them |
| [`const` on every local that does not change](https://omardev29.github.io/rmp-docs/guidelines/const.html), and on what a pointer points to when nothing writes through it | `misc-const-correctness` | yes | yes | no |
| [`const` on a by-value parameter in the definition, never the declaration](https://omardev29.github.io/rmp-docs/guidelines/const.html) | `readability-avoid-const-params-in-decls`, the declaration's half | yes | no: the examples switch `readability` off | no |
| [A constant at namespace scope in a header is `inline constexpr`](https://omardev29.github.io/rmp-docs/guidelines/const.html) | `custom-rmp-header-constant` | yes | yes, in their own headers | no |
| [No raw pointer](https://omardev29.github.io/rmp-docs/guidelines/pointers-and-raii.html), outside the C libraries' boundary | `custom-rmp-raw-pointer` | yes, with what `tools/lint_debt.txt` owes | yes, with what `tools/lint_debt.txt` owes | no |
| [No raw pointer and no C string in a declaration a game can name](https://omardev29.github.io/rmp-docs/guidelines/pointers-and-raii.html) | `tools/pointer_check.py`, against `tools/pointer_ratchet.txt` | yes: `include/rmp/` | no | no |
| [Nothing owned by hand](https://omardev29.github.io/rmp-docs/guidelines/pointers-and-raii.html): no `new`, `delete`, `malloc` or `free` | `cppcoreguidelines-owning-memory`, `cppcoreguidelines-no-malloc`; `tools/ownership_check.sh` `O1` in `include/rmp/` and `src/rmp/` | yes | yes, the clang-tidy checks | no |
| [raylib's `Load*` and `Unload*` only in the files that own what they make](https://omardev29.github.io/rmp-docs/guidelines/pointers-and-raii.html) | `tools/ownership_check.sh` `O2` | yes: `include/rmp/` and `src/rmp/` | yes | no |
| [A `std::optional` is checked before it is read](https://omardev29.github.io/rmp-docs/guidelines/pointers-and-raii.html#optional) | `bugprone-unchecked-optional-access` | yes | yes | no |
| [A `std::string_view` never reaches a C function through `data()`](https://omardev29.github.io/rmp-docs/guidelines/strings.html) | `bugprone-suspicious-stringview-data-usage` | yes | yes | no |
| [`std::array`, not a C array](https://omardev29.github.io/rmp-docs/guidelines/modern-cpp.html#arrays) | `modernize-avoid-c-arrays` | yes | yes | no |
| [`static_cast`, never a C cast](https://omardev29.github.io/rmp-docs/guidelines/modern-cpp.html#casts) | `modernize-avoid-c-style-cast`; `tools/style_check.sh` `S1` in every branch | yes | yes | no |
| [`enum class`](https://omardev29.github.io/rmp-docs/guidelines/modern-cpp.html#enum-class) | `cppcoreguidelines-use-enum-class` | yes | yes | no |
| [`nullptr`, never `NULL` or `0`](https://omardev29.github.io/rmp-docs/guidelines/modern-cpp.html#nullptr) | `modernize-use-nullptr`; `tools/style_check.sh` `S2` in every branch | yes | yes | no |
| [No C variadic function](https://omardev29.github.io/rmp-docs/guidelines/modern-cpp.html#varargs) | `modernize-avoid-variadic-functions` | yes, but for the two behind the said-once warnings, each with its reason | yes | no |
| [`int`, and a fixed width when the size matters](https://omardev29.github.io/rmp-docs/guidelines/modern-cpp.html#integers) | `google-runtime-int` | yes | yes | no |
| [No `long double`](https://omardev29.github.io/rmp-docs/guidelines/modern-cpp.html#integers) | `google-runtime-float` | yes | yes | no |
| [A one-argument constructor is `explicit`](https://omardev29.github.io/rmp-docs/guidelines/modern-cpp.html#explicit) | `google-explicit-constructor` | yes, but for the API's deliberate conversions | yes | no |
| [A class that manages something says what its copies do](https://omardev29.github.io/rmp-docs/guidelines/modern-cpp.html#special-members) | `cppcoreguidelines-special-member-functions` | yes | yes | no |
| [`auto` where a cast already names the type](https://omardev29.github.io/rmp-docs/guidelines/modern-cpp.html#auto) | `modernize-use-auto` | yes | no: the examples switch `modernize` off | no |
| [`using`, not `typedef`](https://omardev29.github.io/rmp-docs/guidelines/modern-cpp.html#using) | `modernize-use-using` | yes | yes | no |
| [`std::numbers`, not a typed-in constant](https://omardev29.github.io/rmp-docs/guidelines/modern-cpp.html#numbers) | `modernize-use-std-numbers` | yes | yes | no |
| [No `using namespace`](https://omardev29.github.io/rmp-docs/guidelines/modern-cpp.html#using-namespace) | `google-build-using-namespace` | yes | yes | no |
| [No unnamed namespace in a header](https://omardev29.github.io/rmp-docs/guidelines/google.html#agreement) | `google-build-namespaces` | yes | yes | no |
| [No using-declaration at global scope in a header](https://omardev29.github.io/rmp-docs/guidelines/google.html#agreement) | `google-global-names-in-headers` | yes | yes | no |
| [No overloaded unary `&`](https://omardev29.github.io/rmp-docs/guidelines/google.html#agreement) | `google-runtime-operator` | yes | yes | no |
| [`std::make_pair` deduces its types](https://omardev29.github.io/rmp-docs/guidelines/google.html#agreement) | `google-build-explicit-make-pair` | yes | yes | no |
| [No default argument on a virtual function](https://omardev29.github.io/rmp-docs/guidelines/modern-cpp.html#virtual-defaults) | `google-default-arguments` | yes | yes | no |
| [`++i` where the old value is not read](https://omardev29.github.io/rmp-docs/guidelines/modern-cpp.html#increment) | `tools/style_check.sh` `S6` | yes | yes | no |
| [No user-defined literal](https://omardev29.github.io/rmp-docs/guidelines/modern-cpp.html#literals) | `tools/style_check.sh` `S5` | yes | yes | no |
| [Nothing newer than the oldest compiler a game is built with](https://omardev29.github.io/rmp-docs/guidelines/modern-cpp.html#floor) | `tools/style_check.sh` `S4` | yes, but not in `tests/`, which build only on CI's compilers | yes | no |
| No iostreams in the library: a file is read through C's `stdio` or raylib | `tools/style_check.sh` `S8`; one `std::ifstream` made every release a fifth bigger | yes: `src/rmp/` and `include/rmp/` | no | no |
| No `//` comment that ends in a backslash: it takes the next line with it | `tools/style_check.sh` `S9`; GCC warns about it, Clang and clang-tidy never do | yes | yes | no |
| cute_aseprite reads only what the framework walked first | `tools/ownership_check.sh` `O3`: its two loads only in `src/rmp/assets/animation.cpp` | yes | yes | no |
| [No `TODO`, `FIXME` or `XXX`](https://omardev29.github.io/rmp-docs/guidelines/google.html#todo) | `tools/style_check.sh` `S3` | yes | yes | no |
| [Designated initialisers in declaration order](https://omardev29.github.io/rmp-docs/guidelines/modern-cpp.html#designated) | `-Werror=reorder-init-list` under Clang; GCC and MSVC refuse them anyway | yes | yes | yes |
| [A macro only for what a function cannot do](https://omardev29.github.io/rmp-docs/guidelines/macros.html) | `cppcoreguidelines-macro-usage`, told the framework's own by name | yes | yes | no |
| No finding of a second analyser, and a reason beside every suppression | `tools/cppcheck_check.sh` | yes: `src/rmp/` | no | no |
| Warnings on the code we write | `-Wall` `-Wextra` | yes, as errors in the framework's checks | yes | yes, as warnings |

## Written down, not checked

Some rules have no tool that can tell the right way from the wrong one. They are questions a reviewer asks:

- `const` on a by-value parameter in a definition — clang-tidy does not look at parameters — and `constexpr`, `consteval` and `constinit` wherever they apply ([const](https://omardev29.github.io/rmp-docs/guidelines/const.html));
- a `std::array` given a size larger than its list, whose rest is filled with zeros ([Modern C++](https://omardev29.github.io/rmp-docs/guidelines/modern-cpp.html#arrays));
- an unsigned type only for bits, and `auto` beyond a cast ([Modern C++](https://omardev29.github.io/rmp-docs/guidelines/modern-cpp.html#integers));
- `#pragma once` at the top of a header, and `<filesystem>` in `src/rmp/app/app.cpp` and `src/rmp/save/save.cpp` only ([Google's guide](https://omardev29.github.io/rmp-docs/guidelines/google.html#deviations));
- everything Google's guide says that no check of these pages states.

## Switched off, and why

Each check the framework's `.clang-tidy` switches off fights a decision the framework has already made, and the file says which next to it. In the same words:

| Check | Why it is off |
|---|---|
| `bugprone-easily-swappable-parameters` | Every `(float x, float y)` in a 2D framework, which is all of them. |
| `bugprone-narrowing-conversions` | `float` and `int` mixing is what raylib's own API does; the static analyser catches the cases that lose data. |
| `misc-non-private-member-variables-in-classes` | The options structs and `rmp::Object` are public data by design ([Google's guide](https://omardev29.github.io/rmp-docs/guidelines/google.html#public-data)). |
| `misc-no-recursion` | The layout walk is a tree walk. |
| `misc-include-cleaner` | It wants an `#include` for every raylib symbol, and raylib is one header. |
| `misc-use-anonymous-namespace`, `misc-use-internal-linkage` | `static` at file scope is the deliberate spelling: `main.cpp` is the file a newcomer reads first, and it has a plain C twin among the examples, so the two keep the same shape. Google allows either. |
| `modernize-use-trailing-return-type` | `auto f() -> int` is not the style, nor Google's. |
| `modernize-use-nodiscard` | It would decorate the whole API for the few calls where it matters. |
| `modernize-macro-to-enum` | The values the `.toml` generates are macros on purpose: the C entry point reads them too ([Macros](https://omardev29.github.io/rmp-docs/guidelines/macros.html#when)). |
| `modernize-use-designated-initializers` | It suggests them inside the framework's implementation, where the field order is Clay's, not the framework's. |
| `portability-avoid-pragma-once` | `#pragma once` is the framework's decision, and every compiler it builds with supports it ([Google's guide](https://omardev29.github.io/rmp-docs/guidelines/google.html#pragma-once)). |
| `performance-enum-size` | Pinning an underlying type on a public enum is churn in the ABI for bytes nobody is short of. |
| `readability-redundant-member-init` | In an options struct every field shows its default, even where the default is what the type would give anyway, and one field that does not is worse. |
| `readability-use-std-min-max` | The explicit `if (dt > 0.1f)` clamps are written that way, with a comment saying why the bound is what it is. |
| `readability-use-concise-preprocessor-directives` | `#if defined(A) \|\| defined(B)` and `#if defined(A)` are written the same way on purpose. |
| `readability-identifier-length` | `dt`, `t` and `o` are the vocabulary. |
| `readability-magic-numbers` | It is a game, and a touch target is a number: 44. |
| `readability-braces-around-statements` | A guard on one line is the style, and `.clang-format` is set to keep it there ([Google's guide](https://omardev29.github.io/rmp-docs/guidelines/google.html#formatting)). |
| `readability-implicit-bool-conversion` | raylib returns `int` for booleans. |
| `readability-function-cognitive-complexity` | A render switch is one function on purpose ([Google's guide](https://omardev29.github.io/rmp-docs/guidelines/google.html#function-length)). |
| `readability-uppercase-literal-suffix` | `1.0f`, not `1.0F`. |
| `readability-avoid-nested-conditional-operator`, `readability-math-missing-parentheses` | Switched off with the others; `.clang-tidy` gives no reason beside them. |

And for the examples, `examples/.clang-tidy` switches off `misc-unused-parameters`: a hook takes `float delta` whether this example's `_update` uses it or not, and the signature is the API's. It keeps `readability-identifier-naming`, `readability-misleading-indentation` and `readability-misplaced-array-index` from the family it switches off, and these six from `modernize`, each a rule of these pages: `modernize-avoid-c-arrays`, `modernize-avoid-c-style-cast`, `modernize-use-nullptr`, `modernize-avoid-variadic-functions`, `modernize-use-std-numbers` and `modernize-use-using`.

## What the framework still owes

A rule that arrives after the code it judges finds the code breaking it. The framework writes that down instead of switching the rule off, and each list only shrinks: what clang-tidy still finds is `tools/lint_debt.txt`; the pointers left in its headers, each with its reason, are `tools/pointer_ratchet.txt`; the files allowed to own memory or raylib resources by hand, each with its reason, are in `tools/ownership_check.sh`; and what cppcheck may not say, each with its reason, is in `tools/cppcheck_check.sh` or on the line itself.

## In a game

A game made with `rmp new` gets the formatter, `rmp fmt`, and the compiler's flags, which hold its designated initialisers to their order. None of the rest runs on its code: the rules are the advice the framework follows, and a game that wants to read like it can follow them too, and can [switch the framework's clang-tidy on](https://omardev29.github.io/rmp-docs/guidelines/index.html#switching-on-clang-tidy) for its own code. [What a game gets](https://omardev29.github.io/rmp-docs/guidelines/index.html#in-a-game) says the same from the game's side.
