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

testifylint->negative-positive - Should we enable it? #15536

Closed
zak-pawel opened this issue Jun 20, 2024 · 2 comments · Fixed by #15566
Closed

testifylint->negative-positive - Should we enable it? #15536

zak-pawel opened this issue Jun 20, 2024 · 2 comments · Fixed by #15566
Labels

Comments

@zak-pawel
Copy link
Collaborator

Description

This issue starts a discussion about enabling:

  • linter: testifylint - Checks usage of github.com/stretchr/testify.
  • checker: negative-positive - More appropriate testify API with clearer failure message.

Example

Before:

assert.Less(t, a, 0)
assert.Greater(t, 0, a)
assert.True(t, a < 0)
assert.True(t, 0 > a)
assert.False(t, a >= 0)
assert.False(t, 0 <= a)

assert.Greater(t, a, 0)
assert.Less(t, 0, a)
assert.True(t, a > 0)
assert.True(t, 0 < a)
assert.False(t, a <= 0)
assert.False(t, 0 >= a)

After:

assert.Negative(t, a)
assert.Positive(t, a)

Expected output

Decision about enabling or not enabling this checker.

Findings

For this checker, the following findings were found in the current codebase:

plugins/inputs/pgbouncer/pgbouncer_test.go:101:2                          testifylint  negative-positive: use require.Positive
plugins/inputs/pgbouncer/pgbouncer_test.go:213:2                          testifylint  negative-positive: use require.Positive
plugins/inputs/postgresql/postgresql_test.go:128:2                        testifylint  negative-positive: use require.Positive
plugins/inputs/postgresql_extensible/postgresql_extensible_test.go:124:2  testifylint  negative-positive: use require.Positive

Additional configuration

For this checker, no additional configuration can be provided.

@srebhan
Copy link
Contributor

srebhan commented Jun 24, 2024

Fine with me.

@powersj
Copy link
Contributor

powersj commented Jun 25, 2024

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants