Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

All Rules

36 rules across 8 categories. Fixable rules are marked — run --fix to apply them automatically.

Capitalisation

IDDescriptionFixable
CP01Keywords must be lowercase
CP02Unquoted identifiers must be lowercase
CP03Function names must be lowercase
CP04Boolean/null literals must be lowercase
CP05Data type names must be lowercase

Layout

IDDescriptionFixable
LT01No space before comma; no consecutive mid-line spaces; no space between function and (
LT02Indentation must use spaces, multiple of 4
LT03No trailing whitespace on lines
LT05Lines must not exceed max_line_length (default 120)
LT06No space between function name and (
LT07CTE closing ) must be on its own line
LT08Blank line required after each CTE closing )
LT09Clauses in standard order: SELECT → FROM → WHERE → GROUP BY → HAVING → ORDER BY → LIMIT
LT10DISTINCT/ALL must be on the same line as SELECT
LT11Set operators (UNION, INTERSECT, EXCEPT) must be on their own line
LT12File must end with exactly one trailing newline

Convention

IDDescriptionFixable
CV03Trailing comma policy in SELECT clauses
CV04Consistent row-counting syntax: COUNT(*) vs COUNT(1)
CV05NULL comparisons must use IS NULL / IS NOT NULL
CV10Identifiers must use a consistent quoting style within a file

Aliasing

IDDescriptionFixable
AL02Column aliases must use explicit AS keyword
AL03Expressions in SELECT must have an alias
AL04Table aliases must be unique within a query
AL05Table aliases that are defined but never referenced
AL06Table alias length must be within configured bounds
AL08Column aliases in SELECT must be unique (case-insensitive)
AL09A column must not be aliased to itself (col AS col)

Ambiguous

IDDescriptionFixable
AM01SELECT DISTINCT with GROUP BY is redundant
AM02UNION must be followed by ALL or DISTINCT
AM05Implicit comma joins are forbidden; use explicit JOIN
AM06GROUP BY / ORDER BY must use a consistent reference style

References

IDDescriptionFixable
RF01Qualified column references must use a known table alias
RF02Wildcard (SELECT *) is not allowed; list columns explicitly

Structure

IDDescriptionFixable
ST03CTEs that are defined but never referenced
ST08COUNT(DISTINCT *) is not valid SQL

Jinja

IDDescriptionFixable
JJ01Jinja tags must have single-space padding inside delimiters