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

var-naming doesn't run on exported test functions #1124

Open
ivanvc opened this issue Nov 14, 2024 · 0 comments
Open

var-naming doesn't run on exported test functions #1124

ivanvc opened this issue Nov 14, 2024 · 0 comments

Comments

@ivanvc
Copy link

ivanvc commented Nov 14, 2024

Hi, thanks for the great work on revive. I checked the documentation and issues from var-naming, but couldn't find anything that explained this behavior. I'm unsure if it is intentional not to check exported test functions.

Describe the bug
The var-naming run doesn't run on exported test functions. i,e,. func TestValidIpAddress(t *testing.T). However, when unexporting the function it runs as expected.

To Reproduce

Steps to reproduce the behavior:

  1. Open a new file named var_naming_test.go
  2. Write the test function:
    package main
    
    import "testing"
    
    func TestValidIp(t *testing.T) {
    	t.Fatal("not implemented")
    }
  3. Run revive (with the default settings), i.e. revive ./... && echo $?

Expected behavior
It should have failed because of the wrong casing in the function name. i.e.,

var_naming_test.go:5:6: func TestValidIp should be TestValidIP

For example, when unexporting the test function (testValidIp) the linter fails as expected.

Logs
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Linux
  • Version of Go: 1.22.9 / 1.23.3
  • Revive version: 1.5.0

Additional context
We first identified this issue in our CI environment (as part of golangci-lint) and I was able to reproduce it locally. Ref: etcd-io/etcd#18816 (comment)

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

No branches or pull requests

1 participant