Skip to content

Commit 17ad6c2

Browse files
committed
Fix linter issues
Signed-off-by: Andy Lo-A-Foe <andy.loafoe@gmail.com>
1 parent 60c7e4a commit 17ad6c2

File tree

5 files changed

+27
-27
lines changed

5 files changed

+27
-27
lines changed

internal/client/client_test.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ func TestNewClient(t *testing.T) {
3939

4040
// Restore after test
4141
defer func() {
42-
os.Setenv("GITHUB_TOKEN", origToken)
43-
os.Setenv("GITHUB_ENTERPRISE_URL", origServerURL)
44-
os.Setenv("GITHUB_ENTERPRISE_UPLOADS_URL", origUploadURL)
42+
_ = os.Setenv("GITHUB_TOKEN", origToken)
43+
_ = os.Setenv("GITHUB_ENTERPRISE_URL", origServerURL)
44+
_ = os.Setenv("GITHUB_ENTERPRISE_UPLOADS_URL", origUploadURL)
4545
}()
4646

4747
tests := []struct {
@@ -53,39 +53,39 @@ func TestNewClient(t *testing.T) {
5353
{
5454
name: "Without authentication",
5555
setupEnv: func() {
56-
os.Unsetenv("GITHUB_TOKEN")
57-
os.Unsetenv("GITHUB_ENTERPRISE_URL")
58-
os.Unsetenv("GITHUB_ENTERPRISE_UPLOADS_URL")
56+
_ = os.Unsetenv("GITHUB_TOKEN")
57+
_ = os.Unsetenv("GITHUB_ENTERPRISE_URL")
58+
_ = os.Unsetenv("GITHUB_ENTERPRISE_UPLOADS_URL")
5959
},
6060
wantAuthenticated: false,
6161
wantErr: false,
6262
},
6363
{
6464
name: "With authentication token",
6565
setupEnv: func() {
66-
os.Setenv("GITHUB_TOKEN", "test-token")
67-
os.Unsetenv("GITHUB_ENTERPRISE_URL")
68-
os.Unsetenv("GITHUB_ENTERPRISE_UPLOADS_URL")
66+
_ = os.Setenv("GITHUB_TOKEN", "test-token")
67+
_ = os.Unsetenv("GITHUB_ENTERPRISE_URL")
68+
_ = os.Unsetenv("GITHUB_ENTERPRISE_UPLOADS_URL")
6969
},
7070
wantAuthenticated: true,
7171
wantErr: false,
7272
},
7373
{
7474
name: "With enterprise URL",
7575
setupEnv: func() {
76-
os.Unsetenv("GITHUB_TOKEN")
77-
os.Setenv("GITHUB_ENTERPRISE_URL", "https://github.example.com/api/v3/")
78-
os.Unsetenv("GITHUB_ENTERPRISE_UPLOADS_URL")
76+
_ = os.Unsetenv("GITHUB_TOKEN")
77+
_ = os.Setenv("GITHUB_ENTERPRISE_URL", "https://github.example.com/api/v3/")
78+
_ = os.Unsetenv("GITHUB_ENTERPRISE_UPLOADS_URL")
7979
},
8080
wantAuthenticated: false,
8181
wantErr: false,
8282
},
8383
{
8484
name: "With enterprise URL and token",
8585
setupEnv: func() {
86-
os.Setenv("GITHUB_TOKEN", "test-token")
87-
os.Setenv("GITHUB_ENTERPRISE_URL", "https://github.example.com/api/v3/")
88-
os.Unsetenv("GITHUB_ENTERPRISE_UPLOADS_URL")
86+
_ = os.Setenv("GITHUB_TOKEN", "test-token")
87+
_ = os.Setenv("GITHUB_ENTERPRISE_URL", "https://github.example.com/api/v3/")
88+
_ = os.Unsetenv("GITHUB_ENTERPRISE_UPLOADS_URL")
8989
},
9090
wantAuthenticated: true,
9191
wantErr: false,

internal/crypto/crypto.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func GetPublicKey(url string) (string, string, error) {
3838
if err != nil {
3939
return "", "", err
4040
}
41-
defer resp.Body.Close()
41+
defer func() { _ = resp.Body.Close() }()
4242

4343
if resp.StatusCode != 200 {
4444
return "", "", fmt.Errorf("not found")

internal/crypto/crypto_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func TestGetPublicKey(t *testing.T) {
5656
name: "Valid PGP key",
5757
handler: func(w http.ResponseWriter, r *http.Request) {
5858
w.WriteHeader(http.StatusOK)
59-
w.Write([]byte(testPublicKey))
59+
_, _ = w.Write([]byte(testPublicKey))
6060
},
6161
wantErr: false,
6262
checkKeyID: true,
@@ -72,15 +72,15 @@ func TestGetPublicKey(t *testing.T) {
7272
name: "Invalid PGP data",
7373
handler: func(w http.ResponseWriter, r *http.Request) {
7474
w.WriteHeader(http.StatusOK)
75-
w.Write([]byte("not a valid pgp key"))
75+
_, _ = w.Write([]byte("not a valid pgp key"))
7676
},
7777
wantErr: true,
7878
},
7979
{
8080
name: "Empty response",
8181
handler: func(w http.ResponseWriter, r *http.Request) {
8282
w.WriteHeader(http.StatusOK)
83-
w.Write([]byte(""))
83+
_, _ = w.Write([]byte(""))
8484
},
8585
wantErr: true,
8686
},
@@ -123,7 +123,7 @@ func TestGetPublicKeyNonPGPContent(t *testing.T) {
123123
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
124124
w.WriteHeader(http.StatusOK)
125125
// Return valid armored data but not a public key
126-
w.Write([]byte(`-----BEGIN PGP MESSAGE-----
126+
_, _ = w.Write([]byte(`-----BEGIN PGP MESSAGE-----
127127
Some message content here
128128
-----END PGP MESSAGE-----`))
129129
}))

internal/download/download.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func GetShasum(asset string, shasumURL string) (string, error) {
3434
if err != nil {
3535
return "", err
3636
}
37-
defer resp.Body.Close()
37+
defer func() { _ = resp.Body.Close() }()
3838

3939
if resp.StatusCode != 200 {
4040
return "", fmt.Errorf("not found")

internal/download/download_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func TestGetShasum(t *testing.T) {
4040
asset: "terraform-provider-aws_1.0.0_linux_amd64.zip",
4141
handler: func(w http.ResponseWriter, r *http.Request) {
4242
w.WriteHeader(http.StatusOK)
43-
w.Write([]byte(`abc123def456 terraform-provider-aws_1.0.0_linux_amd64.zip
43+
_, _ = w.Write([]byte(`abc123def456 terraform-provider-aws_1.0.0_linux_amd64.zip
4444
789012ghi345 terraform-provider-aws_1.0.0_darwin_amd64.zip
4545
`))
4646
},
@@ -52,7 +52,7 @@ func TestGetShasum(t *testing.T) {
5252
asset: "terraform-provider-aws_1.0.0_windows_amd64.zip",
5353
handler: func(w http.ResponseWriter, r *http.Request) {
5454
w.WriteHeader(http.StatusOK)
55-
w.Write([]byte(`abc123def456 terraform-provider-aws_1.0.0_linux_amd64.zip
55+
_, _ = w.Write([]byte(`abc123def456 terraform-provider-aws_1.0.0_linux_amd64.zip
5656
789012ghi345 terraform-provider-aws_1.0.0_darwin_amd64.zip
5757
`))
5858
},
@@ -71,7 +71,7 @@ func TestGetShasum(t *testing.T) {
7171
asset: "terraform-provider-aws_1.0.0_linux_amd64.zip",
7272
handler: func(w http.ResponseWriter, r *http.Request) {
7373
w.WriteHeader(http.StatusOK)
74-
w.Write([]byte(``))
74+
_, _ = w.Write([]byte(``))
7575
},
7676
wantErr: true,
7777
},
@@ -80,7 +80,7 @@ func TestGetShasum(t *testing.T) {
8080
asset: "terraform-provider-aws_1.0.0_linux_amd64.zip",
8181
handler: func(w http.ResponseWriter, r *http.Request) {
8282
w.WriteHeader(http.StatusOK)
83-
w.Write([]byte(`abc123def456 terraform-provider-aws_1.0.0_linux_amd64.zip
83+
_, _ = w.Write([]byte(`abc123def456 terraform-provider-aws_1.0.0_linux_amd64.zip
8484
`))
8585
},
8686
wantShasum: "abc123def456",
@@ -91,7 +91,7 @@ func TestGetShasum(t *testing.T) {
9191
asset: "terraform-provider-aws_1.0.0_linux_amd64.zip",
9292
handler: func(w http.ResponseWriter, r *http.Request) {
9393
w.WriteHeader(http.StatusOK)
94-
w.Write([]byte(`abc123def456 terraform-provider-aws_1.0.0_linux_amd64.zip
94+
_, _ = w.Write([]byte(`abc123def456 terraform-provider-aws_1.0.0_linux_amd64.zip
9595
`))
9696
},
9797
wantErr: true,
@@ -101,7 +101,7 @@ func TestGetShasum(t *testing.T) {
101101
asset: "terraform-provider-aws_4.67.0_linux_amd64.zip",
102102
handler: func(w http.ResponseWriter, r *http.Request) {
103103
w.WriteHeader(http.StatusOK)
104-
w.Write([]byte(`1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef terraform-provider-aws_4.67.0_darwin_amd64.zip
104+
_, _ = w.Write([]byte(`1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef terraform-provider-aws_4.67.0_darwin_amd64.zip
105105
fedcba0987654321fedcba0987654321fedcba0987654321fedcba0987654321 terraform-provider-aws_4.67.0_darwin_arm64.zip
106106
abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890 terraform-provider-aws_4.67.0_linux_amd64.zip
107107
567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef123456 terraform-provider-aws_4.67.0_windows_amd64.zip

0 commit comments

Comments
 (0)