-
-
Notifications
You must be signed in to change notification settings - Fork 210
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
1 parent
0efe84e
commit 3683676
Showing
3 changed files
with
115 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
local severity = { | ||
['W'] = vim.diagnostic.severity.WARN, | ||
['E'] = vim.diagnostic.severity.ERROR, | ||
} | ||
|
||
local parsers = { | ||
require('lint.parser').from_pattern( | ||
'warning: line (%d+): (.*)', | ||
{ 'lnum', 'message' }, | ||
nil, | ||
{ | ||
severity = vim.diagnostic.severity.WARN, | ||
source = 'rpmlint' | ||
} | ||
), | ||
|
||
require('lint.parser').from_pattern( | ||
'.*:(%d+): ([W|E]): (.*)', | ||
{ 'lnum', 'severity', 'message' }, | ||
severity, | ||
{ | ||
severity = vim.diagnostic.severity.WARN, | ||
source = 'rpmlint' | ||
} | ||
), | ||
|
||
require('lint.parser').from_pattern( | ||
'.*: E: .*: line (%d+): (.*)', | ||
{ 'lnum', 'message' }, | ||
nil, | ||
{ | ||
severity = vim.diagnostic.severity.ERROR, | ||
source = 'rpmlint' | ||
} | ||
), | ||
|
||
} | ||
|
||
return { | ||
cmd = 'rpmlint', | ||
stdin = false, | ||
append_fname = true, | ||
args = {}, | ||
stream = 'both', | ||
ignore_exitcode = true, | ||
parser = function(output, bufnr, cwd) | ||
local diagnostics = {} | ||
for _, parser in ipairs(parsers) do | ||
local result = parser(output, bufnr, cwd) | ||
vim.list_extend(diagnostics, result) | ||
end | ||
return diagnostics | ||
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,59 @@ | ||
describe('linter.rpmlint', function() | ||
it('can parse the output', function() | ||
local parser = require('lint.linters.rpmlint').parser | ||
local bufnr = vim.uri_to_bufnr('file:///foo.spec') | ||
local output = [[ | ||
warning: line 162: It's not recommended to have unversioned Obsoletes | ||
foo.spec:17: W: %autopatch-not-in-prep | ||
foo.spec: E: specfile-error error: line 31: Unknown tag: %escription | ||
foo.spec:9: E: buildprereq-use Something | ||
]] | ||
local result = parser(output, bufnr) | ||
assert.are.same(4, #result) | ||
|
||
local expected_warning_1 = { | ||
col = 0, | ||
end_col = 0, | ||
end_lnum = 161, | ||
lnum = 161, | ||
message = "It's not recommended to have unversioned Obsoletes", | ||
severity = vim.diagnostic.severity.WARN, | ||
source = 'rpmlint', | ||
} | ||
|
||
local expected_warning_2 = { | ||
col = 0, | ||
end_col = 0, | ||
end_lnum = 16, | ||
lnum = 16, | ||
message = '%autopatch-not-in-prep', | ||
severity = vim.diagnostic.severity.WARN, | ||
source = 'rpmlint', | ||
} | ||
|
||
local expected_error_1 = { | ||
col = 0, | ||
end_col = 0, | ||
end_lnum = 30, | ||
lnum = 30, | ||
message = 'Unknown tag: %escription', | ||
severity = vim.diagnostic.severity.ERROR, | ||
source = 'rpmlint', | ||
} | ||
|
||
local expected_error_2 = { | ||
col = 0, | ||
end_col = 0, | ||
end_lnum = 8, | ||
lnum = 8, | ||
message = 'buildprereq-use Something', | ||
severity = vim.diagnostic.severity.ERROR, | ||
source = 'rpmlint', | ||
} | ||
|
||
assert.are.same(expected_warning_1, result[1]) | ||
assert.are.same(expected_warning_2, result[2]) | ||
assert.are.same(expected_error_1, result[4]) | ||
assert.are.same(expected_error_2, result[3]) | ||
end) | ||
end) |