-
Notifications
You must be signed in to change notification settings - Fork 265
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
Allow use of _xxx
with unused-parameter
rule
#613
Comments
Hi @Gusted thanks for filling the issue.
It is common in JS but not in GO, to the point that |
I see, fair point. Thank you for your response. |
Is it out of question to have a rule configuration option for this? It could allow the user to define a regex pattern. The default pattern could be |
Not at all. My intention with the previous comment was to highlight that prefixing identifiers with
Yes, it is something that could be studied |
Prefixing with
(I have to disable structcheck and unused for this in golangci-lint) |
@silverwind thanks for joining to the discussion could you provide more details about the use of
Do you mean type something struct {
signo int32
} and type something struct {
_signo int32
}
I know that adding a blank field is a hack to force you to use field names when instantiating a struct (https://go.dev/play/p/hJeg6a0D_x9)
What do you mean by pad the struct and how |
|
Can't really comment much on golang practices, but I'm using the Eslint has distinct pattern configuration for various types of variables (primarly arguments and regular variables), maybe this is something to consider to split into multiple options too. |
I've not see allwedRegex argumnet in |
Think same is for unused-receiver |
Provided MR for this feature |
Is your feature request related to a problem? Please describe.
We're enabling the
unused-parameter
rule on our repo to detect if there are possible bugs. A lot of parameters can be changed to_
, but in certain cases it will make the code more unreadableDescribe the solution you'd like
Add a option(or by default) that certain use-case are allowed, this can be limited to just the
_
prefix or a generic regex option. Using the_
prefix is common in JS to still have the variable name but show that the variable is unused.Describe alternatives you've considered
Adding the
//revive:disable...
comment, but that's better to avoided for each function that needs this.Additional context
None
The text was updated successfully, but these errors were encountered: