-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Relative paths handling is inconsistent between configuration options, hence unable to run golangci-lint from a subdirectory #3717
Labels
won't fix
This will not be worked on
Comments
Hello, we cannot change how the linters manage paths in their configuration: in the majority of cases, we just delegate the configuration to linters. Golangci-lint is a wrapper. |
ldez
added
won't fix
This will not be worked on
and removed
bug
Something isn't working
labels
Mar 23, 2023
|
misha-ridge
added a commit
to misha-ridge/golangci-lint-langserver
that referenced
this issue
Mar 23, 2023
golangci-lint has issues running in subdirectories of the project, e.g. golangci/golangci-lint#3656, golangci/golangci-lint#3717, so running it from the directory where configuration file is located is the only option for some projects. Make it work as an option, because not every project triggers this problem in golangci-lint, so for these projects overhead of looking up directory of config file and adjusting the paths after is not needed.
misha-ridge
added a commit
to misha-ridge/golangci-lint-langserver
that referenced
this issue
Mar 23, 2023
golangci-lint has issues running in subdirectories of the project, e.g. golangci/golangci-lint#3656, golangci/golangci-lint#3717, so running it from the directory where configuration file is located is the only option for some projects. Make it work as an option, because not every project triggers this problem in golangci-lint, so for these projects overhead of looking up directory of config file and adjusting the paths after is not needed.
14 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Welcome
Description of the problem
There are several places in
golangci-lint
where paths are specified, including:run.skip-dirs
pathsissues.exclude-rules.*.path
linters-settings.gocritic.ruleguard.rules
linters-settings.depguard.additional-guards.*.ignore-file-rules
custom.*.path
The handling of these paths is inconsistent, leading to various issues when
golangci-lint run
is run from the directory other than the one containing the.golangci-lint.yml
:run.skip-dirs
,issues.exclude-rules.*.path
are matched textually, so ifgolangci-lint run
is called from a subdirectory, these matches are silently skippedlinters-settings.gocritic.ruleguard.rules
accepts{configDir}
to make it look up proper ruleguard config file. However this directive does not seem to be accepted in any other places of the configuration file.linters-settings.depguard.additional-guards.*.ignore-file-rules
appear to match full file paths.custom.*.path
seem to always be relative to the configuration file, so at least this configuration works.As it stands, the only way to run
golangci-lint run
from a subdirectory is to avoid any paths in configuration file, exceptruleguard
and custom linters.It would be very useful to make all paths in configuration file behave the same. Treating them as relative to the location of the configuration file appears to be the most reasonable option.
There is already one issue for a specific case of path excludes: #1178, however this issue is more general.
Version of golangci-lint
golangci-lint has version v1.51.0 built from (unknown, mod sum: "h1:M1bpDymgdaPKNzPwQdebCGki/nzvVkr2f/eUfk9C9oU=") on (unknown)
Configuration file
The text was updated successfully, but these errors were encountered: