Skip to content
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

Add allowed-expressions flag #46

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

3timeslazy
Copy link

Hi @leighmcculloch,

First of all, thank you for your work!

I noticed that a lot of people asking for exceptions for different frequently used expressions, such as strings.Replace or template.Must. I myself would be happy if the linter could ignore certain expressions rather than putting nolint tag each time or disabling the linter entirely. But I think manually adding exceptions is not scalable, so I made this PR as a proposal of a new allowed-expressions flag.

The format of the flag is a comma separated list of allowed expressions. Each expression has a format of name.Selector. An example: --allowed-expressions=regexp.MustCompile,template.Must.

If the given list is invalid, it is ignored.

Please, let me know what you think.

Thanks!

@leighmcculloch
Copy link
Owner

Hi @3timeslazy! Thanks for opening the change. I think the direction this linter should go in is to focus on preventing the mutation of package level variables as documented in the linked issue below. While allowed expressions would get a long way there, if we did the below, no configuration would be required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants