diff --git a/.golangci.yml b/.golangci.yml index 9d3048d8602..f74587f3ff9 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -21,7 +21,6 @@ issues: skip-files: - cron/data/request.pb.go # autogenerated linters: - disable-all: true enable: - asciicheck - dogsled @@ -70,8 +69,13 @@ linters: - usestdlibvars - whitespace - wrapcheck + disable: + - exhaustruct # initializing every struct makes tests longer without much benefit (spencerschrock) + - paralleltest # need to investigate rate limit issues before re-enabling? (#2527) + - testpackage # tests don't need their own package (spencerschrock) presets: - bugs + - test linters-settings: errcheck: check-type-assertions: true diff --git a/checks/raw/pinned_dependencies_test.go b/checks/raw/pinned_dependencies_test.go index bd0e804ff31..168bc7f0539 100644 --- a/checks/raw/pinned_dependencies_test.go +++ b/checks/raw/pinned_dependencies_test.go @@ -102,6 +102,7 @@ func TestGithubWorkflowPinning(t *testing.T) { } func TestGithubWorkflowPinningPattern(t *testing.T) { + t.Parallel() tests := []struct { desc string uses string diff --git a/clients/cii_response_test.go b/clients/cii_response_test.go index 85cb119895e..81c75620dfb 100644 --- a/clients/cii_response_test.go +++ b/clients/cii_response_test.go @@ -86,6 +86,7 @@ func TestBadgeResponse_AsJSON(t *testing.T) { } t.Run(tt.name, func(t *testing.T) { + t.Parallel() resp := BadgeResponse{ BadgeLevel: tt.fields.BadgeLevel, } diff --git a/clients/githubrepo/roundtripper/rate_limit_test.go b/clients/githubrepo/roundtripper/rate_limit_test.go index 83b50291581..9f60b33faf4 100644 --- a/clients/githubrepo/roundtripper/rate_limit_test.go +++ b/clients/githubrepo/roundtripper/rate_limit_test.go @@ -61,6 +61,7 @@ func TestRoundTrip(t *testing.T) { } t.Run("Successful response", func(t *testing.T) { + t.Parallel() req, err := http.NewRequestWithContext(context.Background(), http.MethodGet, ts.URL+"/success", nil) if err != nil { t.Fatalf("Failed to create request: %v", err) @@ -77,6 +78,7 @@ func TestRoundTrip(t *testing.T) { }) t.Run("Retry-After header set", func(t *testing.T) { + t.Parallel() req, err := http.NewRequestWithContext(context.Background(), http.MethodGet, ts.URL+"/retry", nil) if err != nil { t.Fatalf("Failed to create request: %v", err) diff --git a/dependencydiff/dependencydiff_test.go b/dependencydiff/dependencydiff_test.go index 9a4699fcdb6..e936a6aa648 100644 --- a/dependencydiff/dependencydiff_test.go +++ b/dependencydiff/dependencydiff_test.go @@ -57,7 +57,6 @@ func Test_initRepoAndClientByChecks(t *testing.T) { for _, tt := range tests { tt := tt t.Run(tt.name, func(t *testing.T) { - t.Parallel() err := initRepoAndClientByChecks(&tt.dCtx, tt.srcRepo) if (err != nil) != tt.wantErr { t.Errorf("initClientByChecks() error = {%v}, want error: %v", err, tt.wantErr) @@ -84,7 +83,6 @@ func Test_initRepoAndClientByChecks(t *testing.T) { } func Test_getScorecardCheckResults(t *testing.T) { - //nolint tests := []struct { name string dCtx dependencydiffContext @@ -104,7 +102,6 @@ func Test_getScorecardCheckResults(t *testing.T) { for _, tt := range tests { tt := tt t.Run(tt.name, func(t *testing.T) { - t.Parallel() err := getScorecardCheckResults(&tt.dCtx) if (err != nil) != tt.wantErr { t.Errorf("getScorecardCheckResults() error = {%v}, want error: %v", err, tt.wantErr) diff --git a/errors/public_test.go b/errors/public_test.go index 460a93a2a97..70339ea0123 100644 --- a/errors/public_test.go +++ b/errors/public_test.go @@ -48,7 +48,9 @@ func TestWithMessage(t *testing.T) { }, } for _, tt := range tests { + tt := tt t.Run(tt.name, func(t *testing.T) { + t.Parallel() if err := WithMessage(tt.args.e, tt.args.msg); (err != nil) != tt.wantErr { t.Errorf("WithMessage() error = %v, wantErr %v", err, tt.wantErr) } @@ -96,7 +98,9 @@ func TestGetName(t *testing.T) { }, } for _, tt := range tests { + tt := tt t.Run(tt.name, func(t *testing.T) { + t.Parallel() if got := GetName(tt.args.err); !strings.EqualFold(got, tt.want) { t.Errorf("GetName() = %v, want %v", got, tt.want) } diff --git a/log/log_test.go b/log/log_test.go index a45ec84208d..5150f3b6340 100644 --- a/log/log_test.go +++ b/log/log_test.go @@ -55,6 +55,7 @@ func TestNewLogger(t *testing.T) { } func TestParseLevel(t *testing.T) { + t.Parallel() tests := []struct { name string levelStr string diff --git a/options/flags_test.go b/options/flags_test.go index bf20642ecf8..4dbd6f5c6b4 100644 --- a/options/flags_test.go +++ b/options/flags_test.go @@ -120,6 +120,7 @@ func TestOptions_AddFlags(t *testing.T) { } func TestOptions_AddFlags_ChecksToRun(t *testing.T) { + t.Parallel() tests := []struct { name string opts *Options diff --git a/policy/policy_test.go b/policy/policy_test.go index 9a8722b8907..654eb224670 100644 --- a/policy/policy_test.go +++ b/policy/policy_test.go @@ -346,7 +346,9 @@ func TestGetEnabled(t *testing.T) { } for _, tt := range tests { + tt := tt t.Run(tt.name, func(t *testing.T) { + t.Parallel() var sp *ScorecardPolicy if tt.policyFile != "" { policyBytes, err := os.ReadFile(tt.policyFile) diff --git a/rule/rule_test.go b/rule/rule_test.go index e84de19d47f..dbed1155f29 100644 --- a/rule/rule_test.go +++ b/rule/rule_test.go @@ -120,6 +120,7 @@ func TestRisk_GreaterThan(t *testing.T) { for _, tt := range tests { tt := tt t.Run(tt.name, func(t *testing.T) { + t.Parallel() if got := tt.r.GreaterThan(tt.rr); got != tt.want { t.Errorf("Risk.GreaterThan() = %v, want %v", got, tt.want) } @@ -170,6 +171,7 @@ func TestRisk_String(t *testing.T) { for _, tt := range tests { tt := tt t.Run(tt.name, func(t *testing.T) { + t.Parallel() if got := tt.r.String(); got != tt.want { t.Errorf("Risk.String() = %v, want %v", got, tt.want) } @@ -215,6 +217,7 @@ func TestRemediationEffort_String(t *testing.T) { for _, tt := range tests { tt := tt t.Run(tt.name, func(t *testing.T) { + t.Parallel() if got := tt.effort.String(); got != tt.want { t.Errorf("RemediationEffort.String() = %v, want %v", got, tt.want) } @@ -261,6 +264,7 @@ func TestRisk_UnmarshalYAML(t *testing.T) { for _, tt := range tests { tt := tt t.Run(tt.name, func(t *testing.T) { + t.Parallel() var r Risk err := yaml.Unmarshal([]byte(tt.input), &r) if err != nil { @@ -305,6 +309,7 @@ func TestRemediationEffort_UnmarshalYAML(t *testing.T) { for _, tt := range tests { tt := tt t.Run(tt.name, func(t *testing.T) { + t.Parallel() var r RemediationEffort err := yaml.Unmarshal([]byte(tt.input), &r) if err != nil { @@ -353,6 +358,7 @@ func Test_validate(t *testing.T) { for _, tt := range tests { tt := tt t.Run(tt.name, func(t *testing.T) { + t.Parallel() err := validate(tt.rule) if err != nil { if tt.wantErr == nil || !cmp.Equal(tt.wantErr.Error(), err.Error()) {