esimonov / ifshort

Go linter for checking that your code uses short syntax for if-statements whenever possible.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

False positive with dependent variables

jackwhelpton opened this issue · comments

This appears similar to #4, but in this case the rewrite is far from obvious:

line := <-out
if got := line[strings.Index(line, " INFO")+1:]; got != want {
	// Only validate the message: other tests cover timestamp
	t.Fatalf("got %v, want %v", got, want)
}

as defining two dependent variables using multiple assignments is a challenge (barring refactoring the logic that produces "got" into a separate function, anonymous or otherwise).