-
Notifications
You must be signed in to change notification settings - Fork 787
fix(builtins): set correct golangci_lint cwd #1206
base: main
Are you sure you want to change the base?
fix(builtins): set correct golangci_lint cwd #1206
Conversation
@@ -34,7 +36,8 @@ return h.make_builtin({ | |||
local issues = params.output["Issues"] | |||
if type(issues) == "table" then | |||
for _, d in ipairs(issues) do | |||
if d.Pos.Filename == params.bufname then | |||
local fname = params.cwd .. "/" .. d.Pos.Filename |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doing this here instead of using --path-prefix
so it's easier for consumers to modify the args with .with({ args
(or is there a way to retrieve (resolved) .cwd
from .with(
?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this not working, or did the other change make this one necessary? Either way I think this is fine, though we'll want to use the join_path
utility (example) to guarantee consistency.
@@ -16,14 +16,16 @@ return h.make_builtin({ | |||
to_stdin = true, | |||
from_stderr = false, | |||
ignore_stderr = true, | |||
cwd = function(params) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not a huge deal, since this linter runs (relatively) infrequently, but if we don't expect this result to change, I think we want to cache this to avoid repeated lookups. You may also want to consider using the root_pattern
utility. This builtin has an example of both.
@@ -34,7 +36,8 @@ return h.make_builtin({ | |||
local issues = params.output["Issues"] | |||
if type(issues) == "table" then | |||
for _, d in ipairs(issues) do | |||
if d.Pos.Filename == params.bufname then | |||
local fname = params.cwd .. "/" .. d.Pos.Filename |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this not working, or did the other change make this one necessary? Either way I think this is fine, though we'll want to use the join_path
utility (example) to guarantee consistency.
d34f699
to
f868cb5
Compare
f868cb5
to
6f81824
Compare
I discovered this issue working on https://github.com/marcelbeumer/go-playground/tree/main/gochat (with cwd being
gochat
).golintci_lint was running from the
$ROOT
, which, if I understand correctly, is set the the dir containing.git
, by default. I think it should run in a root appropriate for the file being saved (in this case the dirgochat
containinggo.mod
).I imagine it's a standard pattern to "find the correct root" for the current buffer, so if there's a better way to do this (using null-ls helpers/utils for example) let me know!