forked from nvimdev/guard-collection
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
126 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
local lint = require('guard.lint') | ||
|
||
return { | ||
cmd = 'flake8', | ||
args = { '--format', 'default', '-', '--stdin-display-name' }, | ||
stdin = true, | ||
fname = true, | ||
parse = lint.from_regex({ | ||
source = 'flake8', | ||
regex = ':(%d+):(%d+):%s(%a)(%w+) (.+)', | ||
severities = { | ||
E = lint.severities.error, | ||
W = lint.severities.warning, | ||
C = lint.severities.warning, | ||
F = lint.severities.info, | ||
}, | ||
}), | ||
} |
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,106 @@ | ||
describe('flake8', function() | ||
it('can lint', function() | ||
local ft = require('guard.filetype') | ||
ft('python'):lint('flake8') | ||
require('guard').setup() | ||
|
||
local diagnostics = require('test.linter.helper').test_with('python', { | ||
[[import os]], | ||
[[]], | ||
[[def foo(n):]], | ||
[[ if n == 0:]], | ||
[[ return bar]], | ||
[[print("it's too long sentence to be displayed in one line, blah blah blah blah")]], | ||
}) | ||
assert.are.same({ | ||
{ | ||
bufnr = 3, | ||
col = 0, | ||
end_col = 0, | ||
end_lnum = 0, | ||
lnum = 0, | ||
message = "'os' imported but unused [401]", | ||
namespace = 4, | ||
severity = 3, | ||
source = 'flake8', | ||
}, | ||
{ | ||
bufnr = 3, | ||
col = 0, | ||
end_col = 0, | ||
end_lnum = 2, | ||
lnum = 2, | ||
message = 'expected 2 blank lines, found 1 [302]', | ||
namespace = 4, | ||
severity = 1, | ||
source = 'flake8', | ||
}, | ||
{ | ||
bufnr = 3, | ||
col = 9, | ||
end_col = 9, | ||
end_lnum = 4, | ||
lnum = 4, | ||
message = 'indentation is not a multiple of 4 [111]', | ||
namespace = 4, | ||
severity = 1, | ||
source = 'flake8', | ||
}, | ||
{ | ||
bufnr = 3, | ||
col = 9, | ||
end_col = 9, | ||
end_lnum = 4, | ||
lnum = 4, | ||
message = 'over-indented [117]', | ||
namespace = 4, | ||
severity = 1, | ||
source = 'flake8', | ||
}, | ||
{ | ||
bufnr = 3, | ||
col = 15, | ||
end_col = 15, | ||
end_lnum = 4, | ||
lnum = 4, | ||
message = 'multiple spaces after keyword [271]', | ||
namespace = 4, | ||
severity = 1, | ||
source = 'flake8', | ||
}, | ||
{ | ||
bufnr = 3, | ||
col = 17, | ||
end_col = 17, | ||
end_lnum = 4, | ||
lnum = 4, | ||
message = "undefined name 'bar' [821]", | ||
namespace = 4, | ||
severity = 3, | ||
source = 'flake8', | ||
}, | ||
{ | ||
bufnr = 3, | ||
col = 0, | ||
end_col = 0, | ||
end_lnum = 5, | ||
lnum = 5, | ||
message = 'expected 2 blank lines after class or function definition, found 0 [305]', | ||
namespace = 4, | ||
severity = 1, | ||
source = 'flake8', | ||
}, | ||
{ | ||
bufnr = 3, | ||
col = 79, | ||
end_col = 79, | ||
end_lnum = 5, | ||
lnum = 5, | ||
message = 'line too long (80 > 79 characters) [501]', | ||
namespace = 4, | ||
severity = 1, | ||
source = 'flake8', | ||
}, | ||
}, 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