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 actual is a variable #167

Open
Limero opened this issue Jul 30, 2024 · 1 comment
Open

len: Len instead of Equal when actual is a variable #167

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

Comments

@Limero
Copy link

Limero commented Jul 30, 2024

testifylint v1.4.3 correctly suggests using assert.Len for the following cases:

expected := []string{"a", "b"}
assert.Equal(t, len(expected), 2)

actual := []string{"a", "b"}
assert.Equal(t, 2, len(actual))

expected := 2
actual := []string{"a", "b"}
assert.Equal(t, expected, len(actual))

However, this case is not detected:

expected := []string{"a", "b"}
actual := 2
assert.Equal(t, len(expected), actual)
@ccoVeille
Copy link
Contributor

ccoVeille commented Jul 30, 2024

Thanks for reporting the issue. We will be OK at it.

So it's more suggestion of improvement than a bug, so it's good.

The team is currently not working actively as it's summer. So be patient.

Do you have an example of existing code available on GitHub that is like what you reported ? It could be code you fixed that no longer exists, so then please point us the PR

I'm asking because sometimes it helps to find other pattern in existing code surrounding the one you want us to consider

Thanks by advance

@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

No branches or pull requests

3 participants