Skip to content

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

}

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