What checks what
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 lintruns - The
checks of the framework's
.clang-tidyover the sources ofsrc/,tests/andexamples/, 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, andrmp lintpasses it. examples/.clang-tidy- The same file for the examples,
narrowed: it switches off the
modernizeandreadabilityfamilies, 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 lintfails 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 aNOLINTwith its reason on the line. - The text gates, stages of
rmp test - What clang-tidy cannot see, because it parses one branch of every
#ifor because no check of its says it:tools/naming_check.sh(rules R1 to R8, thenamingstage),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), andtools/cppcheck_check.sh, a second analyser oversrc/rmp(cppcheck). .clang-format, whichrmp fmtapplies- The layout of the code. The framework's CI fails on a file it would change; in a game,
rmp fmtformats andrmp fmt checkrefuses a file it would change, when the game runs them: itsrmp testand its CI do not. - The compiler
- Every
target CMake builds from the framework's sources and a game's is compiled with
-Wall -Wextraunder GCC and Clang: the desktop and the web, and not Android's or iOS's own projects. The framework's own checks build withRMP_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: types, constants, functions and variables, private members, the eight hooks | readability-identifier-naming | yes | yes | no |
| A local never hides a name around it | 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, in every branch | tools/naming_check.sh R1 R2 R3 R4 R8 | yes | yes | no |
Every macro starts with RMP_ | readability-identifier-naming; tools/naming_check.sh R5 in every branch | yes | yes | no |
| No constant named like somebody else's macro | tools/naming_check.sh R6 | yes | yes | no |
| No retired name | tools/naming_check.sh R7 | yes | yes | no |
The layout: 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, 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 | 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 | custom-rmp-header-constant | yes | yes, in their own headers | no |
| No raw pointer, 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 | tools/pointer_check.py, against tools/pointer_ratchet.txt | yes: include/rmp/ | no | no |
Nothing owned by hand: 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 | tools/ownership_check.sh O2 | yes: include/rmp/ and src/rmp/ | yes | no |
A std::optional is checked before it is read | bugprone-unchecked-optional-access | yes | yes | no |
A std::string_view never reaches a C function through data() | bugprone-suspicious-stringview-data-usage | yes | yes | no |
std::array, not a C array | modernize-avoid-c-arrays | yes | yes | no |
static_cast, never a C cast | modernize-avoid-c-style-cast; tools/style_check.sh S1 in every branch | yes | yes | no |
enum class | cppcoreguidelines-use-enum-class | yes | yes | no |
nullptr, never NULL or 0 | modernize-use-nullptr; tools/style_check.sh S2 in every branch | yes | yes | no |
| No C variadic function | 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 | google-runtime-int | yes | yes | no |
No long double | google-runtime-float | yes | yes | no |
A one-argument constructor is explicit | google-explicit-constructor | yes, but for the API's deliberate conversions | yes | no |
| A class that manages something says what its copies do | cppcoreguidelines-special-member-functions | yes | yes | no |
auto where a cast already names the type | modernize-use-auto | yes | no: the examples switch modernize off | no |
using, not typedef | modernize-use-using | yes | yes | no |
std::numbers, not a typed-in constant | modernize-use-std-numbers | yes | yes | no |
No using namespace | google-build-using-namespace | yes | yes | no |
| No unnamed namespace in a header | google-build-namespaces | yes | yes | no |
| No using-declaration at global scope in a header | google-global-names-in-headers | yes | yes | no |
No overloaded unary & | google-runtime-operator | yes | yes | no |
std::make_pair deduces its types | google-build-explicit-make-pair | yes | yes | no |
| No default argument on a virtual function | google-default-arguments | yes | yes | no |
++i where the old value is not read | tools/style_check.sh S6 | yes | yes | no |
| No user-defined literal | tools/style_check.sh S5 | yes | yes | no |
| Nothing newer than the oldest compiler a game is built with | 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 | tools/style_check.sh S3 | yes | yes | no |
| Designated initialisers in declaration order | -Werror=reorder-init-list under Clang; GCC and MSVC refuse them anyway | yes | yes | yes |
| A macro only for what a function cannot do | 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:
conston a by-value parameter in a definition — clang-tidy does not look at parameters — andconstexpr,constevalandconstinitwherever they apply (const);- a
std::arraygiven a size larger than its list, whose rest is filled with zeros (Modern C++); - an unsigned type only for bits, and
autobeyond a cast (Modern C++); #pragma onceat the top of a header, and<filesystem>insrc/rmp/app/app.cppandsrc/rmp/save/save.cpponly (Google's guide);- 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). |
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). |
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). |
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). |
readability-implicit-bool-conversion | raylib returns int for booleans. |
readability-function-cognitive-complexity | A render switch is one function on purpose (Google's guide). |
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 for its own code. What a game gets
says the same from the game's side.