Documentation ¶
Index ¶
- Constants
- Variables
- func All() []string
- func EnabledByDefault() []string
- func IsEnabledByDefault(name string) bool
- func IsKnown(name string) bool
- func SortByPriority(checkers []string)
- type AdvancedChecker
- type BlankImport
- type BoolCompare
- type CallMeta
- type Checker
- type Compares
- type Contains
- type Empty
- type EncodedCompare
- type ErrorIsAs
- type ErrorNil
- type ExpectedActual
- type FloatCompare
- type FnMeta
- type Formatter
- type GoRequire
- type Len
- type NegativePositive
- type NilCompare
- type Regexp
- type RegularChecker
- type RequireError
- type SuiteBrokenParallel
- type SuiteDontUsePkg
- type SuiteExtraAssertCall
- type SuiteExtraAssertCallMode
- type SuiteSubtestRun
- type SuiteTHelper
- type UselessAssert
Constants ¶
const DefaultSuiteExtraAssertCallMode = SuiteExtraAssertCallModeRemove
Variables ¶
var DefaultExpectedVarPattern = regexp.MustCompile(
`(^(exp(ected)?|want(ed)?)([A-Z]\w*)?$)|(^(\w*[a-z])?(Exp(ected)?|Want(ed)?)$)`)
DefaultExpectedVarPattern matches variables with "expected" or "wanted" prefix or suffix in the name.
Functions ¶
func EnabledByDefault ¶
func EnabledByDefault() []string
EnabledByDefault returns checkers enabled by default sorted by checker's priority.
func IsEnabledByDefault ¶
IsEnabledByDefault returns true if a checker is enabled by default. Returns false if there is no such checker in the registry. For pre-validation use Get or IsKnown.
func SortByPriority ¶
func SortByPriority(checkers []string)
SortByPriority mutates the input checkers names by sorting them in checker priority order. Ignores unknown checkers. For pre-validation use Get or IsKnown.
Types ¶
type AdvancedChecker ¶
type AdvancedChecker interface { Checker Check(pass *analysis.Pass, inspector *inspector.Inspector) []analysis.Diagnostic }
AdvancedChecker implements complex Check logic different from trivial CallMeta check.
type BlankImport ¶ added in v1.1.0
type BlankImport struct{}
BlankImport detects useless blank imports of testify's packages. These imports are useless since testify doesn't do any magic with init() function.
The checker detects situations like
import ( "testing" _ "github.com/stretchr/testify" _ "github.com/stretchr/testify/assert" _ "github.com/stretchr/testify/http" _ "github.com/stretchr/testify/mock" _ "github.com/stretchr/testify/require" _ "github.com/stretchr/testify/suite" )
and requires
import ( "testing" )
func NewBlankImport ¶ added in v1.1.0
func NewBlankImport() BlankImport
NewBlankImport constructs BlankImport checker.
func (BlankImport) Check ¶ added in v1.1.0
func (checker BlankImport) Check(pass *analysis.Pass, _ *inspector.Inspector) (diagnostics []analysis.Diagnostic)
func (BlankImport) Name ¶ added in v1.1.0
func (BlankImport) Name() string
type BoolCompare ¶
type BoolCompare struct {
// contains filtered or unexported fields
}
BoolCompare detects situations like
assert.Equal(t, false, result) assert.EqualValues(t, false, result) assert.Exactly(t, false, result) assert.NotEqual(t, true, result) assert.NotEqualValues(t, true, result) assert.False(t, !result) assert.True(t, result == true) ...
and requires
assert.False(t, result) assert.True(t, result)
func NewBoolCompare ¶
func NewBoolCompare() *BoolCompare
NewBoolCompare constructs BoolCompare checker.
func (BoolCompare) Check ¶
func (checker BoolCompare) Check(pass *analysis.Pass, call *CallMeta) *analysis.Diagnostic
func (BoolCompare) Name ¶
func (BoolCompare) Name() string
func (*BoolCompare) SetIgnoreCustomTypes ¶ added in v1.2.0
func (checker *BoolCompare) SetIgnoreCustomTypes(v bool) *BoolCompare
type CallMeta ¶
type CallMeta struct { // Call stores the original AST call expression. Call *ast.CallExpr // Range contains start and end position of assertion call. analysis.Range // IsPkg true if this is package (not object) call. IsPkg bool // IsAssert true if this is "testify/assert" package (or object) call. IsAssert bool // Selector is the AST expression of "assert.Equal". Selector *ast.SelectorExpr // SelectorXStr is a string representation of Selector's left part – value before point, e.g. "assert". SelectorXStr string // Fn stores meta info about assertion function itself. Fn FnMeta // Args stores assertion call arguments but without `t *testing.T` argument. // E.g [42, result, "helpful comment"]. Args []ast.Expr // ArgsRaw stores assertion call initial arguments. // E.g [t, 42, result, "helpful comment"]. ArgsRaw []ast.Expr }
CallMeta stores meta info about assertion function/method call, for example
assert.Equal(t, 42, result, "helpful comment")
func NewCallMeta ¶ added in v1.0.0
NewCallMeta returns meta information about testify assertion call. Returns nil if ast.CallExpr is not testify call.
type Compares ¶
type Compares struct{}
Compares detects situations like
assert.True(t, a == b) assert.True(t, a != b) assert.True(t, a > b) assert.True(t, a >= b) assert.True(t, a < b) assert.True(t, a <= b) assert.False(t, a == b) ...
and requires
assert.Equal(t, a, b) assert.NotEqual(t, a, b) assert.Greater(t, a, b) assert.GreaterOrEqual(t, a, b) assert.Less(t, a, b) assert.LessOrEqual(t, a, b)
If `a` and `b` are pointers then `assert.Same`/`NotSame` is required instead, due to the inappropriate recursive nature of `assert.Equal` (based on `reflect.DeepEqual`).
type Contains ¶ added in v1.5.0
type Contains struct{}
Contains detects situations like
assert.True(t, strings.Contains(a, "abc123")) assert.False(t, !strings.Contains(a, "abc123")) assert.False(t, strings.Contains(a, "abc123")) assert.True(t, !strings.Contains(a, "abc123"))
and requires
assert.Contains(t, a, "abc123") assert.NotContains(t, a, "abc123")
func NewContains ¶ added in v1.5.0
func NewContains() Contains
NewContains constructs Contains checker.
type Empty ¶
type Empty struct{}
Empty detects situations like
assert.Len(t, arr, 0) assert.Equal(t, 0, len(arr)) assert.EqualValues(t, 0, len(arr)) assert.Exactly(t, 0, len(arr)) assert.LessOrEqual(t, len(arr), 0) assert.GreaterOrEqual(t, 0, len(arr)) assert.Less(t, len(arr), 0) assert.Greater(t, 0, len(arr)) assert.Less(t, len(arr), 1) assert.Greater(t, 1, len(arr)) assert.Zero(t, len(arr)) assert.Empty(t, len(arr)) assert.NotEqual(t, 0, len(arr)) assert.NotEqualValues(t, 0, len(arr)) assert.Less(t, 0, len(arr)) assert.Greater(t, len(arr), 0) assert.Positive(t, len(arr)) assert.NotZero(t, len(arr)) assert.NotEmpty(t, len(arr))
and requires
assert.Empty(t, arr) assert.NotEmpty(t, arr)
type EncodedCompare ¶ added in v1.5.0
type EncodedCompare struct{}
EncodedCompare detects situations like
assert.Equal(t, `{"foo": "bar"}`, body) assert.EqualValues(t, `{"foo": "bar"}`, body) assert.Exactly(t, `{"foo": "bar"}`, body) assert.Equal(t, expectedJSON, resultJSON) assert.Equal(t, expBodyConst, w.Body.String()) assert.Equal(t, fmt.Sprintf(`{"value":"%s"}`, hexString), result) assert.Equal(t, "{}", json.RawMessage(resp)) assert.Equal(t, expJSON, strings.Trim(string(resultJSONBytes), "\n")) // + Replace, ReplaceAll, TrimSpace assert.Equal(t, expectedYML, conf)
and requires
assert.JSONEq(t, `{"foo": "bar"}`, body) assert.YAMLEq(t, expectedYML, conf)
func NewEncodedCompare ¶ added in v1.5.0
func NewEncodedCompare() EncodedCompare
NewEncodedCompare constructs EncodedCompare checker.
func (EncodedCompare) Check ¶ added in v1.5.0
func (checker EncodedCompare) Check(pass *analysis.Pass, call *CallMeta) *analysis.Diagnostic
func (EncodedCompare) Name ¶ added in v1.5.0
func (EncodedCompare) Name() string
type ErrorIsAs ¶
type ErrorIsAs struct{}
ErrorIsAs detects situations like
assert.Error(t, err, errSentinel) assert.NoError(t, err, errSentinel) assert.True(t, errors.Is(err, errSentinel)) assert.False(t, errors.Is(err, errSentinel)) assert.True(t, errors.As(err, &target))
and requires
assert.ErrorIs(t, err, errSentinel) assert.NotErrorIs(t, err, errSentinel) assert.ErrorAs(t, err, &target)
Also ErrorIsAs repeats go vet's "errorsas" check logic.
type ErrorNil ¶
type ErrorNil struct{}
ErrorNil detects situations like
assert.Nil(t, err) assert.Empty(t, err) assert.Zero(t, err) assert.Equal(t, nil, err) assert.EqualValues(t, nil, err) assert.Exactly(t, nil, err) assert.ErrorIs(t, err, nil) assert.NotNil(t, err) assert.NotEmpty(t, err) assert.NotZero(t, err) assert.NotEqual(t, nil, err) assert.NotEqualValues(t, nil, err) assert.NotErrorIs(t, err, nil)
and requires
assert.NoError(t, err) assert.Error(t, err)
type ExpectedActual ¶
type ExpectedActual struct {
// contains filtered or unexported fields
}
ExpectedActual detects situations like
assert.Equal(t, result, expected) assert.EqualExportedValues(t, resultObj, User{Name: "Anton"}) assert.EqualValues(t, result, 42) assert.Exactly(t, result, int64(42)) assert.JSONEq(t, result, `{"version": 3}`) assert.InDelta(t, result, 42.42, 1.0) assert.InDeltaMapValues(t, result, map[string]float64{"score": 0.99}, 1.0) assert.InDeltaSlice(t, result, []float64{0.98, 0.99}, 1.0) assert.InEpsilon(t, result, 42.42, 0.0001) assert.InEpsilonSlice(t, result, []float64{0.9801, 0.9902}, 0.0001) assert.IsType(t, result, (*User)(nil)) assert.NotEqual(t, result, "expected") assert.NotEqualValues(t, result, "expected") assert.NotSame(t, resultPtr, &value) assert.Same(t, resultPtr, &value) assert.WithinDuration(t, resultTime, time.Date(2023, 01, 12, 11, 46, 33, 0, nil), time.Second) assert.YAMLEq(t, result, "version: '3'")
and requires
assert.Equal(t, expected, result) assert.EqualExportedValues(t, User{Name: "Anton"}, resultObj) assert.EqualValues(t, 42, result) ...
func NewExpectedActual ¶
func NewExpectedActual() *ExpectedActual
NewExpectedActual constructs ExpectedActual checker using DefaultExpectedVarPattern.
func (ExpectedActual) Check ¶
func (checker ExpectedActual) Check(pass *analysis.Pass, call *CallMeta) *analysis.Diagnostic
func (ExpectedActual) Name ¶
func (ExpectedActual) Name() string
func (*ExpectedActual) SetExpVarPattern ¶
func (checker *ExpectedActual) SetExpVarPattern(p *regexp.Regexp) *ExpectedActual
type FloatCompare ¶
type FloatCompare struct{}
FloatCompare detects situations like
assert.Equal(t, 42.42, result) assert.EqualValues(t, 42.42, result) assert.Exactly(t, 42.42, result) assert.True(t, result == 42.42) assert.False(t, result != 42.42)
and requires
assert.InEpsilon(t, 42.42, result, 0.0001) // Or assert.InDelta
func NewFloatCompare ¶
func NewFloatCompare() FloatCompare
NewFloatCompare constructs FloatCompare checker.
func (FloatCompare) Check ¶
func (checker FloatCompare) Check(pass *analysis.Pass, call *CallMeta) *analysis.Diagnostic
func (FloatCompare) Name ¶
func (FloatCompare) Name() string
type FnMeta ¶
type FnMeta struct { // Range contains start and end position of function Name. analysis.Range // Name is a function name. Name string // NameFTrimmed is a function name without "f" suffix. NameFTrimmed string // IsFmt is true if function is formatted, e.g. "Equalf". IsFmt bool // Signature represents assertion signature. Signature *types.Signature }
FnMeta stores meta info about assertion function itself, for example "Equal".
type Formatter ¶ added in v1.4.0
type Formatter struct {
// contains filtered or unexported fields
}
Formatter detects situations like
assert.ElementsMatch(t, certConfig.Org, csr.Subject.Org, "organizations not equal") assert.Error(t, err, fmt.Sprintf("Profile %s should not be valid", test.profile)) assert.Errorf(t, err, fmt.Sprintf("test %s", test.testName)) assert.Truef(t, targetTs.Equal(ts), "the timestamp should be as expected (%s) but was %s", targetTs) ...
and requires
assert.ElementsMatchf(t, certConfig.Org, csr.Subject.Org, "organizations not equal") assert.Errorf(t, err, "Profile %s should not be valid", test.profile) assert.Errorf(t, err, "test %s", test.testName) assert.Truef(t, targetTs.Equal(ts), "the timestamp should be as expected (%s) but was %s", targetTs, ts)
func NewFormatter ¶ added in v1.4.0
func NewFormatter() *Formatter
NewFormatter constructs Formatter checker.
func (*Formatter) SetCheckFormatString ¶ added in v1.4.0
func (*Formatter) SetRequireFFuncs ¶ added in v1.4.0
type GoRequire ¶ added in v1.0.0
type GoRequire struct {
// contains filtered or unexported fields
}
GoRequire takes idea from go vet's "testinggoroutine" check and detects usage of require package's functions or assert.FailNow in the non-test goroutines
go func() { conn, err = lis.Accept() require.NoError(t, err) if assert.Error(err) { assert.FailNow(t, msg) } }()
func NewGoRequire ¶ added in v1.0.0
func NewGoRequire() *GoRequire
NewGoRequire constructs GoRequire checker.
func (GoRequire) Check ¶ added in v1.0.0
func (checker GoRequire) Check(pass *analysis.Pass, inspector *inspector.Inspector) (diagnostics []analysis.Diagnostic)
Check should be consistent with https://cs.opensource.google/go/x/tools/+/master:go/analysis/passes/testinggoroutine/testinggoroutine.go
But due to the fact that the Check covers cases missed by go vet, the implementation turned out to be terribly complicated.
In simple words, the algorithm is as follows:
- we walk along the call tree and store the status, whether we are in the test goroutine or not;
- if we are in a test goroutine, then require is allowed, otherwise not;
- when we encounter the launch of a subtest or `go` statement, the status changes;
- in order to correctly handle the return to the correct status when exiting the current function, we have to store a stack of statuses (inGoroutineRunningTestFunc).
Other test functions called in the test function are also analyzed to make a verdict about the current function. This leads to recursion, which the cache of processed functions (processedFuncs) helps reduce the impact of. Also, because of this, we have to pre-collect a list of test function declarations (testsDecls).
func (*GoRequire) SetIgnoreHTTPHandlers ¶ added in v1.3.0
type Len ¶
type Len struct{}
Len detects situations like
assert.Equal(t, 3, len(arr)) assert.EqualValues(t, 3, len(arr)) assert.Exactly(t, 3, len(arr)) assert.True(t, len(arr) == 3)
and requires
assert.Len(t, arr, 3)
type NegativePositive ¶ added in v1.3.0
type NegativePositive struct{}
NegativePositive detects situations like
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)
and requires
assert.Negative(t, value) assert.Positive(t, value)
Typed zeros (like `int8(0)`, ..., `uint64(0)`) are also supported.
func NewNegativePositive ¶ added in v1.3.0
func NewNegativePositive() NegativePositive
NewNegativePositive constructs NegativePositive checker.
func (NegativePositive) Check ¶ added in v1.3.0
func (checker NegativePositive) Check(pass *analysis.Pass, call *CallMeta) *analysis.Diagnostic
func (NegativePositive) Name ¶ added in v1.3.0
func (NegativePositive) Name() string
type NilCompare ¶ added in v1.0.0
type NilCompare struct{}
NilCompare detects situations like
assert.Equal(t, nil, value) assert.EqualValues(t, nil, value) assert.Exactly(t, nil, value) assert.NotEqual(t, nil, value) assert.NotEqualValues(t, nil, value)
and requires
assert.Nil(t, value) assert.NotNil(t, value)
func NewNilCompare ¶ added in v1.0.0
func NewNilCompare() NilCompare
NewNilCompare constructs NilCompare checker.
func (NilCompare) Check ¶ added in v1.0.0
func (checker NilCompare) Check(pass *analysis.Pass, call *CallMeta) *analysis.Diagnostic
func (NilCompare) Name ¶ added in v1.0.0
func (NilCompare) Name() string
type Regexp ¶ added in v1.5.0
type Regexp struct{}
Regexp detects situations like
assert.Regexp(t, regexp.MustCompile(`\[.*\] DEBUG \(.*TestNew.*\): message`), out) assert.NotRegexp(t, regexp.MustCompile(`\[.*\] TRACE message`), out)
and requires
assert.Regexp(t, `\[.*\] DEBUG \(.*TestNew.*\): message`, out) assert.NotRegexp(t, `\[.*\] TRACE message`, out)
type RegularChecker ¶
type RegularChecker interface { Checker Check(pass *analysis.Pass, call *CallMeta) *analysis.Diagnostic }
RegularChecker check assertion call presented in CallMeta form.
type RequireError ¶
type RequireError struct {
// contains filtered or unexported fields
}
RequireError detects error assertions like
assert.Error(t, err) // s.Error(err), s.Assert().Error(err) assert.ErrorIs(t, err, io.EOF) assert.ErrorAs(t, err, &target) assert.EqualError(t, err, "end of file") assert.ErrorContains(t, err, "end of file") assert.NoError(t, err) assert.NotErrorIs(t, err, io.EOF)
and requires
require.Error(t, err) // s.Require().Error(err), s.Require().Error(err) require.ErrorIs(t, err, io.EOF) require.ErrorAs(t, err, &target) ...
RequireError ignores: - assertions in the `if` condition; - assertions in the bool expression; - the entire `if-else[-if]` block, if there is an assertion in any `if` condition; - the last assertion in the block, if there are no methods/functions calls after it; - assertions in an explicit goroutine (including `http.Handler`); - assertions in an explicit testing cleanup function or suite teardown methods; - sequence of NoError assertions.
func NewRequireError ¶
func NewRequireError() *RequireError
NewRequireError constructs RequireError checker.
func (RequireError) Check ¶
func (checker RequireError) Check(pass *analysis.Pass, inspector *inspector.Inspector) []analysis.Diagnostic
func (RequireError) Name ¶
func (RequireError) Name() string
func (*RequireError) SetFnPattern ¶ added in v1.0.0
func (checker *RequireError) SetFnPattern(p *regexp.Regexp) *RequireError
type SuiteBrokenParallel ¶ added in v1.4.0
type SuiteBrokenParallel struct{}
SuiteBrokenParallel detects unsupported t.Parallel() call in suite tests
func (s *MySuite) SetupTest() { s.T().Parallel() } // And other hooks... func (s *MySuite) TestSomething() { s.T().Parallel() for _, tt := range cases { s.Run(tt.name, func() { s.T().Parallel() }) s.T().Run(tt.name, func(t *testing.T) { t.Parallel() }) } }
func NewSuiteBrokenParallel ¶ added in v1.4.0
func NewSuiteBrokenParallel() SuiteBrokenParallel
NewSuiteBrokenParallel constructs SuiteBrokenParallel checker.
func (SuiteBrokenParallel) Check ¶ added in v1.4.0
func (checker SuiteBrokenParallel) Check(pass *analysis.Pass, insp *inspector.Inspector) (diagnostics []analysis.Diagnostic)
func (SuiteBrokenParallel) Name ¶ added in v1.4.0
func (SuiteBrokenParallel) Name() string
type SuiteDontUsePkg ¶
type SuiteDontUsePkg struct{}
SuiteDontUsePkg detects situations like
func (s *MySuite) TestSomething() { assert.Equal(s.T(), 42, value) }
and requires
func (s *MySuite) TestSomething() { s.Equal(42, value) }
func NewSuiteDontUsePkg ¶
func NewSuiteDontUsePkg() SuiteDontUsePkg
NewSuiteDontUsePkg constructs SuiteDontUsePkg checker.
func (SuiteDontUsePkg) Check ¶
func (checker SuiteDontUsePkg) Check(pass *analysis.Pass, call *CallMeta) *analysis.Diagnostic
func (SuiteDontUsePkg) Name ¶
func (SuiteDontUsePkg) Name() string
type SuiteExtraAssertCall ¶
type SuiteExtraAssertCall struct {
// contains filtered or unexported fields
}
SuiteExtraAssertCall detects situations like
func (s *MySuite) TestSomething() { s.Assert().Equal(42, value) }
and requires
func (s *MySuite) TestSomething() { s.Equal(42, value) }
or vice versa (depending on the configurable mode).
func NewSuiteExtraAssertCall ¶
func NewSuiteExtraAssertCall() *SuiteExtraAssertCall
NewSuiteExtraAssertCall constructs SuiteExtraAssertCall checker.
func (SuiteExtraAssertCall) Check ¶
func (checker SuiteExtraAssertCall) Check(pass *analysis.Pass, call *CallMeta) *analysis.Diagnostic
func (SuiteExtraAssertCall) Name ¶
func (SuiteExtraAssertCall) Name() string
func (*SuiteExtraAssertCall) SetMode ¶
func (checker *SuiteExtraAssertCall) SetMode(m SuiteExtraAssertCallMode) *SuiteExtraAssertCall
type SuiteExtraAssertCallMode ¶
type SuiteExtraAssertCallMode int
SuiteExtraAssertCallMode reflects different modes of work of SuiteExtraAssertCall checker.
const ( SuiteExtraAssertCallModeRemove SuiteExtraAssertCallMode = iota SuiteExtraAssertCallModeRequire )
type SuiteSubtestRun ¶ added in v1.4.0
type SuiteSubtestRun struct{}
SuiteSubtestRun detects situations like
s.T().Run("subtest", func(t *testing.T) { assert.Equal(t, 42, result) })
and requires
s.Run("subtest", func() { s.Equal(42, result) })
func NewSuiteSubtestRun ¶ added in v1.4.0
func NewSuiteSubtestRun() SuiteSubtestRun
NewSuiteSubtestRun constructs SuiteSubtestRun checker.
func (SuiteSubtestRun) Check ¶ added in v1.4.0
func (checker SuiteSubtestRun) Check(pass *analysis.Pass, insp *inspector.Inspector) (diagnostics []analysis.Diagnostic)
func (SuiteSubtestRun) Name ¶ added in v1.4.0
func (SuiteSubtestRun) Name() string
type SuiteTHelper ¶
type SuiteTHelper struct{}
SuiteTHelper requires t.Helper() call in suite helpers:
func (s *RoomSuite) assertRoomRound(roundID RoundID) { s.T().Helper() s.Equal(roundID, s.getRoom().CurrentRound.ID) }
func NewSuiteTHelper ¶
func NewSuiteTHelper() SuiteTHelper
NewSuiteTHelper constructs SuiteTHelper checker.
func (SuiteTHelper) Check ¶
func (checker SuiteTHelper) Check(pass *analysis.Pass, inspector *inspector.Inspector) (diagnostics []analysis.Diagnostic)
func (SuiteTHelper) Name ¶
func (SuiteTHelper) Name() string
type UselessAssert ¶ added in v1.1.0
type UselessAssert struct{}
UselessAssert detects useless asserts like
assert.Contains(t, tt.value, tt.value) assert.ElementsMatch(t, tt.value, tt.value) assert.Equal(t, tt.value, tt.value) assert.EqualExportedValues(t, tt.value, tt.value) ... assert.True(t, num > num) assert.True(t, num < num) assert.True(t, num >= num) assert.True(t, num <= num) assert.True(t, num == num) assert.True(t, num != num) assert.False(t, num > num) assert.False(t, num < num) assert.False(t, num >= num) assert.False(t, num <= num) assert.False(t, num == num) assert.False(t, num != num) assert.Empty(t, "") assert.False(t, false) assert.Implements(t, (*any)(nil), new(Conn)) assert.Negative(t, -42) assert.Nil(t, nil) assert.NoError(t, nil) assert.NotEmpty(t, "value") assert.NotZero(t, 42) assert.NotZero(t, "value") assert.Positive(t, 42) assert.True(t, true) assert.Zero(t, 0) assert.Zero(t, "") assert.Zero(t, nil)
func NewUselessAssert ¶ added in v1.1.0
func NewUselessAssert() UselessAssert
NewUselessAssert constructs UselessAssert checker.
func (UselessAssert) Check ¶ added in v1.1.0
func (checker UselessAssert) Check(pass *analysis.Pass, call *CallMeta) *analysis.Diagnostic
func (UselessAssert) Name ¶ added in v1.1.0
func (UselessAssert) Name() string
Source Files ¶
- blank_import.go
- bool_compare.go
- call_meta.go
- checker.go
- checkers_registry.go
- compares.go
- contains.go
- empty.go
- encoded_compare.go
- error_is_as.go
- error_nil.go
- expected_actual.go
- float_compare.go
- formatter.go
- go_require.go
- helpers.go
- helpers_basic_type.go
- helpers_bool.go
- helpers_comparison.go
- helpers_context.go
- helpers_diagnostic.go
- helpers_encoded.go
- helpers_error.go
- helpers_format.go
- helpers_http.go
- helpers_interface.go
- helpers_len.go
- helpers_naming.go
- helpers_nil.go
- helpers_pkg_func.go
- helpers_suite.go
- helpers_testing.go
- len.go
- negative_positive.go
- nil_compare.go
- regexp.go
- require_error.go
- suite_broken_parallel.go
- suite_dont_use_pkg.go
- suite_extra_assert_call.go
- suite_subtest_run.go
- suite_thelper.go
- useless_assert.go
Directories ¶
Path | Synopsis |
---|---|
Package printf is a patched fork of https://github.com/golang/tools/blob/b6235391adb3b7f8bcfc4df81055e8f023de2688/go/analysis/passes/printf/printf.go#L538
|
Package printf is a patched fork of https://github.com/golang/tools/blob/b6235391adb3b7f8bcfc4df81055e8f023de2688/go/analysis/passes/printf/printf.go#L538 |