Skip to main content

Crate sql_dialect_fmt_lint

Crate sql_dialect_fmt_lint 

Source
Expand description

Lint rules for SQL, independent of any editor protocol.

lint (and its options/dialect-aware variants) checks source text against the SDF rule set and returns LintDiagnostics located at byte ranges, so the CLI can render path:line:col findings and the language server can convert them to LSP diagnostics without this crate ever depending on LSP types.

§Rules

coderule
SDF001SELECT * in a select list
SDF002large literal IN (...) list
SDF003unsupported embedded LANGUAGE ... AS $$...$$
SDF004DELETE without WHERE
SDF005UPDATE without WHERE
SDF006comma join in FROM (implicit cross join)
SDF007ORDER BY ordinal (e.g. ORDER BY 1)

§Suppression

A finding is suppressed by a line comment on the previous line:

-- sql-dialect-fmt: disable-next-line SDF001
SELECT * FROM t;

Omitting the code (or writing all/lint) suppresses every rule for the next line.

Structs§

LintDiagnostic
One lint finding, located at a byte range into the linted source text.
LintOptions
Lint knobs. Every rule is on by default; each can be disabled independently.

Enums§

Dialect
The SQL dialect a lex/parse/format request targets.
LintCode
The stable identity of a lint rule; rendered as SDFxxx via LintCode::as_str.
LintSeverity
How severe a finding is. Every current rule emits LintSeverity::Warning.

Functions§

lint
Lint text as Snowflake SQL with default LintOptions.
lint_with_dialect
Lint text as dialect, honoring options and suppression comments. Findings are sorted by source position.
lint_with_options
Lint text as Snowflake SQL with explicit options.