-
-
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
feat: new linter exclusions system #5339
Conversation
aed5c27
to
a96fcf4
Compare
8a37c87
to
a2516ac
Compare
3fa2ebb
to
7748b59
Compare
@bombsimon @alexandear Can I do something to ease the review? |
Sorry for slow review! I don't think so, mostly just ben busy and given your very thorough research on this topic in the issue (thanks for that amazing work) I wanted to also catch up with all your findings to better understand these changes. I'll try to get to this asap during the week! |
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.
LGTM, good stuff!
f5a67ef
to
3faf3af
Compare
I'm so excited to merge this PR, I know this is mainly internals but I spend a lot of time on it, and the next PR (I will open it 1 minute after the merge of this one) will add the |
This PR is a part of the v2: #5300
Important
This PR deliberately omits documentation about the new options and section (but the JSONSchema is updated).
This is because I don't want to deprecate the previous section for now: I think it is better to handle that when all the v2 proposals are managed to avoid multiple migrations.
The main goal is to replace
issue.exclude-xxx
options withlinters.exclusions
section.There is a new option
linters.exclusions.warn-unused
that emits a warning if alinters.exclusions.rules
orlinters.exclusions.paths
is unused.There is a new option
run.relative-path-mode
with 4 modes:gomod
: paths are relative to thego.mod
gitroot
: paths are relative to the git root.cfg
: paths are relative to the configuration position.wd
(v1 default): paths are relative to the location where golangci-lint is run.This option controls all the path-related options:
issues.exclude-rules[].path
issues.exclude-rules[].path-except
issues.exclude-dirs
issues.exclude-files
severity.rules[].path
severity.rules[].path-except
custom[].path
linters.exclusions.paths
linters.exclusions.paths-except
linters.exclusions.rules[].path
linters.exclusions.rules[].path-except
The linter configuration related to paths should use the placeholder
${base-path}
:gocritic
(gocritic.ruleguard.rules
)depguard
(rules[].files
)goheader
(goheader.template-path
)errcheck
: the optionerrcheck.exclude
has been deprecated since golangci-lint v1.42 so I didn't add the support of the placeholder.With the new option
run.relative-path-mode
, you can now run golangci-lint inside a package and the configuration related to file paths will work.In v2,
output.path-prefix
will be used only for output and not for matching, and the default relative path mode will begomod
orcfg
(notwd
like today).More details about the topic are inside the issues:
configuration overview
Fixes #5297
Related to #5298
Fixes #4635
Fixes #3953
Fixes #3717
Fixes #1178
Closes #3748