Skip to content

False positives on collect.Errorf calls #287

@iwittkau

Description

@iwittkau
type checker struct {
	foo  []any
	bar  []any
	name string
}

func (c *checker) cond(collect *assert.CollectT) {
	if c.foo == nil && c.bar == nil {
		collect.Errorf("precondition not satisfied")
	}
	require.NotEmpty(collect, c.name)
}

testifylint reports:

require-error: for error assertions use require

at collect.Errorf.

collect.Errorf reports an error and isn't an error assertion.

Interestingly, it's only reported when there's another testify call in the same scope.
If you remove the require.NotEmpty line, it's not triggered for the collect.Errorf call.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions