Skip to content

linters-settings.thelper.test.name not working #2848

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

Closed
4 tasks done
powerman opened this issue May 12, 2022 · 8 comments · Fixed by #2854
Closed
4 tasks done

linters-settings.thelper.test.name not working #2848

powerman opened this issue May 12, 2022 · 8 comments · Fixed by #2854
Labels
bug Something isn't working

Comments

@powerman
Copy link

powerman commented May 12, 2022

Welcome

  • Yes, I'm using a binary release within 2 latest major releases. Only such installations are supported.
  • Yes, I've searched similar issues on GitHub and didn't find any.
  • Yes, I've included all information below (version, config, etc).
  • Yes, I've tried with the standalone linter if available. (https://golangci-lint.run/usage/linters/)

Description of the problem

It's impossible to disable thelper's "t_name" check using .golangci.yml.

Version of golangci-lint

$ golangci-lint --version
golangci-lint has version 1.46.0 built from 7c1d8b75 on 2022-05-09T11:16:24Z

Configuration file

$ cat .golangci.yml
linters-settings:
  thelper:
    test:
      name: false

linters:
  disable-all: true
  enable:
    - thelper

Go environment

$ go version && go env
go version go1.18.2 linux/amd64
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/powerman/.cache/go-build"
GOENV="/home/powerman/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/powerman/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/powerman/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.18.2"
GCCGO="gccgo"
GOAMD64="v3"
AR="ar"
CC="x86_64-pc-linux-gnu-gcc"
CXX="x86_64-pc-linux-gnu-g++"
CGO_ENABLED="1"
GOMOD="/home/powerman/tmp/go/bug-golangci-lint-thelper/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build3888433916=/tmp/go-build -gno-record-gcc-switches"

Verbose output of running

$ golangci-lint cache clean
$ golangci-lint run -v
bug_test.go:5:6: parameter *testing.T should have name t (thelper)                               
func helper(tt *testing.T) {
     ^

Code example or link to a public repository

package bug_test

import "testing"

func helper(tt *testing.T) {
	tt.Helper()
}

func Test(tt *testing.T) {
	tt.Parallel()
	helper(tt)
}
@powerman powerman added the bug Something isn't working label May 12, 2022
@ldez
Copy link
Member

ldez commented May 12, 2022

Hello,
Have you tried to run the linter as a standalone command?
https://github.com/kulti/thelper

@powerman
Copy link
Author

Hello, Have you tried to run the linter as a standalone command? https://github.com/kulti/thelper

Yes - as you see I've checked this item.

@powerman
Copy link
Author

$ thelper -checks=b_begin,b_first,b_name,t_begin,t_first,tb_begin,tb_first,tb_name .
$ thelper -checks=b_begin,b_first,b_name,t_begin,t_first,t_name,tb_begin,tb_first,tb_name .                                                                         
/home/powerman/tmp/go/bug-golangci-lint-thelper/bug_test.go:5:6: parameter *testing.T should have name t

@ldez
Copy link
Member

ldez commented May 13, 2022

@ldez ldez closed this as completed May 13, 2022
@ldez ldez added question Further information is requested and removed bug Something isn't working labels May 13, 2022
@cbandy
Copy link
Contributor

cbandy commented May 14, 2022

I think .golangci.example.yml needs to change to resolve this. It shows values set to false, but the author says:

You cannot configure golangci-lint using false.

thelper:
# The following configurations enable all checks.
# All checks are enabled by default.
test:
first: false
name: false
begin: false
benchmark:
first: false
name: false
begin: false
tb:
first: false
name: false
begin: false

@ldez
Copy link
Member

ldez commented May 14, 2022

The problem is the default behavior of the linter itself.

@ldez
Copy link
Member

ldez commented May 14, 2022

I will try to override the behavior in golangci-lint but it's not the right place IMHO.

@ldez
Copy link
Member

ldez commented May 14, 2022

In fact, since v1.46.0, thelper doesn't work inside golangci-lint with projects using go1.17 even with golangci-lint compile with go1.18.

I'm working on a fix.
I think I will also open an issue.

Edit:

@ldez ldez added bug Something isn't working and removed question Further information is requested labels May 14, 2022
@ldez ldez reopened this May 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants