All Projects → pgjones → flake8-sql

pgjones / flake8-sql

Licence: MIT License
Flake8 plugin that checks SQL code against opinionated style rules

Programming Languages

python
139335 projects - #7 most used programming language

Labels

Projects that are alternatives of or similar to flake8-sql

flake8-functions
flake8 plugin for validation of function parameters (length, complexity, etc)
Stars: ✭ 32 (+28%)
Mutual labels:  flake8
dlint
Dlint is a tool for encouraging best coding practices and helping ensure Python code is secure.
Stars: ✭ 130 (+420%)
Mutual labels:  flake8
flake8-assertive
Flake8 unittest assert method checker
Stars: ✭ 30 (+20%)
Mutual labels:  flake8
python-lint
GitHub Action for Lint your code
Stars: ✭ 57 (+128%)
Mutual labels:  flake8
Wemake Python Styleguide
The strictest and most opinionated python linter ever!
Stars: ✭ 1,714 (+6756%)
Mutual labels:  flake8
flake8-annotations
Flake8 Type Annotation Checking
Stars: ✭ 117 (+368%)
Mutual labels:  flake8
flake8-broken-line
🚨 Flake8 plugin to forbid backslashes (\) for line breaks
Stars: ✭ 85 (+240%)
Mutual labels:  flake8
rubric
Linter Config Initializer for Python
Stars: ✭ 21 (-16%)
Mutual labels:  flake8
jira-sprint-analytics
No description or website provided.
Stars: ✭ 13 (-48%)
Mutual labels:  flake8
flake8-simplify
❄ A flake8 plugin that helps you to simplify code
Stars: ✭ 97 (+288%)
Mutual labels:  flake8
flake8-walrus
flake8 plugin which forbids assignment expressions (the walrus operator)
Stars: ✭ 36 (+44%)
Mutual labels:  flake8
Elements Of Python Style
Goes beyond PEP8 to discuss what makes Python code feel great. A Strunk & White for Python.
Stars: ✭ 3,308 (+13132%)
Mutual labels:  flake8
jupyterlab-flake8
Jupyterlab python linter for notebooks and text files using flake8
Stars: ✭ 105 (+320%)
Mutual labels:  flake8
flake8-cognitive-complexity
An extension for flake8 that validates cognitive functions complexity
Stars: ✭ 44 (+76%)
Mutual labels:  flake8
flake8-import-order-spoqa
Spoqa's import order style for flake8-import-order
Stars: ✭ 15 (-40%)
Mutual labels:  flake8
autoflake8
Tool to automatically fix some issues reported by flake8 (forked from autoflake).
Stars: ✭ 14 (-44%)
Mutual labels:  flake8
flake8-mypy
A plugin for flake8 integrating Mypy.
Stars: ✭ 103 (+312%)
Mutual labels:  flake8
flake8-docstrings
Integration of pydocstyle and flake8 for combined linting and reporting
Stars: ✭ 73 (+192%)
Mutual labels:  flake8
flake8-type-checking
Flake8 plugin for managing type-checking imports & forward references.
Stars: ✭ 38 (+52%)
Mutual labels:  flake8
google classroom
Google Classroom Data Pipeline
Stars: ✭ 17 (-32%)
Mutual labels:  flake8

Flake8-SQL

Build Status

Flake8-SQL is a flake8 plugin that looks for SQL queries and checks then against an opinionated style. This style mostly follows SQL Style Guide, but differ in the two following ways. Firstly alignement should be with the INTO rather than INSERT keyword, i.e.

INSERT INTO table (columns)
     VALUES (values)

Secondly JOIN should be aligned to the left of the river, i.e.

SELECT *
  FROM table1
  JOIN table2 ON ...

Warnings

Q440 Keyword is not uppercase

All the SQL reserved keywords should be uppercase.

Q441 Name is not valid

All the non SQL keywords should be snake_case, start with a letter and not end with an _. Due to a limitation snake_case is checks ensure that the word is lowercase.

Q442 Avoid abbreviated keywords

Avoid using abbreviated keywords instead use the full length version.

Q443 Incorrect whitespace around comma

Commas should be followed by whitespace, but not preceded.

Q444 Incorrect whitespace around equals

Equals should be surrounded with whitespace.

Q445 Missing linespace between root keywords

The root keywords SELECT, FROM, INSERT, VALUES, DELETE FROM, WHERE, UPDATE, AND, OR and SET should be on separate lines (unless the entire query is on one line).

Q446 Missing newline after semicolon

Semicolons must be at the end of the line.

Q447 Root keywords should be right aligned

The root keywords SELECT, FROM, INSERT, VALUES, WHERE, UPDATE, AND, OR, JOIN and SET should be right aligned i.e.

SELECT *
  FROM table

Q448 subquery should be aligned to the right of the river

Any subquery should be aligned to the right of the river i.e.

SELECT *
  FROM table
 WHERE column IN
       (SELECT column
          FROM table)

Q449 tokens should be aligned to the right of the river

Any tokens should be aligned to the right of the river i.e

SELECT column1,
       column2
  FROM table

Configuration

At times it is simpler to use a reserved keyword as an identifier than go to the effort to avoid it. To allow for this set the sql-excepted-names option to a comma separated list of these names.

Limitations

String constants are sought out in the code and considered SQL if they contain select from, insert into values, update set or delete from in order. This may and is likely to lead to false positives, in which case simply add # noqa to have this plugin ignore the string.

F-Strings are formatted with the formatted values, {...}, replaced with the constant formatted_value before being linted. This leads to the error message referring to formatted_value rather than what was actually written.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].