pgjones / flake8-sql

Flake8 plugin that checks SQL code against opinionated style rules

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Failed to run Flake8-sql

piusnig opened this issue · comments

Hey @pgjones, How do I run this plugin so that Linting can take place fo specifically SQL?

When I run using flake8 and put the rule e.g Q440 linting does not take place.

I have tried and searched around but failed to get the correct commands.

Can you please update the readme for guidance on this issue?

This linter will run over the files you run flake8 over there is nothing special to do after installing. This documentation may help.

I'm troubleshooting a different issue and made a quick test file that might be useful. Save this snippet as flake8_sql_check.py

"""Test of flake8-sql.

Test with: python -m flake8 flake8_sql_check.py

Which should output at a minimum:

flake8_sql_check.py:11:9: Q443 incorrect whitespace around comma
flake8_sql_check.py:12:9: Q443 incorrect whitespace around comma
flake8_sql_check.py:14:9: Q444 incorrect whitespace around equals
flake8_sql_check.py:15:9: Q444 incorrect whitespace around equals

If needed, check installed extensions with: python -m flake8 --bug-report

"""

# https://github.com/pgjones/flake8-sql/blob/0ed4d53dfed6d243254d9065646b17cf8f49708d/tests/test_cases/whitespace.py
query = "SELECT ca,cb FROM tbl"  # Q443
query = "SELECT ca ,cb FROM tbl"  # Q443
query = "SELECT ca, cb FROM tbl"
query = "SELECT ca FROM tbl WHERE ca= 'b'"  # Q444
query = "SELECT ca FROM tbl WHERE ca ='b'"  # Q444
query = "SELECT ca FROM tbl WHERE ca = 'b'"
query = "SELECT ca FROM tbl WHERE ca != 'b'"