Rules¶
A rule is stable, preview (it runs only with preview = true), deprecated (it will be removed) or removed (documented for history).
architecture¶
How modules depend on each other: the layers and the direction of the imports.
| Code | Rule | Standard | Status | Added in | Default |
|---|---|---|---|---|---|
BTARCH001 |
import-layersA layer imports nothing of a layer above it imports |
CES-5 | stable | 0.12.0 | on |
BTARCH002 |
separate-orchestrationA function either orders the steps or does one of them design |
CES-8 | preview | 0.13.0 | off |
BTARCH003 |
architecture-vocabularyUnits are named with the architectural vocabulary of the house naming |
CES-16 | preview | 0.13.0 | off |
botica¶
What a run reports about itself: unreadable paths and suppression comments.
| Code | Rule | Standard | Status | Added in | Default |
|---|---|---|---|---|---|
BT001 |
io-errorA path given on the command line cannot be read |
stable | 0.7.0 | on | |
BT002 |
unused-suppressionA suppression comment that silences nothing |
stable | 0.7.0 | on | |
BT003 |
invalid-suppressionA suppression comment that names an unknown rule or is malformed |
stable | 0.7.0 | on | |
BT004 |
external-configThe file that an active external rule names holds the configuration of its tool |
stable | 0.10.0 | on |
cli¶
How command-line programs are written: the parser of the arguments.
| Code | Rule | Standard | Status | Added in | Default |
|---|---|---|---|---|---|
BTCLI001 |
cli-typed-frameworkCommand-line interfaces use a typed, declarative framework cli |
CES-67 | stable | 0.8.0 | on |
config¶
How a program reads its configuration: the settings module, its class and the schema of the environment.
| Code | Rule | Standard | Status | Added in | Default |
|---|---|---|---|---|---|
BTCONF001 |
settings-moduleEnvironment is read only in the settings module config |
CES-76 | stable | 0.8.0 | on |
BTCONF002 |
settings-base-classA settings class extends BaseSettings, not BaseModel config |
CES-76 | preview | 0.10.0 | off |
BTCONF003 |
settings-direct-instantiationSettings are read through get_settings(), never built where they are used config |
CES-76 | preview | 0.10.0 | off |
BTCONF004 |
settings-env-schemaThe variables of .env.schema and the fields of the settings classes match config |
CES-76 | stable | 0.12.0 | on |
data-models¶
Typed data at the boundaries: schemas, models, no raw dicts.
| Code | Rule | Standard | Status | Added in | Default |
|---|---|---|---|---|---|
BTDM001 |
no-dict-aliasNo type alias that hides a raw dict typing |
CES-79 | stable | 0.8.0 | on |
BTDM002 |
no-dict-call-returnNo function returning dict(...) typing |
CES-79 | stable | 0.8.0 | on |
BTDM003 |
no-dict-literal-returnNo function returning a dict literal typing |
CES-79 | stable | 0.8.0 | on |
BTDM004 |
no-dict-return-annotationNo function annotated to return a raw dict typing |
CES-79 | stable | 0.8.0 | on |
database¶
How code reaches a relational database: where the tables live and how the schema changes.
| Code | Rule | Standard | Status | Added in | Default |
|---|---|---|---|---|---|
BTDB001 |
database-packageRelational persistence lives in a database package layout |
CES-18 | stable | 0.8.0 | on |
BTDB002 |
db-no-create-allThe schema changes through migrations, not metadata.create_all() layout |
CES-18 | preview | 0.10.0 | off |
fastapi¶
Rules for FastAPI services.
| Code | Rule | Standard | Status | Added in | Default |
|---|---|---|---|---|---|
BTFAST001 |
api-schemas-extra-forbidRequest and response schemas reject unknown fields typing |
CES-4 | stable | 0.8.0 | on |
BTFAST002 |
api-schema-in-route-modulePydantic schemas are not defined in route modules typing |
CES-17 | preview | 0.10.0 | off |
BTFAST003 |
api-request-schema-nameRequest schemas are named {Name}Request typing |
CES-17 | preview | 0.10.0 | off |
BTFAST004 |
api-response-schema-nameResponse schemas are named {Name}Response typing |
CES-17 | preview | 0.10.0 | off |
logging¶
How code logs and what it must not print.
| Code | Rule | Standard | Status | Added in | Default |
|---|---|---|---|---|---|
BTLOG001 |
log-get-loggerLoggers come from the house get_logger logging |
CES-45 | stable | 0.8.0 | on |
BTLOG002 |
log-no-printLibraries log, they don't print logging |
CES-46 | stable | 0.8.0 | on |
process¶
How changes are made: the scope of a pull request and its commits.
| Code | Rule | Standard | Status | Added in | Default |
|---|---|---|---|---|---|
BTPROC001 |
pr-small-by-intentA pull request carries one intent review |
CES-122 | preview | 0.13.0 | off |
BTPROC002 |
respect-local-repoA change keeps the deliberate choices of the repository review |
CES-30 | preview | 0.13.0 | off |
BTPROC003 |
conventional-commitsEvery commit subject follows Conventional Commits commits |
CES-75 | preview | 0.14.0 | off |
BTPROC004 |
no-ai-coauthorshipA commit message names no AI tool as a co-author or as the author of the change commits |
CES-91 | preview | 0.14.0 | off |
security¶
How code handles credentials: who checks them, how a token is decoded and where the browser keeps it.
| Code | Rule | Standard | Status | Added in | Default |
|---|---|---|---|---|---|
BTSEC001 |
route-authEach route gets its caller from a dependency that verifies a credential auth, fastapi |
CES-121 | preview | 0.13.0 | off |
BTSEC002 |
jwt-verifiedA decoded token has its signature and its expiry checked auth, jwt |
CES-121 | preview | 0.13.0 | off |
BTSEC003 |
no-token-in-web-storageThe browser keeps no credential in web storage auth, browser |
CES-121 | preview | 0.13.0 | off |
structure¶
Where code lives and how big it gets: file size, module naming, repository layout.
| Code | Rule | Standard | Status | Added in | Default |
|---|---|---|---|---|---|
BTSTRUC001 |
file-size-guardKeep source files small size |
CES-71 | stable | 0.7.0 | on |
BTSTRUC002 |
no-utilsNo catch-all modules naming |
CES-63 | stable | 0.7.0 | on |
BTSTRUC003 |
no-artifacts-in-packageKeep data, models and reports outside the code layout |
CES-32 | stable | 0.7.0 | on |
BTSTRUC004 |
no-notebooksKeep Jupyter notebooks outside the code layout |
CES-32 | stable | 0.7.0 | on |
BTSTRUC005 |
no-tests-in-packageKeep tests beside the package, not in it layout |
CES-32 | stable | 0.7.0 | on |
BTSTRUC006 |
cognitive-complexityA function has a cognitive complexity of at most 15 complexity |
CES-110 | preview | 0.10.0 | off |
BTSTRUC007 |
lockfile-committedEach manifest has the lockfile of one package manager, committed dependencies |
CES-109 | preview | 0.13.0 | off |
testing¶
How tests are written and run.
| Code | Rule | Standard | Status | Added in | Default |
|---|---|---|---|---|---|
BTTEST001 |
test-in-memory-adaptersTests drive the logic through in-memory adapters, not mocks tests |
CES-64 | preview | 0.13.0 | off |
BTTEST002 |
test-through-interfaceTests assert on behaviour through the public interface tests |
CES-65 | preview | 0.13.0 | off |
BTTEST003 |
test-coverage-gapA coverage gap is closed with a test that asserts a behaviour tests, coverage |
CES-66 | preview | 0.13.0 | off |
BTTEST004 |
no-coverage-pragmaNo # pragma: no cover hides code from the coverage reporttests, coverage |
CES-66 | preview | 0.14.0 | off |
BTTEST005 |
no-coverage-exclusionThe configuration of coverage leaves no code out of the report and keeps its threshold tests, coverage |
CES-66 | preview | 0.14.0 | off |
BTTEST006 |
coverage-exclusion-reachableCoverage leaves out only code that no test can reach tests, coverage |
CES-66 | preview | 0.14.0 | off |
tooling¶
How the tools that check the code are configured: what keeps them on.
| Code | Rule | Standard | Status | Added in | Default |
|---|---|---|---|---|---|
BTTOOL001 |
no-disabled-typecheckThe type checker stays on for the whole build and every file types |
CES-58 | preview | 0.13.0 | off |
writing¶
How text is written: documentation, commit messages, comments and the terms of the domain.
| Code | Rule | Standard | Status | Added in | Default |
|---|---|---|---|---|---|
BTWRIT001 |
plain-writingText has none of the signs of model writing writing |
CES-120 | preview | 0.13.0 | off |
BTWRIT002 |
minimal-commentsA comment says only what the code cannot writing |
CES-120 | preview | 0.13.0 | off |
BTWRIT003 |
ubiquitous-languageOne term per concept of the domain, the one of the glossary writing |
CES-120 | preview | 0.13.0 | off |