Skip to content

Commit 1625b0c

Browse files
🌱 Disable more style linters for test files (#3707)
* disable lll linter for test files * disable goerr113 linter for tests * disable wrapcheck linter for tests * fix easy linter issues in tests --------- Signed-off-by: Spencer Schrock <[email protected]>
1 parent 4d1621b commit 1625b0c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+76
-115
lines changed

.golangci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ issues:
1818
- funlen
1919
- goconst
2020
- gocyclo
21+
- goerr113
22+
- lll
23+
- wrapcheck
2124
skip-files:
2225
- cron/data/request.pb.go # autogenerated
2326
linters:

checker/check_result_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ func TestCreateProportionalScoreResult(t *testing.T) {
545545
tt := tt
546546
t.Run(tt.name, func(t *testing.T) {
547547
t.Parallel()
548-
if got := CreateProportionalScoreResult(tt.args.name, tt.args.reason, tt.args.b, tt.args.t); !cmp.Equal(got, tt.want) { //nolint:lll
548+
if got := CreateProportionalScoreResult(tt.args.name, tt.args.reason, tt.args.b, tt.args.t); !cmp.Equal(got, tt.want) {
549549
t.Errorf("CreateProportionalScoreResult() = %v, want %v", got, cmp.Diff(got, tt.want))
550550
}
551551
})
@@ -714,14 +714,14 @@ func TestCreateRuntimeErrorResult(t *testing.T) {
714714
name: "empty",
715715
args: args{
716716
name: "",
717-
e: errors.New("runtime error"), //nolint:goerr113
717+
e: errors.New("runtime error"),
718718
},
719719
want: CheckResult{
720720
Name: "",
721721
Reason: "runtime error",
722722
Score: -1,
723723
Version: 2,
724-
Error: errors.New("runtime error"), //nolint:goerr113
724+
Error: errors.New("runtime error"),
725725
},
726726
},
727727
}

checker/client_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ func TestGetClients(t *testing.T) {
106106
t.Setenv("GH_HOST", "github.corp.com")
107107
t.Setenv("GH_TOKEN", "PAT")
108108
}
109-
got, repoClient, ossFuzzClient, ciiClient, vulnsClient, err := GetClients(tt.args.ctx, tt.args.repoURI, tt.args.localURI, tt.args.logger) //nolint:lll
109+
got, repoClient, ossFuzzClient, ciiClient, vulnsClient, err := GetClients(tt.args.ctx, tt.args.repoURI, tt.args.localURI, tt.args.logger)
110110
if (err != nil) != tt.wantErr {
111111
t.Fatalf("GetClients() error = %v, wantErr %v", err, tt.wantErr)
112112
}

checks/ci_tests_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ func TestCITestsRuntimeError(t *testing.T) {
2929

3030
ctrl := gomock.NewController(t)
3131
mockRepoClient := mockrepo.NewMockRepoClient(ctrl)
32-
//nolint:goerr113
3332
mockRepoClient.EXPECT().ListCommits().Return(nil, fmt.Errorf("some runtime error")).AnyTimes()
3433

3534
req := checker.CheckRequest{

checks/code_review_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import (
3030
// TestCodeReview tests the code review checker.
3131
func TestCodereview(t *testing.T) {
3232
t.Parallel()
33-
//nolint:goerr113
3433
tests := []struct {
3534
err error
3635
name string

checks/contributors_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ func TestContributors(t *testing.T) {
143143
},
144144
},
145145
{
146-
err: errors.New("error"), //nolint:goerr113
146+
err: errors.New("error"),
147147
name: "Error getting contributors",
148148
contrib: []clients.User{},
149149
expected: checker.CheckResult{

checks/evaluation/ci_tests_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,10 @@ func Test_prHasSuccessfulCheck(t *testing.T) {
192192
tt := tt
193193
dl := &scut.TestDetailLogger{}
194194

195-
//nolint:errcheck
196-
got, _ := prHasSuccessfulCheck(tt.args, dl)
195+
got, err := prHasSuccessfulCheck(tt.args, dl)
196+
if err != nil {
197+
t.Fatalf("unexpected err: %v", err)
198+
}
197199
if got != tt.want {
198200
t.Errorf("prHasSuccessfulCheck() = %v, want %v", got, tt.want)
199201
}

checks/fileparser/listing_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,6 @@ func TestOnMatchingFileContent(t *testing.T) {
515515
t.Parallel()
516516
x := func(path string, content []byte, args ...interface{}) (bool, error) {
517517
if tt.shouldFuncFail {
518-
//nolint:goerr113
519518
return false, errors.New("test error")
520519
}
521520
if tt.shouldGetPredicateFail {

checks/fuzzing_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@ func TestFuzzing(t *testing.T) {
139139
mockFuzz.EXPECT().Search(gomock.Any()).
140140
DoAndReturn(func(q clients.SearchRequest) (clients.SearchResponse, error) {
141141
if tt.wantErr {
142-
//nolint:goerr113
143142
return clients.SearchResponse{}, errors.New("error")
144143
}
145144
return tt.response, nil
@@ -148,7 +147,6 @@ func TestFuzzing(t *testing.T) {
148147
mockFuzz.EXPECT().ListFiles(gomock.Any()).Return(tt.fileName, nil).AnyTimes()
149148
mockFuzz.EXPECT().GetFileContent(gomock.Any()).DoAndReturn(func(f string) (string, error) {
150149
if tt.wantErr {
151-
//nolint:goerr113
152150
return "", errors.New("error")
153151
}
154152
return tt.fileContent, nil

checks/maintained_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func Test_Maintained(t *testing.T) {
4444
otheruser := clients.User{
4545
Login: "someone-else",
4646
}
47-
//nolint:govet,goerr113
47+
//nolint:govet
4848
tests := []struct {
4949
err error
5050
name string

0 commit comments

Comments
 (0)