diff --git a/lua/lint/linters/rpmspec.lua b/lua/lint/linters/rpmspec.lua index 335c465f..8ca47d3a 100644 --- a/lua/lint/linters/rpmspec.lua +++ b/lua/lint/linters/rpmspec.lua @@ -5,7 +5,10 @@ local parsers = { [[(%w+): line (%d+): (.*)]], { 'severity', 'lnum', 'message' }, nil, - { ['severity'] = vim.diagnostic.severity.ERROR, ['source'] = 'rpmspec' } + { + severity = vim.diagnostic.severity.ERROR, + source = 'rpmspec' + } ), -- warnings @@ -13,7 +16,10 @@ local parsers = { [[(%w+): (.*) on line (%d+):]], { 'severity', 'message', 'lnum' }, nil, - { ['severity'] = vim.diagnostic.severity.WARNING, ['source'] = 'rpmspec' } + { + severity = vim.diagnostic.severity.WARN, + source = 'rpmspec' + } ), } @@ -27,13 +33,10 @@ return { ignore_exitcode = true, parser = function(output, bufnr) local diagnostics = {} - for _, parser in ipairs(parsers) do local result = parser(output, bufnr) - vim.list_extend(diagnostics, result) end - return diagnostics end, } diff --git a/tests/rpmspec_spec.lua b/tests/rpmspec_spec.lua index 3eceea9f..4c18643c 100644 --- a/tests/rpmspec_spec.lua +++ b/tests/rpmspec_spec.lua @@ -7,31 +7,27 @@ warning: Macro expanded in comment on line 1: %{?fedora} error: line 2: Unknown tag: %if ]] local result = parser(output, bufnr) - assert.are.same(2, #result) local expected_warning_1 = { col = 0, end_col = 0, - end_lnum = 1, - lnum = 1, + end_lnum = 0, + lnum = 0, message = 'Macro expanded in comment', - severity = 2, + severity = vim.diagnostic.severity.WARN, source = 'rpmspec', } - - assert.are.same(expected_warning_1, result[1]) - local expected_error_1 = { col = 0, end_col = 0, - end_lnum = 2, - lnum = 2, + end_lnum = 1, + lnum = 1, message = 'Unknown tag: %if', - severity = 1, + severity = vim.diagnostic.severity.ERROR, source = 'rpmspec', } - - assert.are.same(expected_error_1, result[2]) + assert.are.same(expected_error_1, result[1]) + assert.are.same(expected_warning_1, result[2]) end) end)