fix(golangci-lint): incorrect filename concat preventing errors from being displayed (#4926)
Some checks failed
CI / build_image (push) Has been cancelled
CI / test_ale (--linters-only) (push) Has been cancelled
CI / test_ale (--neovim-07-only) (push) Has been cancelled
CI / test_ale (--neovim-08-only) (push) Has been cancelled
CI / test_ale (--vim-80-only) (push) Has been cancelled
CI / test_ale (--vim-90-only) (push) Has been cancelled

Signed-off-by: k4yt3x <i@k4yt3x.com>
This commit is contained in:
K4YT3X
2025-03-16 00:56:27 +00:00
committed by GitHub
parent 1c91102112
commit 995d78435a
2 changed files with 37 additions and 1 deletions

View File

@@ -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,

View File

@@ -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": ""',
\ ' }',
\ ' ]',
\ '}',
\ ])