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

len: Len instead of Equal when comparing two len's #166

Closed
Limero opened this issue Jul 30, 2024 · 1 comment · Fixed by #204
Closed

len: Len instead of Equal when comparing two len's #166

Limero opened this issue Jul 30, 2024 · 1 comment · Fixed by #204
Labels
enhancement New feature or request false-negative Checker's false negative example

Comments

@Limero
Copy link

Limero commented Jul 30, 2024

In a large codebase at work I noticed that people sometimes compare the values of two len() with Equal, something that testifylint v1.4.3 currently doesn't detect. It should suggest using assert.Len() the same as if you compare with a const, i.e. assert.Equal(t, len(expected), 2)

Expected results:

expected := []string{"a", "b"}
actual := map[string]bool{
  "a": true,
  "b": true,
}

❌ assert.Equal(t, len(expected), len(actual))
✅ assert.Len(t, expected, len(actual))
@Antonboom Antonboom added enhancement New feature or request false-negative Checker's false negative example labels Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request false-negative Checker's false negative example
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants