Skip to content

Commit 07e11d4

Browse files
authored
chore: fix thelper linter (#1287)
1 parent 009f5b6 commit 07e11d4

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

.golangci.yml

+1-7
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ linters:
4848
- stylecheck # Stylecheck is a replacement for golint [fast: false, auto-fix: false]
4949
- tagliatelle # Checks the struct tags. [fast: true, auto-fix: false]
5050
- tenv # tenv is analyzer that detects using os.Setenv instead of t.Setenv since Go1.17 [fast: false, auto-fix: false]
51+
- thelper # thelper detects golang test helpers without t.Helper() call and checks the consistency of test helpers [fast: false, auto-fix: false]
5152
- tparallel # tparallel detects inappropriate usage of t.Parallel() method in your Go test codes [fast: false, auto-fix: false]
5253
- typecheck # Like the front-end of a Go compiler, parses and type-checks Go code [fast: false, auto-fix: false]
5354
- unconvert # Remove unnecessary type conversions [fast: false, auto-fix: false]
@@ -61,7 +62,6 @@ linters:
6162
- dupl # Tool for code clone detection [fast: true, auto-fix: false]
6263
- errorlint # errorlint is a linter for that can be used to find code that will cause problems with the error wrapping scheme introduced in Go 1.13. [fast: false, auto-fix: false]
6364
- exhaustive # check exhaustiveness of enum switch statements [fast: false, auto-fix: false]
64-
- exhaustivestruct #[deprecated]: Checks if all struct's fields are initialized [fast: false, auto-fix: false]
6565
- exhaustruct # Checks if all structure fields are initialized [fast: false, auto-fix: false]
6666
- forcetypeassert # finds forced type assertions [fast: true, auto-fix: false]
6767
- funlen # Tool for detection of long functions [fast: true, auto-fix: false]
@@ -73,24 +73,18 @@ linters:
7373
- godox # Tool for detection of FIXME, TODO and other comment keywords [fast: true, auto-fix: false]
7474
- goerr113 # Golang linter to check the errors handling expressions [fast: false, auto-fix: false]
7575
- gofumpt # Gofumpt checks whether code was gofumpt-ed. [fast: true, auto-fix: true]
76-
- golint #[deprecated]: Golint differs from gofmt. Gofmt reformats Go source code, whereas golint prints out style mistakes [fast: false, auto-fix: false]
7776
- gomnd # An analyzer to detect magic numbers. [fast: true, auto-fix: false]
7877
- gosec #(gas): Inspects source code for security problems [fast: false, auto-fix: false]
79-
- interfacer #[deprecated]: Linter that suggests narrower interface types [fast: false, auto-fix: false]
8078
- lll # Reports long lines [fast: true, auto-fix: false]
8179
- maintidx # maintidx measures the maintainability index of each function. [fast: true, auto-fix: false]
82-
- maligned #[deprecated]: Tool to detect Go structs that would take less memory if their fields were sorted [fast: false, auto-fix: false]
8380
- nestif # Reports deeply nested if statements [fast: true, auto-fix: false]
8481
- nilnil # Checks that there is no simultaneous return of `nil` error and an invalid value. [fast: false, auto-fix: false]
8582
- nlreturn # nlreturn checks for a new line before return and branch statements to increase code clarity [fast: true, auto-fix: false]
8683
- nonamedreturns # Reports all named returns [fast: true, auto-fix: false]
8784
- paralleltest # paralleltest detects missing usage of t.Parallel() method in your Go test [fast: true, auto-fix: false]
8885
- prealloc # Finds slice declarations that could potentially be preallocated [fast: true, auto-fix: false]
8986
- predeclared # find code that shadows one of Go's predeclared identifiers [fast: true, auto-fix: false]
90-
- scopelint #[deprecated]: Scopelint checks for unpinned variables in go programs [fast: true, auto-fix: false]
9187
- staticcheck #(megacheck): Staticcheck is a go vet on steroids, applying a ton of static analysis checks [fast: false, auto-fix: false]
92-
- testpackage # linter that makes you use a separate _test package [fast: true, auto-fix: false]
93-
- thelper # thelper detects golang test helpers without t.Helper() call and checks the consistency of test helpers [fast: false, auto-fix: false]
9488
- unparam # Reports unused function parameters [fast: false, auto-fix: false]
9589
- unused #(megacheck): Checks Go code for unused constants, variables, functions and types [fast: false, auto-fix: false]
9690
- varnamelen # checks that the length of a variable's name matches its scope [fast: false, auto-fix: false]

scaleway/provider_test.go

+3
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ func testAccPreCheck(_ *testing.T) {}
2828

2929
// getTestFilePath returns a valid filename path based on the go test name and suffix. (Take care of non fs friendly char)
3030
func getTestFilePath(t *testing.T, suffix string) string {
31+
t.Helper()
3132
specialChars := regexp.MustCompile(`[\\?%*:|"<>. ]`)
3233

3334
// Replace nested tests separators.
@@ -51,6 +52,7 @@ func getTestFilePath(t *testing.T, suffix string) string {
5152
// It is important to add a `defer cleanup()` so the given cassette files are correctly
5253
// closed and saved after the requests.
5354
func getHTTPRecoder(t *testing.T, update bool) (client *http.Client, cleanup func(), err error) {
55+
t.Helper()
5456
recorderMode := recorder.ModeReplaying
5557
if update {
5658
recorderMode = recorder.ModeRecording
@@ -85,6 +87,7 @@ type TestTools struct {
8587
}
8688

8789
func NewTestTools(t *testing.T) *TestTools {
90+
t.Helper()
8891
ctx := context.Background()
8992
// Create a http client with recording capabilities
9093
httpClient, cleanup, err := getHTTPRecoder(t, *UpdateCassettes)

0 commit comments

Comments
 (0)