diff --git a/ale_linters/go/golangci_lint.vim b/ale_linters/go/golangci_lint.vim index 5206bc52..faa8068b 100644 --- a/ale_linters/go/golangci_lint.vim +++ b/ale_linters/go/golangci_lint.vim @@ -45,7 +45,7 @@ function! ale_linters#go#golangci_lint#Handler(buffer, lines) abort endif call add(l:output, { - \ 'filename': ale#path#GetAbsPath(l:dir, l:match['Pos']['Filename']), + \ 'filename': ale#path#GetAbsPath(l:dir, fnamemodify(l:match['Pos']['Filename'], ':t')), \ 'lnum': l:match['Pos']['Line'] + 0, \ 'col': l:match['Pos']['Column'] + 0, \ 'type': l:msg_type, diff --git a/test/handler/test_golangci_lint_handler.vader b/test/handler/test_golangci_lint_handler.vader index 7ee3c822..34f51d78 100644 --- a/test/handler/test_golangci_lint_handler.vader +++ b/test/handler/test_golangci_lint_handler.vader @@ -108,3 +108,39 @@ Execute (The golangci-lint handler should handle only typecheck lines as errors) \ ' ]', \ '}', \ ]) + +Execute (The golangci-lint handler should set proper filename): + call ale#test#SetFilename('app/cmd/server/main.go') + + AssertEqual + \ [ + \ { + \ 'lnum': 198, + \ 'col': 19, + \ 'text': 'funlen - Function getConfig has too many statements (51 > 50)', + \ 'type': 'W', + \ 'filename': ale#path#Simplify(expand('%:p:h') . '/main.go'), + \ }, + \ ], + \ ale_linters#go#golangci_lint#Handler(bufnr(''), [ + \ '{', + \ ' "Issues": [', + \ ' {', + \ ' "FromLinter": "funlen",', + \ ' "Text": "Function getConfig has too many statements (51 > 50)",', + \ ' "Severity": "",', + \ ' "SourceLines": [', + \ ' "package main"', + \ ' ],', + \ ' "Pos": {', + \ ' "Filename": "cmd/server/main.go",', + \ ' "Offset": 5374,', + \ ' "Line": 198,', + \ ' "Column": 19', + \ ' },', + \ ' "ExpectNoLint": false,', + \ ' "ExpectedNoLintLinter": ""', + \ ' }', + \ ' ]', + \ '}', + \ ])