-
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
panics with enable-all-rules: true
: not enough arguments for cyclomatic rule, expected 1, got 0
#749
Comments
Hi @Dentrax, thanks for filling the issue. As is stated in the Configuration section of the README.md: Rules like cognitive-complexity require to be parametrized to run. (The idea of using default values for rules arguments was already discussed and discarded) |
Sorry, I missed this! Isn't that a bit too complex for the end-user? This was my first try to run
Shouldn't all rules have default values? The end user could not know the best value for a specific rule. For example, I could not know the correct parameter for the cognitive-complexity rule. Are there any known industry standard value? If not, why not we just skip?
As an end and fresh user of revive, I'd like to run everything by simply passing a flag. If just passing
Can you please attach reference link? I'd like to read! If the above statements have already been discussed and discarded, I can leave the use of the Thanks! Please don't get me wrong, these are just my feedback. |
Do you think the message is not clear enough?
About default values, see below.
End users of tools like
The simplest way of running
Expectations are very personal. For example I'll be surprised if Anyway,
You can read this thread: #517
Related info on these threads but the main content is in #517
The flag is not mandatory, you can remove it from the configuration if you'll not use it
a simple
Thank you! All feedbacks are welcome |
Looking to add golangci-lint to a new project. (Hopefully more to come) Trying to figure out how to disable just one rule (i.e. var-naming) from revive.
Kindly point me to doc(s) you're referring to or even better if you could please explain why the config below is causing the panic. Much appreciated!
|
Hi @AlexBasile123, the Configuration section of the README.md provides the information you are looking for: By default To enable all available rules you need to add: enableAllRules = true This will enable all available rules no matter of what rules are named in the configuration file. To disable a rule, you simply mark it as disabled in the configuration. [rule.line-length-limit]
Disabled = true When enabling all rules you still need/can provide specific configurations for rules. severity = "warning"
confidence = 0.8
errorCode = 0
warningCode = 0
# Enable all available rules
enableAllRules = true
# Disabled rules
[rule.blank-imports]
Disabled = true
[rule.file-header]
Disabled = true
[rule.max-public-structs]
Disabled = true
[rule.line-length-limit]
Disabled = true
[rule.function-length]
Disabled = true
[rule.banned-characters]
Disabled = true
# Rule tuning
[rule.argument-limit]
Arguments = [5]
[rule.cyclomatic]
Arguments = [10]
[rule.cognitive-complexity]
Arguments = [7]
[rule.function-result-limit]
Arguments = [3]
[rule.error-strings]
Arguments = ["mypackage.Error"] In your case, if you are searching to disable |
Thanks Chavacava for the quick response! Before pasting the config I forgot to set disabled back to true. By specifying any rules, whether disabled or not, it only runs those rules. Changing enableAllRules to true doesn't have any affect. Meaning, it will respect just the rules that were listed. I'll try setting the mandatory arguments for all rules when using enable-all-rules. Would've been nice not to and just keep the current defaults as when you don't specify any rules. All in all, sounds like listing out the rules (at least the ones w/ mandatory args) is the way to go. I appreciate your feedback. |
Hello, I've made a PR (#830) that will set default configuration to some rules in order to do not panic when running revive with |
Describe the bug
To Reproduce
Steps to reproduce the behavior:
Ref: https://golangci-lint.run/usage/linters/#revive
# flags revive ...
Expected behavior
It should work?
Logs
See the first section.
Desktop (please complete the following information):
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: