Skip to content

Commit 8c92869

Browse files
update golint version (#2083)
1 parent 1744ff2 commit 8c92869

27 files changed

+141
-115
lines changed

Diff for: .golangci.yml

+65-20
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,72 @@
1-
linters-settings:
2-
misspell:
3-
locale: US
4-
1+
version: "2"
52
linters:
63
disable-all: true
74
enable:
8-
- typecheck
9-
- goimports
10-
- misspell
11-
- revive
5+
- durationcheck
6+
- gocritic
7+
- gomodguard
128
- govet
139
- ineffassign
14-
- gosimple
10+
- misspell
11+
- revive
12+
- staticcheck
13+
- unconvert
1514
- unused
16-
- gocritic
17-
15+
- usetesting
16+
- whitespace
17+
settings:
18+
misspell:
19+
locale: US
20+
staticcheck:
21+
checks:
22+
- all
23+
- -SA1008
24+
- -SA1019
25+
- -SA4000
26+
- -SA9004
27+
- -ST1000
28+
- -ST1005
29+
- -ST1016
30+
- -ST1021
31+
- -ST1020
32+
- -U1000
33+
exclusions:
34+
generated: lax
35+
rules:
36+
- path: (.+)\.go$
37+
text: "empty-block:"
38+
- path: (.+)\.go$
39+
text: "unused-parameter:"
40+
- path: (.+)\.go$
41+
text: "dot-imports:"
42+
- path: (.+)\.go$
43+
text: "singleCaseSwitch: should rewrite switch statement to if statement"
44+
- path: (.+)\.go$
45+
text: "unlambda: replace"
46+
- path: (.+)\.go$
47+
text: "captLocal:"
48+
- path: (.+)\.go$
49+
text: "should have a package comment"
50+
- path: (.+)\.go$
51+
text: "ifElseChain:"
52+
- path: (.+)\.go$
53+
text: "elseif:"
54+
- path: (.+)\.go$
55+
text: "Error return value of"
56+
- path: (.+)\.go$
57+
text: "unnecessary conversion"
58+
- path: (.+)\.go$
59+
text: "Error return value is not checked"
1860
issues:
19-
exclude-use-default: false
20-
exclude:
21-
# todo fix these when we get enough time.
22-
- "singleCaseSwitch: should rewrite switch statement to if statement"
23-
- "unlambda: replace"
24-
- "captLocal:"
25-
- "ifElseChain:"
26-
- "elseif:"
27-
- "should have a package comment"
61+
max-issues-per-linter: 100
62+
max-same-issues: 100
63+
formatters:
64+
enable:
65+
- gofumpt
66+
- goimports
67+
exclusions:
68+
generated: lax
69+
paths:
70+
- third_party$
71+
- builtin$
72+
- examples$

Diff for: api-bucket-notification.go

-1
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,6 @@ func (c *Client) ListenBucketNotification(ctx context.Context, bucketName, prefi
251251

252252
// Close current connection before looping further.
253253
closeResponse(resp)
254-
255254
}
256255
}(notificationInfoCh)
257256

Diff for: api-get-object-acl.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -135,16 +135,16 @@ func getAmzGrantACL(aCPolicy *accessControlPolicy) map[string][]string {
135135
res := map[string][]string{}
136136

137137
for _, g := range grants {
138-
switch {
139-
case g.Permission == "READ":
138+
switch g.Permission {
139+
case "READ":
140140
res["X-Amz-Grant-Read"] = append(res["X-Amz-Grant-Read"], "id="+g.Grantee.ID)
141-
case g.Permission == "WRITE":
141+
case "WRITE":
142142
res["X-Amz-Grant-Write"] = append(res["X-Amz-Grant-Write"], "id="+g.Grantee.ID)
143-
case g.Permission == "READ_ACP":
143+
case "READ_ACP":
144144
res["X-Amz-Grant-Read-Acp"] = append(res["X-Amz-Grant-Read-Acp"], "id="+g.Grantee.ID)
145-
case g.Permission == "WRITE_ACP":
145+
case "WRITE_ACP":
146146
res["X-Amz-Grant-Write-Acp"] = append(res["X-Amz-Grant-Write-Acp"], "id="+g.Grantee.ID)
147-
case g.Permission == "FULL_CONTROL":
147+
case "FULL_CONTROL":
148148
res["X-Amz-Grant-Full-Control"] = append(res["X-Amz-Grant-Full-Control"], "id="+g.Grantee.ID)
149149
}
150150
}

Diff for: api-list.go

-1
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,6 @@ func (c *Client) listObjectVersions(ctx context.Context, bucketName string, opts
524524
}
525525
return
526526
}
527-
528527
}
529528
}(resultCh)
530529
return resultCh

Diff for: api-put-object-streaming.go

-1
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,6 @@ func (c *Client) putObjectMultipartStreamOptionalChecksum(ctx context.Context, b
350350
// Part number always starts with '1'.
351351
var partNumber int
352352
for partNumber = 1; partNumber <= totalPartsCount; partNumber++ {
353-
354353
// Proceed to upload the part.
355354
if partNumber == totalPartsCount {
356355
partSize = lastPartSize

Diff for: api-remove.go

+1-4
Original file line numberDiff line numberDiff line change
@@ -392,10 +392,7 @@ func (c *Client) removeObjects(ctx context.Context, bucketName string, objectsCh
392392
defer close(resultCh)
393393

394394
// Loop over entries by 1000 and call MultiDelete requests
395-
for {
396-
if finish {
397-
break
398-
}
395+
for !finish {
399396
count := 0
400397
var batch []ObjectInfo
401398

Diff for: api-s3-datatypes.go

-1
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,6 @@ func (l *ListVersionsResult) UnmarshalXML(d *xml.Decoder, _ xml.StartElement) (e
194194
default:
195195
return errors.New("unrecognized option:" + tagName)
196196
}
197-
198197
}
199198
}
200199
return nil

Diff for: api-select.go

-2
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,6 @@ func (s *SelectResults) start(pipeWriter *io.PipeWriter) {
609609
closeResponse(s.resp)
610610
return
611611
}
612-
613612
}
614613
}()
615614
}
@@ -669,7 +668,6 @@ func extractHeader(body io.Reader, myHeaders http.Header) error {
669668
}
670669

671670
myHeaders.Set(headerTypeName, headerValueName)
672-
673671
}
674672
return nil
675673
}

Diff for: api.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ func (c *Client) do(req *http.Request) (resp *http.Response, err error) {
598598

599599
// If trace is enabled, dump http request and response,
600600
// except when the traceErrorsOnly enabled and the response's status code is ok
601-
if c.isTraceEnabled && !(c.traceErrorsOnly && resp.StatusCode == http.StatusOK) {
601+
if c.isTraceEnabled && (!c.traceErrorsOnly || resp.StatusCode != http.StatusOK) {
602602
err = c.dumpHTTP(req, resp)
603603
if err != nil {
604604
return nil, err

Diff for: core_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func TestGetObjectCore(t *testing.T) {
8686
t.Fatal("Error:", err, bucketName, objectName)
8787
}
8888

89-
st, err := c.Client.StatObject(context.Background(), bucketName, objectName, StatObjectOptions{})
89+
st, err := c.StatObject(context.Background(), bucketName, objectName, StatObjectOptions{})
9090
if err != nil {
9191
t.Fatal("Stat error:", err, bucketName, objectName)
9292
}

Diff for: examples/s3/removebucketreplication.go

-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ func main() {
4949

5050
// Remove replication configuration on a bucket
5151
err = s3Client.RemoveBucketReplication(context.Background(), "my-bucketname")
52-
5352
if err != nil {
5453
log.Fatalln(err)
5554
}

Diff for: pkg/credentials/credentials_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ func TestCredentialsGet(t *testing.T) {
5656
if err != nil {
5757
t.Fatal(err)
5858
}
59-
if "UXHW" != creds.AccessKeyID {
59+
if creds.AccessKeyID != "UXHW" {
6060
t.Errorf("Expected \"UXHW\", got %s", creds.AccessKeyID)
6161
}
62-
if "MYSECRET" != creds.SecretAccessKey {
62+
if creds.SecretAccessKey != "MYSECRET" {
6363
t.Errorf("Expected \"MYSECRET\", got %s", creds.SecretAccessKey)
6464
}
6565
if creds.SessionToken != "" {

Diff for: pkg/credentials/env_test.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ import (
2525

2626
func TestEnvAWSRetrieve(t *testing.T) {
2727
os.Clearenv()
28-
os.Setenv("AWS_ACCESS_KEY_ID", "access")
29-
os.Setenv("AWS_SECRET_ACCESS_KEY", "secret")
30-
os.Setenv("AWS_SESSION_TOKEN", "token")
28+
t.Setenv("AWS_ACCESS_KEY_ID", "access")
29+
t.Setenv("AWS_SECRET_ACCESS_KEY", "secret")
30+
t.Setenv("AWS_SESSION_TOKEN", "token")
3131

3232
e := EnvAWS{}
3333
if !e.IsExpired() {
@@ -54,8 +54,8 @@ func TestEnvAWSRetrieve(t *testing.T) {
5454
}
5555

5656
os.Clearenv()
57-
os.Setenv("AWS_ACCESS_KEY", "access")
58-
os.Setenv("AWS_SECRET_KEY", "secret")
57+
t.Setenv("AWS_ACCESS_KEY", "access")
58+
t.Setenv("AWS_SECRET_KEY", "secret")
5959

6060
expectedCreds = Value{
6161
AccessKeyID: "access",
@@ -76,8 +76,8 @@ func TestEnvAWSRetrieve(t *testing.T) {
7676
func TestEnvMinioRetrieve(t *testing.T) {
7777
os.Clearenv()
7878

79-
os.Setenv("MINIO_ACCESS_KEY", "access")
80-
os.Setenv("MINIO_SECRET_KEY", "secret")
79+
t.Setenv("MINIO_ACCESS_KEY", "access")
80+
t.Setenv("MINIO_SECRET_KEY", "secret")
8181

8282
e := EnvMinio{}
8383
if !e.IsExpired() {

Diff for: pkg/credentials/file_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func TestFileAWS(t *testing.T) {
4646
t.Errorf("Expected 'token', got %s'", credValues.SessionToken)
4747
}
4848

49-
os.Setenv("AWS_SHARED_CREDENTIALS_FILE", "credentials.sample")
49+
t.Setenv("AWS_SHARED_CREDENTIALS_FILE", "credentials.sample")
5050
creds = NewFileAWSCredentials("", "")
5151
credValues, err = creds.GetWithContext(defaultCredContext)
5252
if err != nil {
@@ -68,7 +68,7 @@ func TestFileAWS(t *testing.T) {
6868
t.Fatal(err)
6969
}
7070

71-
os.Setenv("AWS_SHARED_CREDENTIALS_FILE", filepath.Join(wd, "credentials.sample"))
71+
t.Setenv("AWS_SHARED_CREDENTIALS_FILE", filepath.Join(wd, "credentials.sample"))
7272
creds = NewFileAWSCredentials("", "")
7373
credValues, err = creds.GetWithContext(defaultCredContext)
7474
if err != nil {
@@ -86,7 +86,7 @@ func TestFileAWS(t *testing.T) {
8686
}
8787

8888
os.Clearenv()
89-
os.Setenv("AWS_PROFILE", "no_token")
89+
t.Setenv("AWS_PROFILE", "no_token")
9090

9191
creds = NewFileAWSCredentials("credentials.sample", "")
9292
credValues, err = creds.GetWithContext(defaultCredContext)
@@ -167,7 +167,7 @@ func TestFileMinioClient(t *testing.T) {
167167
}
168168

169169
os.Clearenv()
170-
os.Setenv("MINIO_ALIAS", "play")
170+
t.Setenv("MINIO_ALIAS", "play")
171171

172172
creds = NewFileMinioClient("config.json.sample", "")
173173
credValues, err = creds.GetWithContext(defaultCredContext)

0 commit comments

Comments
 (0)