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 one more check in gocriticNilValReturn #100

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

Conversation

orsinium
Copy link
Contributor

No description provided.

Copy link
Collaborator

@cristaloleg cristaloleg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sgtm

@@ -191,6 +191,8 @@ func gocriticWrapperFunc(m fluent.Matcher) {
func gocriticNilValReturn(m fluent.Matcher) {
m.Match(`if $*_; $v == nil { return $v }`).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we drop this one? or combine them into one? @quasilyte

Copy link
Owner

@quasilyte quasilyte Oct 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought that this pattern catches both if statements with and without the init clause. I'll re-check this with gogrep.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Buuuuuut we can make two rules with suggestion. Not one with some info and one with a fix.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's correct. But the form with the fix should go before this one.
Otherwise, the more generic pattern will match and we'll never get a suggestion.
At least it looks like we need to move the new rule above this one.

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.

3 participants