Skip to content

Commit a39e83c

Browse files
committed
chore: Update golangci-lint to v2
Signed-off-by: Steve Hipwell <[email protected]>
1 parent 38e68ad commit a39e83c

File tree

3,443 files changed

+324001
-108986
lines changed

Some content is hidden

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

3,443 files changed

+324001
-108986
lines changed

.golangci.yml

Lines changed: 57 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,71 @@
1-
# Visit https://golangci-lint.run/ for usage documentation
2-
# and information on other useful linters
3-
1+
version: "2"
42
run:
5-
deadline: 3m
63
modules-download-mode: vendor
74

8-
issues:
9-
max-per-linter: 0
10-
max-same-issues: 0
11-
125
linters:
13-
disable-all: true
6+
default: none
7+
148
enable:
9+
- copyloopvar
1510
- durationcheck
1611
- errcheck
17-
- exportloopref
18-
# - forcetypeassert
19-
# - godot
20-
- gofmt
21-
- gosimple
12+
- errname
13+
- errorlint
14+
- forcetypeassert
15+
- godot
16+
- govet
2217
- ineffassign
2318
- makezero
2419
- misspell
25-
# - nilerr
26-
# - predeclared
20+
- modernize
21+
- nilerr
22+
- predeclared
2723
- staticcheck
28-
- tenv
2924
- unconvert
30-
# - unparam
25+
- unparam
3126
- unused
32-
- vet
27+
- usetesting
28+
29+
exclusions:
30+
generated: lax
31+
presets:
32+
- comments
33+
- common-false-positives
34+
- legacy
35+
- std-error-handling
36+
paths:
37+
- third_party$
38+
- builtin$
39+
- examples$
40+
41+
issues:
42+
max-issues-per-linter: 0
43+
max-same-issues: 0
44+
45+
formatters:
46+
enable:
47+
- gofmt
48+
- gofumpt
49+
- goimports
50+
51+
settings:
52+
gofmt:
53+
simplify: true
54+
rewrite-rules:
55+
- pattern: interface{}
56+
replacement: any
57+
- pattern: a[b:len(a)]
58+
replacement: a[b:]
59+
gofumpt:
60+
module-path: github.com/integrations/terraform-provider-github
61+
extra-rules: true
62+
goimports:
63+
local-prefixes:
64+
- github.com/integrations/terraform-provider-github
3365

34-
linters-settings:
35-
errcheck:
36-
ignore: github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema:ForceNew|Set,fmt:.*,io:Close
66+
exclusions:
67+
generated: lax
68+
paths:
69+
- third_party$
70+
- builtin$
71+
- examples$

GNUmakefile

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
TEST?=$$(go list ./... |grep -v 'vendor')
2-
GOFMT_FILES?=$$(find . -name '*.go' |grep -v vendor)
32
WEBSITE_REPO=github.com/hashicorp/terraform-website
43
PKG_NAME=github
54

65
default: build
76

87
tools:
98
go install github.com/client9/misspell/cmd/[email protected]
10-
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.51.1
9+
go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.6.0
1110

1211
build: fmtcheck
1312
CGO_ENABLED=0 go build -ldflags="-s -w" ./...
1413

1514
fmt:
16-
@echo "==> Fixing source code with gofmt..."
17-
gofmt -s -w $(GOFMT_FILES)
15+
@echo "==> Fixing source code with golangci-lint..."
16+
golangci-lint fmt ./...
1817

1918
fmtcheck:
2019
@sh -c "'$(CURDIR)/scripts/gofmtcheck.sh'"
@@ -38,15 +37,6 @@ test-compile:
3837
fi
3938
CGO_ENABLED=0 go test -c $(TEST) $(TESTARGS)
4039

41-
vet:
42-
@echo "go vet ."
43-
@go vet $$(go list ./... | grep -v vendor/) ; if [ $$? -eq 1 ]; then \
44-
echo ""; \
45-
echo "Vet found suspicious constructs. Please check the reported constructs"; \
46-
echo "and fix them if necessary before submitting the code for review."; \
47-
exit 1; \
48-
fi
49-
5040
website:
5141
ifeq (,$(wildcard $(GOPATH)/src/$(WEBSITE_REPO)))
5242
echo "$(WEBSITE_REPO) not found in your GOPATH (necessary for layouts and assets), get-ting..."
@@ -65,4 +55,4 @@ ifeq (,$(wildcard $(GOPATH)/src/$(WEBSITE_REPO)))
6555
endif
6656
@$(MAKE) -C $(GOPATH)/src/$(WEBSITE_REPO) website-provider-test PROVIDER_PATH=$(shell pwd) PROVIDER_NAME=$(PKG_NAME)
6757

68-
.PHONY: build test testacc vet fmt fmtcheck lint tools test-compile website website-lint website-test
58+
.PHONY: build test testacc fmt fmtcheck lint tools test-compile website website-lint website-test

github/apps.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func GenerateOAuthTokenFromApp(baseURL, appID, appInstallationID, pemData string
3030
return token, nil
3131
}
3232

33-
func getInstallationAccessToken(baseURL string, jwt string, installationID string) (string, error) {
33+
func getInstallationAccessToken(baseURL, jwt, installationID string) (string, error) {
3434
if baseURL != "https://api.github.com/" && !GHECDataResidencyMatch.MatchString(baseURL) {
3535
baseURL += "api/v3/"
3636
}
@@ -87,7 +87,6 @@ func generateAppJWT(appID string, now time.Time, pemData []byte) (string, error)
8787
jose.SigningKey{Algorithm: jose.RS256, Key: privateKey},
8888
(&jose.SignerOptions{}).WithType("JWT"),
8989
)
90-
9190
if err != nil {
9291
return "", err
9392
}

github/apps_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@ func TestGetInstallationAccessToken(t *testing.T) {
158158
defer ts.Close()
159159

160160
accessToken, err := getInstallationAccessToken(ts.URL+"/", fakeJWT, testGitHubAppInstallationID)
161-
162161
if err != nil {
163162
t.Logf("Unexpected error: %s", err)
164163
t.Fail()

github/config.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ type Owner struct {
4141
// https://[hostname].ghe.com instances expect paths that behave similar to GitHub.com, not GitHub Enterprise Server.
4242
var GHECDataResidencyMatch = regexp.MustCompile(`^https:\/\/[a-zA-Z0-9.\-]*\.ghe\.com$`)
4343

44-
func RateLimitedHTTPClient(client *http.Client, writeDelay time.Duration, readDelay time.Duration, retryDelay time.Duration, parallelRequests bool, retryableErrors map[int]bool, maxRetries int) *http.Client {
45-
44+
func RateLimitedHTTPClient(client *http.Client, writeDelay, readDelay, retryDelay time.Duration, parallelRequests bool, retryableErrors map[int]bool, maxRetries int) *http.Client {
4645
client.Transport = NewEtagTransport(client.Transport)
4746
client.Transport = NewRateLimitTransport(client.Transport, WithWriteDelay(writeDelay), WithReadDelay(readDelay), WithParallelRequests(parallelRequests))
4847
client.Transport = logging.NewSubsystemLoggingHTTPTransport("GitHub", client.Transport)
@@ -59,7 +58,6 @@ func RateLimitedHTTPClient(client *http.Client, writeDelay time.Duration, readDe
5958
}
6059

6160
func (c *Config) AuthenticatedHTTPClient() *http.Client {
62-
6361
ctx := context.Background()
6462
ts := oauth2.StaticTokenSource(
6563
&oauth2.Token{AccessToken: c.Token},
@@ -79,7 +77,6 @@ func (c *Config) AnonymousHTTPClient() *http.Client {
7977
}
8078

8179
func (c *Config) NewGraphQLClient(client *http.Client) (*githubv4.Client, error) {
82-
8380
uv4, err := url.Parse(c.BaseURL)
8481
if err != nil {
8582
return nil, err
@@ -95,7 +92,6 @@ func (c *Config) NewGraphQLClient(client *http.Client) (*githubv4.Client, error)
9592
}
9693

9794
func (c *Config) NewRESTClient(client *http.Client) (*github.Client, error) {
98-
9995
uv3, err := url.Parse(c.BaseURL)
10096
if err != nil {
10197
return nil, err
@@ -143,8 +139,7 @@ func (c *Config) ConfigureOwner(owner *Owner) (*Owner, error) {
143139

144140
// Meta returns the meta parameter that is passed into subsequent resources
145141
// https://godoc.org/github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema#ConfigureFunc
146-
func (c *Config) Meta() (interface{}, error) {
147-
142+
func (c *Config) Meta() (any, error) {
148143
var client *http.Client
149144
if c.Anonymous() {
150145
client = c.AnonymousHTTPClient()

github/config_test.go

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,12 @@ func TestGHECDataResidencyMatch(t *testing.T) {
6666
}
6767

6868
func TestAccConfigMeta(t *testing.T) {
69-
7069
// FIXME: Skip test runs during travis lint checking
7170
if testToken == "" {
7271
return
7372
}
7473

7574
t.Run("returns an anonymous client for the v3 REST API", func(t *testing.T) {
76-
7775
config := Config{BaseURL: "https://api.github.com/"}
7876
meta, err := config.Meta()
7977
if err != nil {
@@ -86,18 +84,14 @@ func TestAccConfigMeta(t *testing.T) {
8684
if err != nil {
8785
t.Fatalf("failed to validate returned client without error: %s", err.Error())
8886
}
89-
9087
})
9188

9289
t.Run("returns an anonymous client for the v4 GraphQL API", func(t *testing.T) {
93-
9490
// https://developer.github.com/v4/guides/forming-calls/#authenticating-with-graphql
9591
t.Skip("anonymous client for the v4 GraphQL API is unsupported")
96-
9792
})
9893

9994
t.Run("returns a v3 REST API client to manage individual resources", func(t *testing.T) {
100-
10195
config := Config{
10296
Token: testToken,
10397
BaseURL: "https://api.github.com/",
@@ -113,11 +107,9 @@ func TestAccConfigMeta(t *testing.T) {
113107
if err != nil {
114108
t.Fatalf("failed to validate returned client without error: %s", err.Error())
115109
}
116-
117110
})
118111

119112
t.Run("returns a v3 REST API client with max retries", func(t *testing.T) {
120-
121113
config := Config{
122114
Token: testToken,
123115
BaseURL: "https://api.github.com/",
@@ -138,11 +130,9 @@ func TestAccConfigMeta(t *testing.T) {
138130
if err != nil {
139131
t.Fatalf("failed to validate returned client without error: %s", err.Error())
140132
}
141-
142133
})
143134

144135
t.Run("returns a v4 GraphQL API client to manage individual resources", func(t *testing.T) {
145-
146136
config := Config{
147137
Token: testToken,
148138
BaseURL: "https://api.github.com/",
@@ -162,11 +152,9 @@ func TestAccConfigMeta(t *testing.T) {
162152
if err != nil {
163153
t.Fatalf("failed to validate returned client without error: %s", err.Error())
164154
}
165-
166155
})
167156

168157
t.Run("returns a v3 REST API client to manage organization resources", func(t *testing.T) {
169-
170158
config := Config{
171159
Token: testToken,
172160
BaseURL: "https://api.github.com/",
@@ -183,11 +171,9 @@ func TestAccConfigMeta(t *testing.T) {
183171
if err != nil {
184172
t.Fatalf("failed to validate returned client without error: %s", err.Error())
185173
}
186-
187174
})
188175

189176
t.Run("returns a v4 GraphQL API client to manage organization resources", func(t *testing.T) {
190-
191177
config := Config{
192178
Token: testToken,
193179
BaseURL: "https://api.github.com/",
@@ -205,7 +191,7 @@ func TestAccConfigMeta(t *testing.T) {
205191
ViewerCanAdminister githubv4.Boolean
206192
} `graphql:"organization(login: $login)"`
207193
}
208-
variables := map[string]interface{}{
194+
variables := map[string]any{
209195
"login": githubv4.String(testOrganization),
210196
}
211197
err = client.Query(context.Background(), &query, variables)
@@ -216,7 +202,5 @@ func TestAccConfigMeta(t *testing.T) {
216202
if query.Organization.ViewerCanAdminister != true {
217203
t.Fatalf("unexpected response when validating client")
218204
}
219-
220205
})
221-
222206
}

github/data_source_github_actions_environment_secrets.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func dataSourceGithubActionsEnvironmentSecrets() *schema.Resource {
5555
}
5656
}
5757

58-
func dataSourceGithubActionsEnvironmentSecretsRead(d *schema.ResourceData, meta interface{}) error {
58+
func dataSourceGithubActionsEnvironmentSecretsRead(d *schema.ResourceData, meta any) error {
5959
client := meta.(*Owner).v3client
6060
owner := meta.(*Owner).name
6161
var repoName string

github/data_source_github_actions_environment_secrets_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
)
1010

1111
func TestAccGithubActionsEnvironmentSecretsDataSource(t *testing.T) {
12-
1312
t.Run("queries actions secrets from an environment", func(t *testing.T) {
1413
randomID := acctest.RandStringFromCharSet(5, acctest.CharSetAlphaNum)
1514

github/data_source_github_actions_environment_variables.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func dataSourceGithubActionsEnvironmentVariables() *schema.Resource {
5959
}
6060
}
6161

62-
func dataSourceGithubActionsEnvironmentVariablesRead(d *schema.ResourceData, meta interface{}) error {
62+
func dataSourceGithubActionsEnvironmentVariablesRead(d *schema.ResourceData, meta any) error {
6363
client := meta.(*Owner).v3client
6464
owner := meta.(*Owner).name
6565
var repoName string

github/data_source_github_actions_environment_variables_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
)
1111

1212
func TestAccGithubActionsEnvironmentVariablesDataSource(t *testing.T) {
13-
1413
t.Run("queries actions variables from an environment", func(t *testing.T) {
1514
randomID := acctest.RandStringFromCharSet(5, acctest.CharSetAlphaNum)
1615

0 commit comments

Comments
 (0)