Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sql: add maker for sqlfluff #2500

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sethwoodworth
Copy link

@sethwoodworth sethwoodworth commented Aug 4, 2020

I'm hoping to add a maker for an alternate sql linter named sqlfluff.

I'm new to vim's errorformat and got a partially working &efm for sqlfluff's default output format.

@blueyed seems really responsive and helpful in PRs, so I am hoping to get some feedback and get this PR working and tested!

Questions:

  1. sqlfluff takes a --dialect argument. Is there an example maker I could reference for providing a config option for this?
  2. sqlfluff has three output format options: human, json, & yaml, my &efm is attempting to match the human output format as I wanted to avoid multi-line errorformats, and json doesn't have line breaks. But after getting message-continuations working, I suspect yaml would be easier than the human format. Suggestions? I can provide example output.
  3. sqlfluff has error codes of PRS and L003 the efm of %t%n breaks when the error code is PRS. How should I handle this case?

Here is an example snippet of the human format output:

== [models/redacted/foobie_bletch.sql] FAIL
L:   6 | P: 101 | L016 | Line is too long.
L:   8 | P: 112 | L016 | Line is too long.
L:  10 | P:   3 | L003 | Indentation not hanging or a multiple of 4 spaces
L:  11 | P:   3 | L003 | Indentation not hanging or a multiple of 4 spaces
L:  12 | P:   3 | L003 | Indentation not hanging or a multiple of 4 spaces
L:  13 | P:   3 | L003 | Indentation not hanging or a multiple of 4 spaces
L:  14 | P:   3 | L003 | Indentation not hanging or a multiple of 4 spaces
L:  15 | P:   3 | L003 | Indentation not hanging or a multiple of 4 spaces
L:  16 | P:   3 | L003 | Indentation not hanging or a multiple of 4 spaces
L:  17 | P:  47 | L011 | Implicit aliasing of table not allowed. Use explicit
                       | `AS` clause.
L:  18 | P:  63 | L011 | Implicit aliasing of table not allowed. Use explicit
                       | `AS` clause.
L:  19 | P:   3 | L003 | Indentation not hanging or a multiple of 4 spaces
L:  19 | P:  45 |  PRS | Found unparsable section: '\n-- need this because there
                       | can be multi...'

@sethwoodworth
Copy link
Author

I took a pass at parsing the YAML output format and am having similar issues:
let &efm='-\ filepath:\ %f,%E\ \ - code: %t%n,%C\ %#line_no:\ %l,%C\ %#%l,%C\ %#line_pos:\ %c,%C\ %#description:\ %m,%C\ \ \ \ \ \ %m'

On input of:

- filepath: models/foobie/applications_a.sql
  violations:
  - code: PRS
    line_no: 19
    line_pos: 45
    description: 'Found unparsable section: ''\n-- need this because there can be
      multi...'''
  - code: L003
    line_no: 10
    line_pos: 3
    description: Indentation not hanging or a multiple of 4 spaces
  - code: L003
    line_no: 11
    line_pos: 3
    description: Indentation not hanging or a multiple of 4 spaces
  - code: L003
    line_no: 12
    line_pos: 3
    description: Indentation not hanging or a multiple of 4 spaces
  - code: L003
    line_no: 13
    line_pos: 3
    description: Indentation not hanging or a multiple of 4 spaces
  - code: L003
    line_no: 14
    line_pos: 3
    description: Indentation not hanging or a multiple of 4 spaces
  - code: L003
    line_no: 15
    line_pos: 3
    description: Indentation not hanging or a multiple of 4 spaces
  - code: L003
    line_no: 16
    line_pos: 3
    description: Indentation not hanging or a multiple of 4 spaces
  - code: L003
    line_no: 19
    line_pos: 3
    description: Indentation not hanging or a multiple of 4 spaces
  - code: L011
    line_no: 17
    line_pos: 47
    description: Implicit aliasing of table not allowed. Use explicit `AS` clause.
  - code: L011
    line_no: 18
    line_pos: 63
    description: Implicit aliasing of table not allowed. Use explicit `AS` clause.
  - code: L016
    line_no: 6
    line_pos: 101
    description: Line is too long.
  - code: L016
    line_no: 8
    line_pos: 112
    description: Line is too long.

@sethwoodworth sethwoodworth marked this pull request as draft August 5, 2020 16:56
@FelipeLema
Copy link

for anyone interested: I made a wrapper on sqlfluff that can be used with neomake. it prints one error per line

https://codeberg.org/FelipeLema/sqlfluff-oneliner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants