ReferenceRéférence
All the rulesToutes les règles
Every rule of xstyle: its code, severity, fix level and languages, read from xstyle --list-rules.Toutes les règles de xstyle : code, sévérité, niveau de fix et langages, lus depuis xstyle --list-rules.
85 rules, generated from xstyle --list-rules of version v1.0.0. xstyle -x CODE explains one in the terminal; the severities and fix levels are explained in Severities and fix levels.
* = every file checked.
85 règles, générées depuis xstyle --list-rules de la version v1.0.0. xstyle -x CODE en explique une dans le terminal ; les sévérités et niveaux de fix sont expliqués dans Sévérités et niveaux de fix. Les textes des règles sont ceux du programme (en anglais).
* = tous les fichiers vérifiés.
1. MandatoryObligatoire
| Code | Severity | Fix | Languages | Rule |
|---|---|---|---|---|
R34 | mandatory | force | \* | Rule 34: if it exists, there is porn of it. No exceptions |
| Code | Sévérité | Fix | Langages | Règle |
|---|---|---|---|---|
R34 | mandatory | force | \* | Rule 34: if it exists, there is porn of it. No exceptions |
2. Generic (every language)Génériques (tous les langages)
| Code | Severity | Fix | Languages | Rule |
|---|---|---|---|---|
G-CRLF | major | auto | \* | Windows line endings (CRLF), use LF |
G-TAB | major | auto | \* | Tab used for the indentation, use 4 spaces (except Makefile recipes) |
G-TRAILING | minor | auto | \* | Trailing whitespace |
G-EMPTY-LINES | minor | auto | \* | Two or more consecutive empty lines, one is the maximum |
G-EOF-NEWLINE | negligible | auto | \* | No newline at the end of the file |
G-EOF-EMPTY | negligible | auto | \* | Empty lines at the end of the file |
G-TODO | minor | - | \* | TODO / FIXME / XXX tag, describe the limitation in a normal comment instead |
G-INDENT | negligible | - | cpp,c,py,sh,lua,js,rs,cmake | Indentation that is not a multiple of 4 spaces |
| Code | Sévérité | Fix | Langages | Règle |
|---|---|---|---|---|
G-CRLF | major | auto | \* | Windows line endings (CRLF), use LF |
G-TAB | major | auto | \* | Tab used for the indentation, use 4 spaces (except Makefile recipes) |
G-TRAILING | minor | auto | \* | Trailing whitespace |
G-EMPTY-LINES | minor | auto | \* | Two or more consecutive empty lines, one is the maximum |
G-EOF-NEWLINE | negligible | auto | \* | No newline at the end of the file |
G-EOF-EMPTY | negligible | auto | \* | Empty lines at the end of the file |
G-TODO | minor | - | \* | TODO / FIXME / XXX tag, describe the limitation in a normal comment instead |
G-INDENT | negligible | - | cpp,c,py,sh,lua,js,rs,cmake | Indentation that is not a multiple of 4 spaces |
3. C++ / CC++ / C
| Code | Severity | Fix | Languages | Rule |
|---|---|---|---|---|
CPP-USING-NAMESPACE | unforgivable | - | cpp | using namespace, always write the fully qualified names |
CPP-GUARD-MISSING | major | auto | cpp,c | Header without include guard (#ifndef NAME_H / #define NAME_H) |
CPP-PRAGMA-ONCE | minor | auto | cpp,c | #pragma once instead of the include guard NAME_H |
CPP-GUARD-NAME | minor | auto | cpp,c | Include guard not named after the file (Name.hpp -> NAME_H) |
CPP-ENDIF-COMMENT | negligible | auto | cpp,c | Guard #endif without its /* NAME_H */ comment |
CPP-PREPRO-INDENT | negligible | auto | cpp,c | #if block not at the indent of the code around with its content one level more (directives: 4 per #if / guard level) |
CPP-HEADER | minor | ask | cpp,c | Missing file header (cpp-class scripts/header.py) |
CPP-HEADER-FILE | negligible | auto | cpp,c | @file of the header is not the name of the file |
CPP-NULL | major | auto | cpp | NULL instead of nullptr |
CPP-C-CAST | major | auto | cpp | C cast, use static_cast (only (void) is allowed) |
CPP-AUTO | major | - | cpp | auto, write the type (allowed: iterators, structured bindings) |
CPP-USING-STD | major | - | cpp | using std::x, always write std::x |
CPP-TYPEDEF | minor | auto | cpp | typedef, use using Name = Type |
CPP-BRACE-FUNCTION | major | auto | cpp,c | Function opening brace on the signature line, it goes on its own line |
CPP-BRACE-OWN-LINE | major | auto | cpp,c | Opening brace of a class / namespace / control block on its own line, it goes on the same line |
CPP-ELSE-LINE | minor | auto | cpp,c | else / catch not on the closing brace line (} else {) |
CPP-KEYWORD-SPACE | minor | auto | cpp,c | No space between if / for / while / switch / catch and the parenthesis |
CPP-PAREN-SPACE | negligible | auto | cpp,c | Space inside the parentheses of a control statement |
CPP-COLON-SPACE | negligible | auto | cpp | Space before ':' of a range-for, an inheritance or an enum base |
CPP-PTR-REF | minor | auto | cpp,c | & / * glued to the name instead of the type (const T& name, char* buf) |
CPP-VOID-PARAM | minor | auto | cpp,c | Empty parameter list, write (void) |
CPP-THIS | minor | auto | cpp | Member accessed without this-> |
CPP-NAMESPACE-NESTED | minor | - | cpp | Nested namespace blocks, use namespace a::b { |
CPP-NAMESPACE-COMMENT | negligible | auto | cpp | Namespace block without // namespace start / // namespace end |
CPP-NAMESPACE-INDENT | minor | - | cpp | Content of a namespace indented (it is not) |
CPP-INCLUDE-ORDER | minor | auto | cpp,c | Include order: personal libs (+ defines), project, external; longest name first |
CPP-CLASS-NAME | major | - | cpp | Class / struct / enum not in PascalCase |
CPP-MEMBER-NAME | minor | - | cpp | Class data member not named _camelCase |
CPP-MACRO-NAME | minor | - | cpp,c | Macro not in UPPER_SNAKE (or _lower for attribute / section macros) |
CPP-ONE-LINER | negligible | auto | cpp | One-liner body not written {statement}; (an empty one: { /* Nothing */ };) |
CPP-EMPTY-BODY | minor | auto | cpp | Empty constructor / destructor / operator of a class on several lines (one line: sig: init { /* Nothing */ }; // comment) |
CPP-ONELINER-ALIGN | negligible | auto | cpp | One-liner functions of a group not aligned tight: their { right after the longest signature + 1 (lengths far apart: one column per level of 2+ lines) |
CPP-INIT-COLON | minor | auto | cpp | Init list on the line of its constructor: its : glued to the ) (Name(int a): _a{a}) |
CPP-ACCESS-ORDER | negligible | - | cpp | public before private / protected in a class |
CPP-SINGLE-STATEMENT | minor | - | cpp | Single statement function defined in the .cpp, define it inline in the header |
CPP-DOXYGEN | minor | - | cpp,c | Doxygen comment (@brief, @param, ///, /**), short plain comments only |
CPP-INCLUDE-COMMENT | minor | - | cpp,c | Include of a header without its trailing comment listing what is used |
CPP-COMMENT-ALIGN | negligible | auto | cpp,c | Trailing comments of an include block not aligned on one column |
CPP-EMPTY-SECTION | minor | auto | cpp,c | Section separator / class block with nothing linked to it |
CPP-CLASS-BLOCK | minor | - | cpp | Declaration in the wrong class block: Pre-Function = declared only (body in the .cpp), Function = defined in the header, Constructor / Destructor = theirs, data members before the blocks (Operator: free) |
CPP-ORPHAN-GROUP | negligible | auto | cpp,c | /* group */ label with nothing under it |
| Code | Sévérité | Fix | Langages | Règle |
|---|---|---|---|---|
CPP-USING-NAMESPACE | unforgivable | - | cpp | using namespace, always write the fully qualified names |
CPP-GUARD-MISSING | major | auto | cpp,c | Header without include guard (#ifndef NAME_H / #define NAME_H) |
CPP-PRAGMA-ONCE | minor | auto | cpp,c | #pragma once instead of the include guard NAME_H |
CPP-GUARD-NAME | minor | auto | cpp,c | Include guard not named after the file (Name.hpp -> NAME_H) |
CPP-ENDIF-COMMENT | negligible | auto | cpp,c | Guard #endif without its /* NAME_H */ comment |
CPP-PREPRO-INDENT | negligible | auto | cpp,c | #if block not at the indent of the code around with its content one level more (directives: 4 per #if / guard level) |
CPP-HEADER | minor | ask | cpp,c | Missing file header (cpp-class scripts/header.py) |
CPP-HEADER-FILE | negligible | auto | cpp,c | @file of the header is not the name of the file |
CPP-NULL | major | auto | cpp | NULL instead of nullptr |
CPP-C-CAST | major | auto | cpp | C cast, use static_cast (only (void) is allowed) |
CPP-AUTO | major | - | cpp | auto, write the type (allowed: iterators, structured bindings) |
CPP-USING-STD | major | - | cpp | using std::x, always write std::x |
CPP-TYPEDEF | minor | auto | cpp | typedef, use using Name = Type |
CPP-BRACE-FUNCTION | major | auto | cpp,c | Function opening brace on the signature line, it goes on its own line |
CPP-BRACE-OWN-LINE | major | auto | cpp,c | Opening brace of a class / namespace / control block on its own line, it goes on the same line |
CPP-ELSE-LINE | minor | auto | cpp,c | else / catch not on the closing brace line (} else {) |
CPP-KEYWORD-SPACE | minor | auto | cpp,c | No space between if / for / while / switch / catch and the parenthesis |
CPP-PAREN-SPACE | negligible | auto | cpp,c | Space inside the parentheses of a control statement |
CPP-COLON-SPACE | negligible | auto | cpp | Space before ':' of a range-for, an inheritance or an enum base |
CPP-PTR-REF | minor | auto | cpp,c | & / * glued to the name instead of the type (const T& name, char* buf) |
CPP-VOID-PARAM | minor | auto | cpp,c | Empty parameter list, write (void) |
CPP-THIS | minor | auto | cpp | Member accessed without this-> |
CPP-NAMESPACE-NESTED | minor | - | cpp | Nested namespace blocks, use namespace a::b { |
CPP-NAMESPACE-COMMENT | negligible | auto | cpp | Namespace block without // namespace start / // namespace end |
CPP-NAMESPACE-INDENT | minor | - | cpp | Content of a namespace indented (it is not) |
CPP-INCLUDE-ORDER | minor | auto | cpp,c | Include order: personal libs (+ defines), project, external; longest name first |
CPP-CLASS-NAME | major | - | cpp | Class / struct / enum not in PascalCase |
CPP-MEMBER-NAME | minor | - | cpp | Class data member not named _camelCase |
CPP-MACRO-NAME | minor | - | cpp,c | Macro not in UPPER_SNAKE (or _lower for attribute / section macros) |
CPP-ONE-LINER | negligible | auto | cpp | One-liner body not written {statement}; (an empty one: { /* Nothing */ };) |
CPP-EMPTY-BODY | minor | auto | cpp | Empty constructor / destructor / operator of a class on several lines (one line: sig: init { /* Nothing */ }; // comment) |
CPP-ONELINER-ALIGN | negligible | auto | cpp | One-liner functions of a group not aligned tight: their { right after the longest signature + 1 (lengths far apart: one column per level of 2+ lines) |
CPP-INIT-COLON | minor | auto | cpp | Init list on the line of its constructor: its : glued to the ) (Name(int a): _a{a}) |
CPP-ACCESS-ORDER | negligible | - | cpp | public before private / protected in a class |
CPP-SINGLE-STATEMENT | minor | - | cpp | Single statement function defined in the .cpp, define it inline in the header |
CPP-DOXYGEN | minor | - | cpp,c | Doxygen comment (@brief, @param, ///, /**), short plain comments only |
CPP-INCLUDE-COMMENT | minor | - | cpp,c | Include of a header without its trailing comment listing what is used |
CPP-COMMENT-ALIGN | negligible | auto | cpp,c | Trailing comments of an include block not aligned on one column |
CPP-EMPTY-SECTION | minor | auto | cpp,c | Section separator / class block with nothing linked to it |
CPP-CLASS-BLOCK | minor | - | cpp | Declaration in the wrong class block: Pre-Function = declared only (body in the .cpp), Function = defined in the header, Constructor / Destructor = theirs, data members before the blocks (Operator: free) |
CPP-ORPHAN-GROUP | negligible | auto | cpp,c | /* group */ label with nothing under it |
4. CMakeCMake
| Code | Severity | Fix | Languages | Rule |
|---|---|---|---|---|
CMAKE-SECTION-ORDER | minor | - | cmake | Sections not in the cmake-style order |
CMAKE-BANNER | negligible | auto | cmake | Section banner not '# ' + 25 '=' |
CMAKE-COMPILER-ORDER | major | force | cmake | set(CMAKE_CXX_COMPILER) after project(): ignored, it goes before |
CMAKE-GLOB-SOURCES | major | - | cmake | Sources collected with file(GLOB), list them in set(SRC ...) |
CMAKE-UNREGISTERED | major | force | cmake | Source file of src/ missing from set(SRC ...) |
| Code | Sévérité | Fix | Langages | Règle |
|---|---|---|---|---|
CMAKE-SECTION-ORDER | minor | - | cmake | Sections not in the cmake-style order |
CMAKE-BANNER | negligible | auto | cmake | Section banner not '# ' + 25 '=' |
CMAKE-COMPILER-ORDER | major | force | cmake | set(CMAKE_CXX_COMPILER) after project(): ignored, it goes before |
CMAKE-GLOB-SOURCES | major | - | cmake | Sources collected with file(GLOB), list them in set(SRC ...) |
CMAKE-UNREGISTERED | major | force | cmake | Source file of src/ missing from set(SRC ...) |
5. libutilslibutils
| Code | Severity | Fix | Languages | Rule |
|---|---|---|---|---|
LU-INCLUDE | major | auto | cpp | libutils header included directly, use #define _Section + <utils/utils.hpp> |
LU-BARE-INCLUDE | major | auto | cpp | <utils/utils.hpp> without any #define _Section before it |
LU-SECTION | minor | auto | cpp | libutils section used without its #define before <utils/utils.hpp> |
LU-ATTRIBUTE | minor | auto | cpp | Standard attribute with a libutils macro equivalent ([[nodiscard]] -> _nodiscard) |
LU-MIGRATION | major | auto | cpp | Deprecated libutils name (migration alias), use the new name |
LU-EXCEPTION | major | - | cpp | Standard exception thrown, use utils::exception::ErrorException |
LU-ARGS | minor | - | cpp | Arguments parsed by hand, use utils::arguments::ArgParser |
LU-ANSI | minor | - | cpp | Raw ANSI escape sequence, use utils::iomanip |
LU-SOCKET | minor | - | cpp | Raw BSD socket, use utils::network (TCPSocket, Server, Client) |
LU-SYSCALL | minor | - | cpp | Raw pipe / dup / fork / epoll / shm / dlopen, use utils::encapsulation |
LU-THREADS | minor | - | cpp | Hand made thread pool, use utils::pool::Cluster or utils::system::Scheduler |
LU-ANGLE | minor | - | cpp | Degree / radian conversion by hand, use utils::math::trigo |
LU-BASE64 | minor | - | cpp | Hand made base64, use utils::smanip::codec::Base64Codec |
LU-VERBOSE | minor | - | cpp | Hand made verbose flag, use utils::verbose (set_verbose, onBasicVerbose) |
LU-DISTANCE | minor | - | cpp | Hand made string distance, use utils::algorithms::c2dmp |
| Code | Sévérité | Fix | Langages | Règle |
|---|---|---|---|---|
LU-INCLUDE | major | auto | cpp | libutils header included directly, use #define _Section + <utils/utils.hpp> |
LU-BARE-INCLUDE | major | auto | cpp | <utils/utils.hpp> without any #define _Section before it |
LU-SECTION | minor | auto | cpp | libutils section used without its #define before <utils/utils.hpp> |
LU-ATTRIBUTE | minor | auto | cpp | Standard attribute with a libutils macro equivalent ([[nodiscard]] -> _nodiscard) |
LU-MIGRATION | major | auto | cpp | Deprecated libutils name (migration alias), use the new name |
LU-EXCEPTION | major | - | cpp | Standard exception thrown, use utils::exception::ErrorException |
LU-ARGS | minor | - | cpp | Arguments parsed by hand, use utils::arguments::ArgParser |
LU-ANSI | minor | - | cpp | Raw ANSI escape sequence, use utils::iomanip |
LU-SOCKET | minor | - | cpp | Raw BSD socket, use utils::network (TCPSocket, Server, Client) |
LU-SYSCALL | minor | - | cpp | Raw pipe / dup / fork / epoll / shm / dlopen, use utils::encapsulation |
LU-THREADS | minor | - | cpp | Hand made thread pool, use utils::pool::Cluster or utils::system::Scheduler |
LU-ANGLE | minor | - | cpp | Degree / radian conversion by hand, use utils::math::trigo |
LU-BASE64 | minor | - | cpp | Hand made base64, use utils::smanip::codec::Base64Codec |
LU-VERBOSE | minor | - | cpp | Hand made verbose flag, use utils::verbose (set_verbose, onBasicVerbose) |
LU-DISTANCE | minor | - | cpp | Hand made string distance, use utils::algorithms::c2dmp |
6. PythonPython
| Code | Severity | Fix | Languages | Rule |
|---|---|---|---|---|
PY-WILDCARD-IMPORT | major | - | py | from x import *, import the names explicitly |
PY-BARE-EXCEPT | major | - | py | Bare except:, catch the exceptions expected |
PY-TYPE-HINTS | minor | auto | py | Function without type hints (added when certain: literal defaults, None / literal returns) |
PY-PRINT-ERROR | minor | auto | py | print(..., file=stderr), use stderr.write |
PY-OPEN-ENCODING | minor | force | py | open() of a text file without encoding="utf-8" |
| Code | Sévérité | Fix | Langages | Règle |
|---|---|---|---|---|
PY-WILDCARD-IMPORT | major | - | py | from x import *, import the names explicitly |
PY-BARE-EXCEPT | major | - | py | Bare except:, catch the exceptions expected |
PY-TYPE-HINTS | minor | auto | py | Function without type hints (added when certain: literal defaults, None / literal returns) |
PY-PRINT-ERROR | minor | auto | py | print(..., file=stderr), use stderr.write |
PY-OPEN-ENCODING | minor | force | py | open() of a text file without encoding="utf-8" |
7. RustRust
| Code | Severity | Fix | Languages | Rule |
|---|---|---|---|---|
RS-UNWRAP | major | - | rs | .unwrap() outside of the tests, propagate with ? (and a context) or handle the error |
RS-PANIC | major | - | rs | panic! / process::exit in a library file, todo! / unimplemented! left anywhere |
RS-GLOB-IMPORT | major | - | rs | use path::*, import the names explicitly (super::* and preludes excepted) |
RS-NAMING | minor | - | rs | fn / variables snake_case, types PascalCase, const / static UPPER_SNAKE |
RS-UNSAFE | minor | - | rs | unsafe block without a // SAFETY: comment explaining why it is sound |
RS-PRINT-ERROR | minor | auto | rs | Error printed with println!, use eprintln! (stderr) |
RS-DBG | minor | - | rs | dbg! left in the code |
| Code | Sévérité | Fix | Langages | Règle |
|---|---|---|---|---|
RS-UNWRAP | major | - | rs | .unwrap() outside of the tests, propagate with ? (and a context) or handle the error |
RS-PANIC | major | - | rs | panic! / process::exit in a library file, todo! / unimplemented! left anywhere |
RS-GLOB-IMPORT | major | - | rs | use path::*, import the names explicitly (super::* and preludes excepted) |
RS-NAMING | minor | - | rs | fn / variables snake_case, types PascalCase, const / static UPPER_SNAKE |
RS-UNSAFE | minor | - | rs | unsafe block without a // SAFETY: comment explaining why it is sound |
RS-PRINT-ERROR | minor | auto | rs | Error printed with println!, use eprintln! (stderr) |
RS-DBG | minor | - | rs | dbg! left in the code |
8. ShellShell
| Code | Severity | Fix | Languages | Rule |
|---|---|---|---|---|
SH-SHEBANG | minor | - | sh | Script without shebang (#!/bin/bash) |
SH-STRICT | minor | force | sh | Bash script without set -euo pipefail |
SH-TEST | negligible | auto | sh | [ ] test in a bash script, use [[ ]] |
| Code | Sévérité | Fix | Langages | Règle |
|---|---|---|---|---|
SH-SHEBANG | minor | - | sh | Script without shebang (#!/bin/bash) |
SH-STRICT | minor | force | sh | Bash script without set -euo pipefail |
SH-TEST | negligible | auto | sh | [ ] test in a bash script, use [[ ]] |