Antonboom / testifylint

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

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

Closed pgimalac closed 1 month ago

pgimalac commented 3 months 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 3 months 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 3 months ago

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

Antonboom commented 1 month ago

@pgimalac thanks!

Fixed.