Documentation
¶
Overview ¶
Package keywordcase reports PostgreSQL keywords that are not written in lowercase, per the gomatic SQL standard (keywords are lowercase; uppercase and title-case are the error). It tokenizes SQL with the shared gomatic/go-sql library — a thin wrapper over libpg_query, PostgreSQL's own lexer — and flags any keyword token whose text is not already its lowercase form. Quoted identifiers and keyword text inside string literals are not keyword tokens, so they are never flagged.
The scanner classifies keywords by table lookup, context-free, so an unquoted identifier that spells an unreserved or column-name keyword (a column named Version, say) scans as a keyword token. The parse tree disambiguates: tokens it proves to be identifiers are never flagged, and when a source does not parse as SQL at all only the reserved and type/function-name keyword classes — which can never be bare identifiers — are flagged.
Dollar-quoted string bodies ($$…$$), the fleet-standard form for function and DO bodies, are scanned recursively so the SQL inside them is held to the same standard; a body that is not lexable SQL (a PL/Python body, say) is skipped silently, and recursion stops after [nestingLimit] levels of dollar quoting.
Index ¶
Constants ¶
const Category = "sql"
Category is the language group this analyzer belongs to, used by the yze suite to run it only when processing SQL.
const ErrReadFile errs.Const = "cannot read SQL file"
ErrReadFile reports that a SQL source file could not be read.
const Name = "keywordcase"
Name is the analyzer's stable identifier — the suffix of its flat rule id and the key the yze suite catalogs it under.
const Rule = Tool + "/" + Name
Rule is the stable, flat rule id every diagnostic carries: "yze/" + Name.
const Tool = "yze"
Tool is the suite name stamped on every diagnostic. The analyzer is bundled into the yze suite (the language group lives in the repo path and Category, not the rule id), so it reports as "yze", not a separate "yze-sql" tool.
Variables ¶
This section is empty.
Functions ¶
func Diagnostics ¶
Diagnostics reports every keyword token in source whose text is not its canonical lowercase spelling. A lexical error scanning source is returned (wrapped in sql.ErrScan) so the caller can surface it as a tool failure rather than a clean pass. path is stamped on each diagnostic's location. Positions are computed in a single forward pass over source, so a file of any size costs O(n).
Types ¶
type FileReader ¶
FileReader reads a file's bytes; injected so aggregation is testable without the filesystem.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
yze-sql-keywordcase
command
Command yze-sql-keywordcase reports PostgreSQL keywords that are not written in lowercase in the given .sql files and directories, emitting the lean stickler-json report the stickler runner consumes.
|
Command yze-sql-keywordcase reports PostgreSQL keywords that are not written in lowercase in the given .sql files and directories, emitting the lean stickler-json report the stickler runner consumes. |