-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into add-gofumpt
- Loading branch information
Showing
9 changed files
with
254 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
local lint = require('guard.lint') | ||
|
||
return { | ||
cmd = 'sqlfluff', | ||
args = { 'lint', '-f', 'github-annotation' }, | ||
stdin = true, | ||
parse = lint.from_json({ | ||
attributes = { | ||
row = 'line', | ||
col = 'start_column', | ||
end_col = 'end_column', | ||
severity = 'annotation_level', | ||
message = 'message', | ||
}, | ||
severities = { | ||
notice = lint.severities.info, | ||
warning = lint.severities.warning, | ||
error = lint.severities.error, | ||
}, | ||
source = 'sqlfluff', | ||
}), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
describe('sqlfluff_fix', function() | ||
it('can format', function() | ||
local ft = require('guard.filetype') | ||
local tool = ft('sql'):fmt('sqlfluff_fix') | ||
tool.formatter[1].args = vim.list_extend(tool.formatter[1].args, { '--dialect', 'ansi' }) | ||
require('guard').setup() | ||
|
||
local formatted = require('test.formatter.helper').test_with('sql', { | ||
[[SELECT]], | ||
[[ a + b AS foo,]], | ||
[[ c AS bar]], | ||
[[FROM my_table]], | ||
}) | ||
assert.are.same({ | ||
[[SELECT]], | ||
[[ c AS bar,]], | ||
[[ a + b AS foo]], | ||
[[FROM my_table]], | ||
}, formatted) | ||
end) | ||
end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
describe('sqlfluff', function() | ||
it('can format', function() | ||
local ft = require('guard.filetype') | ||
local tool = ft('sql'):fmt('sqlfluff') | ||
tool.formatter[1].args = vim.list_extend(tool.formatter[1].args,{ '--dialect', 'ansi' }) | ||
require('guard').setup() | ||
|
||
local formatted = require('test.formatter.helper').test_with('sql', { | ||
[[SELECT *]], | ||
[[FROM]], | ||
[[ World ]], | ||
[[WHERE "Someone"]], | ||
[[ LIKE '%YOU%']], | ||
}) | ||
assert.are.same({ | ||
[[SELECT *]], | ||
[[FROM]], | ||
[[ World]], | ||
[[WHERE]], | ||
[[ "Someone"]], | ||
[[ LIKE '%YOU%']], | ||
}, formatted) | ||
end) | ||
end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
describe('taplo', function() | ||
it('can format', function() | ||
local ft = require('guard.filetype') | ||
ft('toml'):fmt('taplo') | ||
require('guard').setup() | ||
|
||
local formatted = require('test.formatter.helper').test_with('toml', { | ||
[[ [dependencies] ]], | ||
[[ async-process = "^1.7"]], | ||
[[strum = { version = "^0.25", features = ["derive"] } ]], | ||
[[anyhow = "1" ]], | ||
[[tracing-error = "0.2" ]], | ||
[[]], | ||
[[]], | ||
}) | ||
assert.are.same({ | ||
'[dependencies]', | ||
[[async-process = "^1.7"]], | ||
[[strum = { version = "^0.25", features = ["derive"] }]], | ||
[[anyhow = "1"]], | ||
[[tracing-error = "0.2"]], | ||
}, formatted) | ||
end) | ||
end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
describe('sqlfluff', function() | ||
it('can lint', function() | ||
local helper = require('test.linter.helper') | ||
local ft = require('guard.filetype') | ||
local tool = ft('sql'):lint('sqlfluff') | ||
tool.linter[1].args = vim.list_extend(tool.linter[1].args, { '--dialect', 'ansi' }) | ||
require('guard').setup() | ||
|
||
local diagnostics = helper.test_with('sql', { | ||
[[SELECT a+b AS foo,]], | ||
[[c AS bar from my_table]], | ||
}) | ||
assert.are.same({ | ||
{ | ||
bufnr = 3, | ||
col = 0, | ||
end_col = 0, | ||
end_lnum = 0, | ||
lnum = 0, | ||
message = 'LT09: Select targets should be on a new line unless there is only one select target. [nil]', | ||
namespace = 1, | ||
severity = 3, | ||
source = 'sqlfluff', | ||
}, | ||
{ | ||
bufnr = 3, | ||
col = 0, | ||
end_col = 0, | ||
end_lnum = 0, | ||
lnum = 0, | ||
message = 'ST06: Select wildcards then simple targets before calculations and aggregates. [nil]', | ||
namespace = 1, | ||
severity = 3, | ||
source = 'sqlfluff', | ||
}, | ||
{ | ||
bufnr = 3, | ||
col = 6, | ||
end_col = 6, | ||
end_lnum = 0, | ||
lnum = 0, | ||
message = "LT02: Expected line break and indent of 4 spaces before 'a'. [nil]", | ||
namespace = 1, | ||
severity = 3, | ||
source = 'sqlfluff', | ||
}, | ||
{ | ||
bufnr = 3, | ||
col = 8, | ||
end_col = 8, | ||
end_lnum = 0, | ||
lnum = 0, | ||
message = "LT01: Expected single whitespace between naked identifier and binary operator '+'. [nil]", | ||
namespace = 1, | ||
severity = 3, | ||
source = 'sqlfluff', | ||
}, | ||
{ | ||
bufnr = 3, | ||
col = 9, | ||
end_col = 9, | ||
end_lnum = 0, | ||
lnum = 0, | ||
message = "LT01: Expected single whitespace between binary operator '+' and naked identifier. [nil]", | ||
namespace = 1, | ||
severity = 3, | ||
source = 'sqlfluff', | ||
}, | ||
{ | ||
bufnr = 3, | ||
col = 10, | ||
end_col = 10, | ||
end_lnum = 0, | ||
lnum = 0, | ||
message = "LT01: Expected only single space before 'AS' keyword. Found ' '. [nil]", | ||
namespace = 1, | ||
severity = 3, | ||
source = 'sqlfluff', | ||
}, | ||
{ | ||
bufnr = 3, | ||
col = 0, | ||
end_col = 0, | ||
end_lnum = 1, | ||
lnum = 1, | ||
message = 'LT02: Expected indent of 4 spaces. [nil]', | ||
namespace = 1, | ||
severity = 3, | ||
source = 'sqlfluff', | ||
}, | ||
{ | ||
bufnr = 3, | ||
col = 8, | ||
end_col = 8, | ||
end_lnum = 1, | ||
lnum = 1, | ||
message = "LT02: Expected line break and no indent before 'from'. [nil]", | ||
namespace = 1, | ||
severity = 3, | ||
source = 'sqlfluff', | ||
}, | ||
{ | ||
bufnr = 3, | ||
col = 9, | ||
end_col = 9, | ||
end_lnum = 1, | ||
lnum = 1, | ||
message = 'CP01: Keywords must be consistently upper case. [nil]', | ||
namespace = 1, | ||
severity = 3, | ||
source = 'sqlfluff', | ||
}, | ||
}, diagnostics) | ||
end) | ||
end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters