-
-
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
🌟 Let's talk about exclusion options inside issues section #5297
Comments
Related to this topic, can we do something to clarify that this is purely about excluding reports/issues and not analyzing? Don't know from the top of my head what that would be and the setting is clearly already under the |
Currently, I don't know if the section will be inside |
After working on the formatters, I think my proposal should be updated to: linters: # <-- Important
# ...
exclusions:
default:
- comments
- stdErrorHandling
- commonFalsePositives
- legacy
generated: strict # by default?
rules:
- path: _test\.go
linters:
- gocyclo
- errcheck
- dupl
- gosec
- path-except: _test\.go
linters:
- forbidigo
- path: internal/hmac/
text: "weak cryptographic primitive"
linters:
- gosec
- linters:
- staticcheck
text: "SA9003:"
- linters:
- lll
source: "^//go:generate "
paths:
- src/external_libs
- autogenerated_by_my_lib
- ".*\\.my\\.go$"
- lib/bad.go
# ... Linters ( linters:
# ...
exclusions:
#...
fommatters:
# ...
exclusions:
# ... |
Introducing |
After going down the rabbit hole, and spending too much time on it, I think the problem with
This is impossible with a simple option to handle all cases, the 2 sets of constraints are incompatible. My current thoughts are either to have 2 options and/or have a specific placeholder (like The extra hidden problem here is consistency: |
Maybe it can feel the topic is not moving fast, but the sub-topic of Thinking about the compatibility is a nightmare as I explained here This option asks questions about absolute/relative path usage inside processors. I will share my current notes (draft) about processors. Processors are mainly divided into 3 categories (this is a simplification there are variants):
They are executed in this order:
An example of the sub-topics of the sub-topic: initially the Another example is the There are too many rabbit holes 😸 I opened a first PR with just some processor optimizations: #5316 |
The option The goal is to handle the filepaths when golangci-lint is run inside a subdirectory but the reports must be related to a parent.
The main goal is to be used inside The usage has been extended This option requires the usage of relative paths (to the binary). References:
The
Note: I wonder if the placement of this option inside I feel that |
Classic project
Currently:
Monorepo
Currently:
Local group of projects
Currently:
Mixed content
Currently:
|
absolute path:
relative path:
My conclusions are we need several ways to match:
There are 5 topics behind relative paths:
|
So IMO The compatibility is complex mainly due to this option 😢 |
I searched public repositories inside GitHub: https://github.com/search?q=path%3A%2F.golangci*+%22output%3A%22+%2Fpath-prefix%3A+%28%27%7C%22%29.%2B%28%27%7C%22%29%2F+-path%3A*reference*+&type=code Conclusion: only one real usage of |
I searched for GitHub action: https://github.com/search?q=%2Fgolangci%5C%2Fgolangci-lint-action%40%28.%2B%29%3A%2F+%22working-directory%3A%22+path%3A%2F.github%2F&type=code A few more results (<20) but not many. |
I need to share my thoughts. I can see several possibilities for the path problem:
Also, the management of file paths is inconsistent inside linters configurations:
In all cases, linters cannot be easily handled with a configuration option (because the regexp matching is inside the linters) so a placeholder is the only solution for linters. |
There were not a lot of reactions, I know this topic is not "sexy" but this is an important topic. I have done my best to provide information because this is not a trivial problem, and it tortured my mind for 1 week. For now, I choose I will implement that to check if everything works as expected. The previous placeholder |
I have a working POC:
About linters, I think having multiple placeholders ( So only one placeholder should exist: something like About plugins ( After that, I will implement again the new In v2, I see the end of this topic, I am relieved. |
I named the placeholder
About Currently, Go plugins ( |
The PR is open: #5339 |
Important
This is a proposal: I don't know if it is possible and what the impact could be inside the code.
The proposal may evolve.
The current configuration:
⛑️ The Problems
Useless Option
The option
exclude-dirs-use-default
comes from the "prehistorical" world ofGOPATH
.vendor$
,testdata$
are useless inside this default configuration because the Go tooling already excludes them.Godeps$
is useless.examples$
: This is unexpected because it excludes all directories ending withexamples
.third_party$
,builtin$
: we should not create "custom conventions", so those elements should not be excluded.Duplicated Options
The goals of
exclude-dirs
andexclude-files
are the same.The matching can be complex in some cases:
exclude
can be expressed with anexclude-rules
.Unclear Section
At the 1st level of the
issues
section, there are options about filtering (ex:max-issues-per-linter
,new-from-rev
), and about exclusions (ex:exclude-rules
).I don't think we should create a subsection for each topic but we should have at least one for exclusions.
Default Exclusions
There is a dedicated proposal for this topic:
💭 Proposal
issues
:issues.exclude-generated
->issues.exclusions.generated
issues.exclude-case-sensitive
->issues.exclusions.case-sensitive
: Useful? Remove? Merge with rules? (it just add(?i)
prefix) -> by default?issues.exclude-rules
->issues.exclusions.rules
issues.exclude-use-default
. Replaced byissues.exclusions.default
.exclude-dirs-use-default
.issues.exclude
.issues.exclude-use-default
(cf proposal about default exclusions)issues.exclude-dirs
. Replaced byissues.exclusions.paths
.issues.exclude-files
. Replaced byissues.exclusions.paths
.Example
The text was updated successfully, but these errors were encountered: