Antonboom / testifylint

The Golang linter that checks usage of github.com/stretchr/testify.
https://github.com/stretchr/testify
MIT License
97 stars 9 forks source link

`formatter` lint rule only warns when importing `assert` package #170

Open pgimalac opened 1 month ago

pgimalac commented 1 month ago

Here is a minimal reproducible example where the formatter rule should suggest not using fmt.Sprintf, but doesn't.

package main

import (
    "fmt"
    "testing"

    "github.com/stretchr/testify/require"
)

func TestA(t *testing.T) {
    require.True(t, false, fmt.Sprintf("expected %v, got %v", true, false))
}

Adding a blank import of github.com/stretchr/testify/assert (or any assertion using it) will make the formatter rule complain.

ccoVeille commented 1 month ago

Thanks for reporting this. I appreciate your feedback, and the minimum reproducible code.

We will have a look.

This one is indeed a bug, if confirmed.

The fix should be easy :tm: (famous last words 😅🤣)

pgimalac commented 1 month ago

I took a look and I believe I found the issue, I'll validate and open a PR.