Skip to content

Lint rules

banshee ships 67 lint rules. Each has a dedicated page with the rationale, a before/after example, and how to configure or suppress it. Run banshee explain <CODE> for the same text on the command line.

CodeFixableDescription
AL01yesTable alias should be introduced with AS
AL02yesColumn alias should be introduced with AS
AL03—Complex select expression should be aliased
AL04—Duplicate table alias in one FROM
AL05—Table alias declared but never used
AL08—Duplicate column alias in a SELECT list
CodeFixableDescription
AM01—DISTINCT is redundant with GROUP BY
AM02—Set operators (UNION/EXCEPT/INTERSECT) should state ALL or DISTINCT
AM03—ORDER BY mixes explicit and implicit sort directions
AM04yesAvoid SELECT *; list columns explicitly (fix needs schema)
AM05—Implicit cross join; use an explicit JOIN clause
AM07—Set-operation branches select different column counts
AM09—LIMIT/OFFSET without ORDER BY is non-deterministic
CodeFixableDescription
CP01yesKeywords should be upper case
CP02yesUnquoted identifiers should be lower case
CodeFixableDescription
CV01yesUse <> instead of != for inequality
CV04yesUse count(*) instead of count(1)/count(0)
CV05yesCompare with NULL using IS NULL / IS NOT NULL
CV06yesStatements should end with a semicolon
CV08—Prefer LEFT JOIN over RIGHT JOIN
CV09—Use of a configured blocked word
CV10yesLIKE without a wildcard is just =
CV11—Inconsistent cast style within a statement
CV13yesIN with a single value is just =
CodeFixableDescription
JB01yesUse ->> when comparing a JSONB value to text
CodeFixableDescription
MG01yesCREATE INDEX without CONCURRENTLY locks the table
MG02yesADD CONSTRAINT (FK/CHECK) without NOT VALID validates under a lock
MG03—ADD COLUMN with a volatile DEFAULT rewrites the whole table
MG04—ADD COLUMN NOT NULL without a DEFAULT fails on a non-empty table
MG05—DROP COLUMN destroys data and breaks dependents
MG06—ALTER COLUMN TYPE rewrites the table under a lock
MG07—RENAME breaks code that refers to the old name
MG08—TRUNCATE … CASCADE empties dependent tables too
MG09yesPrefer text to char(n)/varchar(n)
MG10yesPrefer timestamptz to timestamp
MG11—Prefer bigint over a narrower integer for a primary key
MG12yesDROP INDEX without CONCURRENTLY locks the table
MG13—ADD PRIMARY KEY/UNIQUE builds its index under a lock
MG14—ALTER COLUMN SET NOT NULL scans the table under a lock
MG15—Prefer GENERATED … AS IDENTITY over serial
MG16—DROP TABLE destroys the table and its dependents
MG17—ALTER COLUMN DROP NOT NULL lets nulls into the column
MG18—DROP DATABASE destroys the whole database
MG19—CREATE INDEX CONCURRENTLY cannot run inside a transaction
MG20—Transaction opened but never committed or rolled back
MG21—BEGIN/START issued inside an open transaction
MG22—CREATE/DROP without IF [NOT] EXISTS is not idempotent
MG23—CREATE TABLE name is not schema-qualified
MG24—Identifier exceeds Postgres’s 63-byte limit
MG25—REINDEX without CONCURRENTLY locks the index for the rebuild
MG26—VACUUM FULL / CLUSTER rewrite the table under a lock
MG27—Lock-taking migration without statement/lock timeout
MG28—CREATE DOMAIN with a constraint is validated under a lock
MG29—ALTER DOMAIN ADD CONSTRAINT validates under a lock
MG30—DETACH PARTITION without CONCURRENTLY holds an exclusive lock
CodeFixableDescription
RF01—Reference to an unknown table, column or alias (needs schema)
RF02—Ambiguous column; qualify with a table name (needs schema)
RF03—Inconsistent column qualification in a single-table query
RF06yesIdentifier quoted unnecessarily
CodeFixableDescription
SF01—UPDATE can affect all rows
SF02—DELETE can affect all rows
SF03—INSERT without an explicit column list
CodeFixableDescription
ST01yesRedundant ELSE NULL in CASE
ST03—CTE is defined but never used
ST05—Subquery in FROM/JOIN; prefer a CTE
ST07—Avoid NATURAL JOIN
ST08—DISTINCT ON without ORDER BY is non-deterministic