Summary
Add a rule to detect inconsistent casing of SQL keywords within a single query (e.g., mixing SELECT with from or Where).
Why This Matters
Consistent keyword casing is a code quality issue:
- Readability — mixed case is visually jarring and harder to scan
- Team standards — inconsistency suggests lack of formatting discipline
- Professional appearance — code reviews flag this immediately
- Maintenance — consistent style makes patterns easier to recognize
The Professional Standard
Most SQL style guides recommend one of:
-
UPPERCASE keywords (most common in enterprise)
SELECT id, name FROM users WHERE status = 'active' ORDER BY name;
-
lowercase keywords (common in modern tooling)
select id, name from users where status = 'active' order by name;
Both are valid — but mixing them is not:
-- This is ugly and unprofessional:
SELECT id, name from Users WHERE status = 'active' Order By name;
Rule Specification
| Property |
Value |
| Rule ID |
STYLE003 |
| Name |
Inconsistent keyword case |
| Category |
Style |
| Severity |
Info |
| Default |
Enabled |
Detection Patterns
-- Should trigger (mixed case)
SELECT id FROM users where status = 'active';
select * From orders WHERE id = 1;
SELECT name, Select email FROM users; -- even worse
-- Should NOT trigger (consistent)
SELECT * FROM users WHERE id = 1;
select * from users where id = 1;
Keywords to Check
Primary: SELECT, FROM, WHERE, JOIN, LEFT, RIGHT, INNER, OUTER, ON, AND, OR, NOT, IN, ORDER, BY, GROUP, HAVING, LIMIT, OFFSET, INSERT, INTO, VALUES, UPDATE, SET, DELETE, CREATE, ALTER, DROP, TABLE, INDEX, AS, DISTINCT, UNION, ALL, BETWEEN, LIKE, IS, NULL, EXISTS, CASE, WHEN, THEN, ELSE, END
Suggested Message
"Inconsistent SQL keyword casing: found both 'SELECT' and 'from'. Use consistent case for all keywords (either UPPERCASE or lowercase) for better readability."
References
Implementation Notes
- Extract all SQL keywords from query
- Check if all are uppercase, all lowercase, or mixed
- Consider: PascalCase identifiers (table/column names) are fine
- Mixed case = trigger rule
- Don't flag: quoted identifiers, string literals
- Configurable: preferred style (UPPER vs lower) as optional enforcement
Summary
Add a rule to detect inconsistent casing of SQL keywords within a single query (e.g., mixing
SELECTwithfromorWhere).Why This Matters
Consistent keyword casing is a code quality issue:
The Professional Standard
Most SQL style guides recommend one of:
UPPERCASE keywords (most common in enterprise)
lowercase keywords (common in modern tooling)
Both are valid — but mixing them is not:
Rule Specification
STYLE003Detection Patterns
Keywords to Check
Primary:
SELECT,FROM,WHERE,JOIN,LEFT,RIGHT,INNER,OUTER,ON,AND,OR,NOT,IN,ORDER,BY,GROUP,HAVING,LIMIT,OFFSET,INSERT,INTO,VALUES,UPDATE,SET,DELETE,CREATE,ALTER,DROP,TABLE,INDEX,AS,DISTINCT,UNION,ALL,BETWEEN,LIKE,IS,NULL,EXISTS,CASE,WHEN,THEN,ELSE,ENDSuggested Message
References
Implementation Notes