-
Notifications
You must be signed in to change notification settings - Fork 286
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
Expose the ability to enable all rules #517
Comments
Hi @Zamiell, thanks for filling the issue. This is a subject that we had already talked about (for example #104 and #236) but for which we were not able to find a nice solution. There are some aspects to take into account:
|
I think that both 1 and 2 are fine. Consider the following hypothetical user story:
linters-settings:
revive:
enable-all: true
rules:
- name: exported
severity: disabled
linters-settings:
revive:
enable-all: true
rules:
- name: exported
severity: disabled
- name: A
severity: disabled
- name: B
severity: disabled
- name: C
severity: disabled
linters-settings:
revive:
enable-all: true
rules:
- name: exported
severity: disabled
- name: A
severity: disabled
- name: B
severity: disabled
- name: C
severity: disabled
- name: D
severity: disabled
- name: E
severity: disabled
- name: F
severity: disabled
One could argue that in this hypothetical, Alice is still burdened with keeping her config up-to-date, because as soon as the maintainers of However, I don't think this is a valid criticism. Implicitly, by specifying |
@Zamiell, please check this branch and let me know if it fits your expectations. The all-rules-activated configuration looks something like: ignoreGeneratedHeader = false
severity = "warning"
confidence = 0.8
errorCode = 0
warningCode = 0
activateAllRules = true # here we activate all rules
# Deactivated rules
[rule.blank-imports]
Deactivated = true
[rule.file-header]
Deactivated = true
[rule.max-public-structs]
Deactivated = true
[rule.line-length-limit]
Deactivated = true
[rule.function-length]
Deactivated = true
# Rule tuning
[rule.argument-limit]
Arguments = [5]
[rule.cyclomatic]
Arguments = [10]
[rule.cognitive-complexity]
Arguments = [7]
[rule.function-result-limit]
Arguments = [3] |
Nice, thanks chavacava. |
Sure, it is simpler but disabled is not a severity (i.e. using the
Yes, I've hesitated between Meanwhile lets see what @mgechev says about all this. |
The process for introducing a tool for static analysis described in this comment sounds like:
That's probably a valid approach, especially in a large codebase. A more intentional approach I see is:
Both have trade-offs. The pros of the first approach I see are:
At the same time, I'm not convinced a developer should enable certain rule only because their code pass its checks. Looking at I'm not convinced we should move forward with this feature request. Let me know what your thoughts if you disagree. |
My understanding of the so called "first approach" is that a rule is disabled because it is not of interest (steps 5 and 6)
Yes, even if the I really like that
Should we need to go on with this feature and let users decide to use it or not? Which is the price of adding this feature (config complexity, more constraints to implement future features) ? |
mgechev, it is unclear what you mean by this. For example, building on my hypothetical above:
Does this even count as a "disadvantage" of the workflow? That's just the normal, expected workflow. Like, you could flip that logic on its head. If I may, I could rephrase your argument to the following: "A developer should not enable a rule if said rule has nothing to do with his codebase." But consider the following hypothetical:
It actually might not be deprecated after all. See: golangci/golangci-lint#1888 |
That's the main problem I see as well. Given the configuration is implicit by default, nobody really knows what checks apply to their project. I don't see this as a scalable approach in large repositories.
This is the approach my colleagues and I would take + a team discussion after that. I consider it as a best practice.
Bob's company sounds like a bad place so he should have left on the first place. Looks like nobody reviewed his code and he was fired for a mistake anyone can make. Tools for static analysis, unfortunately, can't guarantee correctness and even if Bob somehow got lucky with the sql rules, he may hit a deadlock the next day and have the same fate. Saying this, I'm not feeling strongly against the feature. revive is an open source project with many users so I'd suggest collecting opinions and making a decision based on this. Additionally, let's keep an eye on golangci/golangci-lint#1888. |
I think we can add the feature and let users decide to use it or not. (I'll not use it but some of my colleagues find it useful) |
Sounds good! |
Hello, and thanks for the linter. I have a feature request.
Right now, it appears that the only way that users can enable all rules and disable one rule is to manually specify every single existing rule into the config except for the one specific one that they don't want.
This is tedious, and not very future proof.
Meaning that when you guys add a new useful rule, I don't want to have to manually do research and find out which specific new rule that you added, and then manually add that new rule to my config in order to stay up-to-date. I just want to upgrade my version of
golangci-lint
and automatically get the latest and greatest linting without having to change my config.As an analogy, golangci-lint allows this kind of workflow with the following YML config:
The text was updated successfully, but these errors were encountered: