xstylev1.0.0
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

CodeSeverityFixLanguagesRule
R34mandatoryforce\*Rule 34: if it exists, there is porn of it. No exceptions
CodeSévéritéFixLangagesRègle
R34mandatoryforce\*Rule 34: if it exists, there is porn of it. No exceptions

2. Generic (every language)Génériques (tous les langages)

CodeSeverityFixLanguagesRule
G-CRLFmajorauto\*Windows line endings (CRLF), use LF
G-TABmajorauto\*Tab used for the indentation, use 4 spaces (except Makefile recipes)
G-TRAILINGminorauto\*Trailing whitespace
G-EMPTY-LINESminorauto\*Two or more consecutive empty lines, one is the maximum
G-EOF-NEWLINEnegligibleauto\*No newline at the end of the file
G-EOF-EMPTYnegligibleauto\*Empty lines at the end of the file
G-TODOminor-\*TODO / FIXME / XXX tag, describe the limitation in a normal comment instead
G-INDENTnegligible-cpp,c,py,sh,lua,js,rs,cmakeIndentation that is not a multiple of 4 spaces
CodeSévéritéFixLangagesRègle
G-CRLFmajorauto\*Windows line endings (CRLF), use LF
G-TABmajorauto\*Tab used for the indentation, use 4 spaces (except Makefile recipes)
G-TRAILINGminorauto\*Trailing whitespace
G-EMPTY-LINESminorauto\*Two or more consecutive empty lines, one is the maximum
G-EOF-NEWLINEnegligibleauto\*No newline at the end of the file
G-EOF-EMPTYnegligibleauto\*Empty lines at the end of the file
G-TODOminor-\*TODO / FIXME / XXX tag, describe the limitation in a normal comment instead
G-INDENTnegligible-cpp,c,py,sh,lua,js,rs,cmakeIndentation that is not a multiple of 4 spaces

3. C++ / CC++ / C

CodeSeverityFixLanguagesRule
CPP-USING-NAMESPACEunforgivable-cppusing namespace, always write the fully qualified names
CPP-GUARD-MISSINGmajorautocpp,cHeader without include guard (#ifndef NAME_H / #define NAME_H)
CPP-PRAGMA-ONCEminorautocpp,c#pragma once instead of the include guard NAME_H
CPP-GUARD-NAMEminorautocpp,cInclude guard not named after the file (Name.hpp -> NAME_H)
CPP-ENDIF-COMMENTnegligibleautocpp,cGuard #endif without its /* NAME_H */ comment
CPP-PREPRO-INDENTnegligibleautocpp,c#if block not at the indent of the code around with its content one level more (directives: 4 per #if / guard level)
CPP-HEADERminoraskcpp,cMissing file header (cpp-class scripts/header.py)
CPP-HEADER-FILEnegligibleautocpp,c@file of the header is not the name of the file
CPP-NULLmajorautocppNULL instead of nullptr
CPP-C-CASTmajorautocppC cast, use static_cast (only (void) is allowed)
CPP-AUTOmajor-cppauto, write the type (allowed: iterators, structured bindings)
CPP-USING-STDmajor-cppusing std::x, always write std::x
CPP-TYPEDEFminorautocpptypedef, use using Name = Type
CPP-BRACE-FUNCTIONmajorautocpp,cFunction opening brace on the signature line, it goes on its own line
CPP-BRACE-OWN-LINEmajorautocpp,cOpening brace of a class / namespace / control block on its own line, it goes on the same line
CPP-ELSE-LINEminorautocpp,celse / catch not on the closing brace line (} else {)
CPP-KEYWORD-SPACEminorautocpp,cNo space between if / for / while / switch / catch and the parenthesis
CPP-PAREN-SPACEnegligibleautocpp,cSpace inside the parentheses of a control statement
CPP-COLON-SPACEnegligibleautocppSpace before ':' of a range-for, an inheritance or an enum base
CPP-PTR-REFminorautocpp,c& / * glued to the name instead of the type (const T& name, char* buf)
CPP-VOID-PARAMminorautocpp,cEmpty parameter list, write (void)
CPP-THISminorautocppMember accessed without this->
CPP-NAMESPACE-NESTEDminor-cppNested namespace blocks, use namespace a::b {
CPP-NAMESPACE-COMMENTnegligibleautocppNamespace block without // namespace start / // namespace end
CPP-NAMESPACE-INDENTminor-cppContent of a namespace indented (it is not)
CPP-INCLUDE-ORDERminorautocpp,cInclude order: personal libs (+ defines), project, external; longest name first
CPP-CLASS-NAMEmajor-cppClass / struct / enum not in PascalCase
CPP-MEMBER-NAMEminor-cppClass data member not named _camelCase
CPP-MACRO-NAMEminor-cpp,cMacro not in UPPER_SNAKE (or _lower for attribute / section macros)
CPP-ONE-LINERnegligibleautocppOne-liner body not written {statement}; (an empty one: { /* Nothing */ };)
CPP-EMPTY-BODYminorautocppEmpty constructor / destructor / operator of a class on several lines (one line: sig: init { /* Nothing */ }; // comment)
CPP-ONELINER-ALIGNnegligibleautocppOne-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-COLONminorautocppInit list on the line of its constructor: its : glued to the ) (Name(int a): _a{a})
CPP-ACCESS-ORDERnegligible-cpppublic before private / protected in a class
CPP-SINGLE-STATEMENTminor-cppSingle statement function defined in the .cpp, define it inline in the header
CPP-DOXYGENminor-cpp,cDoxygen comment (@brief, @param, ///, /**), short plain comments only
CPP-INCLUDE-COMMENTminor-cpp,cInclude of a header without its trailing comment listing what is used
CPP-COMMENT-ALIGNnegligibleautocpp,cTrailing comments of an include block not aligned on one column
CPP-EMPTY-SECTIONminorautocpp,cSection separator / class block with nothing linked to it
CPP-CLASS-BLOCKminor-cppDeclaration 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-GROUPnegligibleautocpp,c/* group */ label with nothing under it
CodeSévéritéFixLangagesRègle
CPP-USING-NAMESPACEunforgivable-cppusing namespace, always write the fully qualified names
CPP-GUARD-MISSINGmajorautocpp,cHeader without include guard (#ifndef NAME_H / #define NAME_H)
CPP-PRAGMA-ONCEminorautocpp,c#pragma once instead of the include guard NAME_H
CPP-GUARD-NAMEminorautocpp,cInclude guard not named after the file (Name.hpp -> NAME_H)
CPP-ENDIF-COMMENTnegligibleautocpp,cGuard #endif without its /* NAME_H */ comment
CPP-PREPRO-INDENTnegligibleautocpp,c#if block not at the indent of the code around with its content one level more (directives: 4 per #if / guard level)
CPP-HEADERminoraskcpp,cMissing file header (cpp-class scripts/header.py)
CPP-HEADER-FILEnegligibleautocpp,c@file of the header is not the name of the file
CPP-NULLmajorautocppNULL instead of nullptr
CPP-C-CASTmajorautocppC cast, use static_cast (only (void) is allowed)
CPP-AUTOmajor-cppauto, write the type (allowed: iterators, structured bindings)
CPP-USING-STDmajor-cppusing std::x, always write std::x
CPP-TYPEDEFminorautocpptypedef, use using Name = Type
CPP-BRACE-FUNCTIONmajorautocpp,cFunction opening brace on the signature line, it goes on its own line
CPP-BRACE-OWN-LINEmajorautocpp,cOpening brace of a class / namespace / control block on its own line, it goes on the same line
CPP-ELSE-LINEminorautocpp,celse / catch not on the closing brace line (} else {)
CPP-KEYWORD-SPACEminorautocpp,cNo space between if / for / while / switch / catch and the parenthesis
CPP-PAREN-SPACEnegligibleautocpp,cSpace inside the parentheses of a control statement
CPP-COLON-SPACEnegligibleautocppSpace before ':' of a range-for, an inheritance or an enum base
CPP-PTR-REFminorautocpp,c& / * glued to the name instead of the type (const T& name, char* buf)
CPP-VOID-PARAMminorautocpp,cEmpty parameter list, write (void)
CPP-THISminorautocppMember accessed without this->
CPP-NAMESPACE-NESTEDminor-cppNested namespace blocks, use namespace a::b {
CPP-NAMESPACE-COMMENTnegligibleautocppNamespace block without // namespace start / // namespace end
CPP-NAMESPACE-INDENTminor-cppContent of a namespace indented (it is not)
CPP-INCLUDE-ORDERminorautocpp,cInclude order: personal libs (+ defines), project, external; longest name first
CPP-CLASS-NAMEmajor-cppClass / struct / enum not in PascalCase
CPP-MEMBER-NAMEminor-cppClass data member not named _camelCase
CPP-MACRO-NAMEminor-cpp,cMacro not in UPPER_SNAKE (or _lower for attribute / section macros)
CPP-ONE-LINERnegligibleautocppOne-liner body not written {statement}; (an empty one: { /* Nothing */ };)
CPP-EMPTY-BODYminorautocppEmpty constructor / destructor / operator of a class on several lines (one line: sig: init { /* Nothing */ }; // comment)
CPP-ONELINER-ALIGNnegligibleautocppOne-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-COLONminorautocppInit list on the line of its constructor: its : glued to the ) (Name(int a): _a{a})
CPP-ACCESS-ORDERnegligible-cpppublic before private / protected in a class
CPP-SINGLE-STATEMENTminor-cppSingle statement function defined in the .cpp, define it inline in the header
CPP-DOXYGENminor-cpp,cDoxygen comment (@brief, @param, ///, /**), short plain comments only
CPP-INCLUDE-COMMENTminor-cpp,cInclude of a header without its trailing comment listing what is used
CPP-COMMENT-ALIGNnegligibleautocpp,cTrailing comments of an include block not aligned on one column
CPP-EMPTY-SECTIONminorautocpp,cSection separator / class block with nothing linked to it
CPP-CLASS-BLOCKminor-cppDeclaration 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-GROUPnegligibleautocpp,c/* group */ label with nothing under it

4. CMakeCMake

CodeSeverityFixLanguagesRule
CMAKE-SECTION-ORDERminor-cmakeSections not in the cmake-style order
CMAKE-BANNERnegligibleautocmakeSection banner not '# ' + 25 '='
CMAKE-COMPILER-ORDERmajorforcecmakeset(CMAKE_CXX_COMPILER) after project(): ignored, it goes before
CMAKE-GLOB-SOURCESmajor-cmakeSources collected with file(GLOB), list them in set(SRC ...)
CMAKE-UNREGISTEREDmajorforcecmakeSource file of src/ missing from set(SRC ...)
CodeSévéritéFixLangagesRègle
CMAKE-SECTION-ORDERminor-cmakeSections not in the cmake-style order
CMAKE-BANNERnegligibleautocmakeSection banner not '# ' + 25 '='
CMAKE-COMPILER-ORDERmajorforcecmakeset(CMAKE_CXX_COMPILER) after project(): ignored, it goes before
CMAKE-GLOB-SOURCESmajor-cmakeSources collected with file(GLOB), list them in set(SRC ...)
CMAKE-UNREGISTEREDmajorforcecmakeSource file of src/ missing from set(SRC ...)

5. libutilslibutils

CodeSeverityFixLanguagesRule
LU-INCLUDEmajorautocpplibutils header included directly, use #define _Section + <utils/utils.hpp>
LU-BARE-INCLUDEmajorautocpp<utils/utils.hpp> without any #define _Section before it
LU-SECTIONminorautocpplibutils section used without its #define before <utils/utils.hpp>
LU-ATTRIBUTEminorautocppStandard attribute with a libutils macro equivalent ([[nodiscard]] -> _nodiscard)
LU-MIGRATIONmajorautocppDeprecated libutils name (migration alias), use the new name
LU-EXCEPTIONmajor-cppStandard exception thrown, use utils::exception::ErrorException
LU-ARGSminor-cppArguments parsed by hand, use utils::arguments::ArgParser
LU-ANSIminor-cppRaw ANSI escape sequence, use utils::iomanip
LU-SOCKETminor-cppRaw BSD socket, use utils::network (TCPSocket, Server, Client)
LU-SYSCALLminor-cppRaw pipe / dup / fork / epoll / shm / dlopen, use utils::encapsulation
LU-THREADSminor-cppHand made thread pool, use utils::pool::Cluster or utils::system::Scheduler
LU-ANGLEminor-cppDegree / radian conversion by hand, use utils::math::trigo
LU-BASE64minor-cppHand made base64, use utils::smanip::codec::Base64Codec
LU-VERBOSEminor-cppHand made verbose flag, use utils::verbose (set_verbose, onBasicVerbose)
LU-DISTANCEminor-cppHand made string distance, use utils::algorithms::c2dmp
CodeSévéritéFixLangagesRègle
LU-INCLUDEmajorautocpplibutils header included directly, use #define _Section + <utils/utils.hpp>
LU-BARE-INCLUDEmajorautocpp<utils/utils.hpp> without any #define _Section before it
LU-SECTIONminorautocpplibutils section used without its #define before <utils/utils.hpp>
LU-ATTRIBUTEminorautocppStandard attribute with a libutils macro equivalent ([[nodiscard]] -> _nodiscard)
LU-MIGRATIONmajorautocppDeprecated libutils name (migration alias), use the new name
LU-EXCEPTIONmajor-cppStandard exception thrown, use utils::exception::ErrorException
LU-ARGSminor-cppArguments parsed by hand, use utils::arguments::ArgParser
LU-ANSIminor-cppRaw ANSI escape sequence, use utils::iomanip
LU-SOCKETminor-cppRaw BSD socket, use utils::network (TCPSocket, Server, Client)
LU-SYSCALLminor-cppRaw pipe / dup / fork / epoll / shm / dlopen, use utils::encapsulation
LU-THREADSminor-cppHand made thread pool, use utils::pool::Cluster or utils::system::Scheduler
LU-ANGLEminor-cppDegree / radian conversion by hand, use utils::math::trigo
LU-BASE64minor-cppHand made base64, use utils::smanip::codec::Base64Codec
LU-VERBOSEminor-cppHand made verbose flag, use utils::verbose (set_verbose, onBasicVerbose)
LU-DISTANCEminor-cppHand made string distance, use utils::algorithms::c2dmp

6. PythonPython

CodeSeverityFixLanguagesRule
PY-WILDCARD-IMPORTmajor-pyfrom x import *, import the names explicitly
PY-BARE-EXCEPTmajor-pyBare except:, catch the exceptions expected
PY-TYPE-HINTSminorautopyFunction without type hints (added when certain: literal defaults, None / literal returns)
PY-PRINT-ERRORminorautopyprint(..., file=stderr), use stderr.write
PY-OPEN-ENCODINGminorforcepyopen() of a text file without encoding="utf-8"
CodeSévéritéFixLangagesRègle
PY-WILDCARD-IMPORTmajor-pyfrom x import *, import the names explicitly
PY-BARE-EXCEPTmajor-pyBare except:, catch the exceptions expected
PY-TYPE-HINTSminorautopyFunction without type hints (added when certain: literal defaults, None / literal returns)
PY-PRINT-ERRORminorautopyprint(..., file=stderr), use stderr.write
PY-OPEN-ENCODINGminorforcepyopen() of a text file without encoding="utf-8"

7. RustRust

CodeSeverityFixLanguagesRule
RS-UNWRAPmajor-rs.unwrap() outside of the tests, propagate with ? (and a context) or handle the error
RS-PANICmajor-rspanic! / process::exit in a library file, todo! / unimplemented! left anywhere
RS-GLOB-IMPORTmajor-rsuse path::*, import the names explicitly (super::* and preludes excepted)
RS-NAMINGminor-rsfn / variables snake_case, types PascalCase, const / static UPPER_SNAKE
RS-UNSAFEminor-rsunsafe block without a // SAFETY: comment explaining why it is sound
RS-PRINT-ERRORminorautorsError printed with println!, use eprintln! (stderr)
RS-DBGminor-rsdbg! left in the code
CodeSévéritéFixLangagesRègle
RS-UNWRAPmajor-rs.unwrap() outside of the tests, propagate with ? (and a context) or handle the error
RS-PANICmajor-rspanic! / process::exit in a library file, todo! / unimplemented! left anywhere
RS-GLOB-IMPORTmajor-rsuse path::*, import the names explicitly (super::* and preludes excepted)
RS-NAMINGminor-rsfn / variables snake_case, types PascalCase, const / static UPPER_SNAKE
RS-UNSAFEminor-rsunsafe block without a // SAFETY: comment explaining why it is sound
RS-PRINT-ERRORminorautorsError printed with println!, use eprintln! (stderr)
RS-DBGminor-rsdbg! left in the code

8. ShellShell

CodeSeverityFixLanguagesRule
SH-SHEBANGminor-shScript without shebang (#!/bin/bash)
SH-STRICTminorforceshBash script without set -euo pipefail
SH-TESTnegligibleautosh[ ] test in a bash script, use [[ ]]
CodeSévéritéFixLangagesRègle
SH-SHEBANGminor-shScript without shebang (#!/bin/bash)
SH-STRICTminorforceshBash script without set -euo pipefail
SH-TESTnegligibleautosh[ ] test in a bash script, use [[ ]]