Skip to content

Commit 19e8a7d

Browse files
committed
lint: Enable additional linters
Fix in the one go. We can remove the separate 'go vet' and 'go fmt' invocations since these are now run by golangci-lint Signed-off-by: Stephen Finucane <[email protected]>
1 parent 31e9a97 commit 19e8a7d

File tree

11 files changed

+40
-34
lines changed

11 files changed

+40
-34
lines changed

.golangci.yaml

+11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
11
---
2+
linters:
3+
disable-all: true
4+
enable:
5+
- errcheck
6+
- gofmt
7+
- goimports
8+
- govet
9+
- staticcheck
10+
- unparam
11+
- unused
12+
213
issues:
314
exclude:
415
- SA1006 # printf-style function with dynamic format string and no further arguments should use print-style function instead (staticcheck)

Makefile

-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ endif
1717
# chcon -Rt svirt_sandbox_file_t .
1818
# chcon -Rt svirt_sandbox_file_t ~/.cache/golangci-lint
1919
lint:
20-
go fmt ./...
21-
go vet -tags "fixtures acceptance" ./...
2220
$(RUNNER) run -t --rm \
2321
-v $(shell pwd):/app \
2422
-v ~/.cache/golangci-lint/$(GOLANGCI_LINT_VERSION):/root/.cache \

internal/acceptance/openstack/identity/v3/oauth1_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,11 @@ func TestOAuth1CRUD(t *testing.T) {
9393

9494
// test HMACSHA1 and PLAINTEXT signature methods
9595
for _, method := range []oauth1.SignatureMethod{oauth1.HMACSHA1, oauth1.PLAINTEXT} {
96-
oauth1MethodTest(t, client, consumer, method, user, project, roles, ao.IdentityEndpoint)
96+
oauth1MethodTest(t, client, consumer, method, user, project, roles)
9797
}
9898
}
9999

100-
func oauth1MethodTest(t *testing.T, client *gophercloud.ServiceClient, consumer *oauth1.Consumer, method oauth1.SignatureMethod, user *tokens.User, project *tokens.Project, roles []tokens.Role, identityEndpoint string) {
100+
func oauth1MethodTest(t *testing.T, client *gophercloud.ServiceClient, consumer *oauth1.Consumer, method oauth1.SignatureMethod, user *tokens.User, project *tokens.Project, roles []tokens.Role) {
101101
// Request a token
102102
requestTokenOpts := oauth1.RequestTokenOpts{
103103
OAuthConsumerKey: consumer.ID,

internal/acceptance/openstack/networking/v2/extensions/layer3/l3_scheduling_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func TestLayer3RouterScheduling(t *testing.T) {
5454

5555
containsRouterFunc := func(rs []routers.Router, routerID string) bool {
5656
for _, r := range rs {
57-
if r.ID == router.ID {
57+
if r.ID == routerID {
5858
return true
5959
}
6060
}

internal/acceptance/openstack/sharedfilesystems/v2/replicas.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func CreateReplica(t *testing.T, client *gophercloud.ServiceClient, share *share
2828
return nil, err
2929
}
3030

31-
_, err = waitForReplicaStatus(t, client, replica.ID, "available")
31+
err = waitForReplicaStatus(t, client, replica.ID, "available")
3232
if err != nil {
3333
t.Logf("Failed to get %s replica status", replica.ID)
3434
DeleteReplica(t, client, replica)
@@ -49,7 +49,7 @@ func DeleteReplica(t *testing.T, client *gophercloud.ServiceClient, replica *rep
4949
t.Errorf("Unable to delete replica %s: %v", replica.ID, err)
5050
}
5151

52-
_, err = waitForReplicaStatus(t, client, replica.ID, "deleted")
52+
err = waitForReplicaStatus(t, client, replica.ID, "deleted")
5353
if err != nil {
5454
t.Errorf("Failed to wait for 'deleted' status for %s replica: %v", replica.ID, err)
5555
} else {
@@ -71,7 +71,7 @@ func ListShareReplicas(t *testing.T, client *gophercloud.ServiceClient, shareID
7171
return replicas.ExtractReplicas(pages)
7272
}
7373

74-
func waitForReplicaStatus(t *testing.T, c *gophercloud.ServiceClient, id, status string) (*replicas.Replica, error) {
74+
func waitForReplicaStatus(t *testing.T, c *gophercloud.ServiceClient, id, status string) error {
7575
var current *replicas.Replica
7676

7777
err := tools.WaitFor(func(ctx context.Context) (bool, error) {
@@ -104,14 +104,14 @@ func waitForReplicaStatus(t *testing.T, c *gophercloud.ServiceClient, id, status
104104
if err != nil {
105105
mErr := PrintMessages(t, c, id)
106106
if mErr != nil {
107-
return current, fmt.Errorf("Replica status is '%s' and unable to get manila messages: %s", err, mErr)
107+
return fmt.Errorf("Replica status is '%s' and unable to get manila messages: %s", err, mErr)
108108
}
109109
}
110110

111-
return current, err
111+
return err
112112
}
113113

114-
func waitForReplicaState(t *testing.T, c *gophercloud.ServiceClient, id, state string) (*replicas.Replica, error) {
114+
func waitForReplicaState(t *testing.T, c *gophercloud.ServiceClient, id, state string) error {
115115
var current *replicas.Replica
116116

117117
err := tools.WaitFor(func(ctx context.Context) (bool, error) {
@@ -136,9 +136,9 @@ func waitForReplicaState(t *testing.T, c *gophercloud.ServiceClient, id, state s
136136
if err != nil {
137137
mErr := PrintMessages(t, c, id)
138138
if mErr != nil {
139-
return current, fmt.Errorf("Replica state is '%s' and unable to get manila messages: %s", err, mErr)
139+
return fmt.Errorf("Replica state is '%s' and unable to get manila messages: %s", err, mErr)
140140
}
141141
}
142142

143-
return current, err
143+
return err
144144
}

internal/acceptance/openstack/sharedfilesystems/v2/replicas_test.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func TestReplicaPromote(t *testing.T) {
8686
// sync new replica
8787
err = replicas.Resync(context.TODO(), client, created.ID).ExtractErr()
8888
th.AssertNoErr(t, err)
89-
_, err = waitForReplicaState(t, client, created.ID, "in_sync")
89+
err = waitForReplicaState(t, client, created.ID, "in_sync")
9090
if err != nil {
9191
t.Fatalf("Replica status error: %v", err)
9292
}
@@ -95,7 +95,7 @@ func TestReplicaPromote(t *testing.T) {
9595
err = replicas.Promote(context.TODO(), client, created.ID, &replicas.PromoteOpts{}).ExtractErr()
9696
th.AssertNoErr(t, err)
9797

98-
_, err = waitForReplicaState(t, client, created.ID, "active")
98+
err = waitForReplicaState(t, client, created.ID, "active")
9999
if err != nil {
100100
t.Fatalf("Replica status error: %v", err)
101101
}
@@ -117,14 +117,14 @@ func TestReplicaPromote(t *testing.T) {
117117
// sync old replica
118118
err = replicas.Resync(context.TODO(), client, oldReplicaID).ExtractErr()
119119
th.AssertNoErr(t, err)
120-
_, err = waitForReplicaState(t, client, oldReplicaID, "in_sync")
120+
err = waitForReplicaState(t, client, oldReplicaID, "in_sync")
121121
if err != nil {
122122
t.Fatalf("Replica status error: %v", err)
123123
}
124124
err = replicas.Promote(context.TODO(), client, oldReplicaID, &replicas.PromoteOpts{}).ExtractErr()
125125
th.AssertNoErr(t, err)
126126

127-
_, err = waitForReplicaState(t, client, oldReplicaID, "active")
127+
err = waitForReplicaState(t, client, oldReplicaID, "active")
128128
if err != nil {
129129
t.Fatalf("Replica status error: %v", err)
130130
}
@@ -262,7 +262,7 @@ func TestReplicaResetStatus(t *testing.T) {
262262
}
263263

264264
// We need to wait till the Extend operation is done
265-
_, err = waitForReplicaStatus(t, client, replica.ID, "error")
265+
err = waitForReplicaStatus(t, client, replica.ID, "error")
266266
if err != nil {
267267
t.Fatalf("Replica status error: %v", err)
268268
}
@@ -300,7 +300,7 @@ func TestReplicaForceDelete(t *testing.T) {
300300
t.Fatalf("Unable to force delete a replica: %v", err)
301301
}
302302

303-
_, err = waitForReplicaStatus(t, client, replica.ID, "deleted")
303+
err = waitForReplicaStatus(t, client, replica.ID, "deleted")
304304
if err != nil {
305305
t.Fatalf("Replica status error: %v", err)
306306
}

openstack/networking/v2/extensions/bgp/speakers/testing/requests_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,9 @@ func TestGetAdvertisedRoutes(t *testing.T) {
224224
}
225225

226226
expected := []speakers.AdvertisedRoute{
227-
speakers.AdvertisedRoute{NextHop: "172.17.128.212", Destination: "172.17.129.192/27"},
228-
speakers.AdvertisedRoute{NextHop: "172.17.128.218", Destination: "172.17.129.0/27"},
229-
speakers.AdvertisedRoute{NextHop: "172.17.128.231", Destination: "172.17.129.160/27"},
227+
{NextHop: "172.17.128.212", Destination: "172.17.129.192/27"},
228+
{NextHop: "172.17.128.218", Destination: "172.17.129.0/27"},
229+
{NextHop: "172.17.128.231", Destination: "172.17.129.160/27"},
230230
}
231231
th.CheckDeepEquals(t, count, 1)
232232
th.CheckDeepEquals(t, expected, actual)

openstack/objectstorage/v1/objects/requests.go

+1-4
Original file line numberDiff line numberDiff line change
@@ -596,10 +596,7 @@ func CreateTempURL(ctx context.Context, c *gophercloud.ServiceClient, containerN
596596
if err != nil {
597597
return "", err
598598
}
599-
urlToBeSigned, err := tempURL(c, containerName, objectName)
600-
if err != nil {
601-
return "", err
602-
}
599+
urlToBeSigned := tempURL(c, containerName, objectName)
603600

604601
if opts.Split == "" {
605602
opts.Split = "/v1/"

openstack/objectstorage/v1/objects/urls.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import (
1111
// Names must not be URL-encoded in this case.
1212
//
1313
// See: https://docs.openstack.org/swift/latest/api/temporary_url_middleware.html#hmac-signature-for-temporary-urls
14-
func tempURL(c *gophercloud.ServiceClient, container, object string) (string, error) {
15-
return c.ServiceURL(container, object), nil
14+
func tempURL(c *gophercloud.ServiceClient, container, object string) string {
15+
return c.ServiceURL(container, object)
1616
}
1717

1818
func listURL(c *gophercloud.ServiceClient, container string) (string, error) {

pagination/testing/linked_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func ExtractLinkedInts(r pagination.Page) ([]int, error) {
3030
return s.Ints, err
3131
}
3232

33-
func createLinked(t *testing.T) pagination.Pager {
33+
func createLinked() pagination.Pager {
3434
testhelper.SetupHTTP()
3535

3636
testhelper.Mux.HandleFunc("/page1", func(w http.ResponseWriter, r *http.Request) {
@@ -58,7 +58,7 @@ func createLinked(t *testing.T) pagination.Pager {
5858
}
5959

6060
func TestEnumerateLinked(t *testing.T) {
61-
pager := createLinked(t)
61+
pager := createLinked()
6262
defer testhelper.TeardownHTTP()
6363

6464
callCount := 0
@@ -100,7 +100,7 @@ func TestEnumerateLinked(t *testing.T) {
100100
}
101101

102102
func TestAllPagesLinked(t *testing.T) {
103-
pager := createLinked(t)
103+
pager := createLinked()
104104
defer testhelper.TeardownHTTP()
105105

106106
page, err := pager.AllPages(context.TODO())

testhelper/convenience.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -268,15 +268,15 @@ func CheckDeepEquals(t *testing.T, expected, actual interface{}) {
268268
})
269269
}
270270

271-
func isByteArrayEquals(t *testing.T, expectedBytes []byte, actualBytes []byte) bool {
271+
func isByteArrayEquals(expectedBytes []byte, actualBytes []byte) bool {
272272
return bytes.Equal(expectedBytes, actualBytes)
273273
}
274274

275275
// AssertByteArrayEquals a convenience function for checking whether two byte arrays are equal
276276
func AssertByteArrayEquals(t *testing.T, expectedBytes []byte, actualBytes []byte) {
277277
t.Helper()
278278

279-
if !isByteArrayEquals(t, expectedBytes, actualBytes) {
279+
if !isByteArrayEquals(expectedBytes, actualBytes) {
280280
logFatal(t, "The bytes differed.")
281281
}
282282
}
@@ -285,7 +285,7 @@ func AssertByteArrayEquals(t *testing.T, expectedBytes []byte, actualBytes []byt
285285
func CheckByteArrayEquals(t *testing.T, expectedBytes []byte, actualBytes []byte) {
286286
t.Helper()
287287

288-
if !isByteArrayEquals(t, expectedBytes, actualBytes) {
288+
if !isByteArrayEquals(expectedBytes, actualBytes) {
289289
logError(t, "The bytes differed.")
290290
}
291291
}

0 commit comments

Comments
 (0)