Skip to content

Commit 6d68a19

Browse files
committed
Run linter on some v6 directories, fix errors
Slowly trying to re-enable linting on v6 files. This is a first pass (enabling it on 4 directories, removed from the skip-dirs list in .golangci.json). [#172389465] Authored-by: Reid Mitchell <[email protected]>
1 parent e1ef7b4 commit 6d68a19

24 files changed

+117
-140
lines changed

.golangci.json

+1-9
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,8 @@
1818
"^api/cloudcontroller/ccv2",
1919
"^api/plugin",
2020
"^api/router",
21-
"^command/plugin",
22-
"^command/v6",
2321
"^integration/assets",
2422
"^integration/v6",
25-
"^util/generic",
26-
"^util/manifest",
2723
".*fake.*"
2824
],
2925
"skip-files": [
@@ -44,11 +40,7 @@
4440
"deadcode"
4541
]
4642
},
47-
"linters-settings": {
48-
"errcheck": {
49-
"check-blank": true
50-
}
51-
},
43+
"linters-settings": {},
5244
"issues": {
5345
"max-same-issue": 0,
5446
"exclude": [

command/plugin/plugins_command_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ var _ = Describe("plugins Command", func() {
139139

140140
var err error
141141
file, err = ioutil.TempFile("", "")
142-
defer file.Close()
143142
Expect(err).NotTo(HaveOccurred())
143+
defer file.Close()
144144

145145
err = ioutil.WriteFile(file.Name(), []byte("some-text"), 0600)
146146
Expect(err).NotTo(HaveOccurred())

command/v6/delete_buildpack_command.go

-4
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,3 @@ func (cmd *DeleteBuildpackCommand) Setup(config command.Config, ui command.UI) e
4141
func (cmd DeleteBuildpackCommand) Execute(args []string) error {
4242
return translatableerror.UnrefactoredCommandError{}
4343
}
44-
45-
func (cmd DeleteBuildpackCommand) stackSpecified() bool {
46-
return len(cmd.Stack) > 0
47-
}

command/v6/delete_isolation_segment_command_test.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ var _ = Describe("delete-isolation-segment Command", func() {
132132
When("the -f flag is not provided", func() {
133133
When("the user chooses the default", func() {
134134
BeforeEach(func() {
135-
input.Write([]byte("\n"))
135+
_, err := input.Write([]byte("\n"))
136+
Expect(err).NotTo(HaveOccurred())
136137
})
137138

138139
It("cancels the deletion", func() {
@@ -144,7 +145,8 @@ var _ = Describe("delete-isolation-segment Command", func() {
144145

145146
When("the user inputs yes", func() {
146147
BeforeEach(func() {
147-
input.Write([]byte("yes\n"))
148+
_, err := input.Write([]byte("yes\n"))
149+
Expect(err).NotTo(HaveOccurred())
148150
})
149151

150152
It("deletes the isolation segment", func() {
@@ -156,7 +158,8 @@ var _ = Describe("delete-isolation-segment Command", func() {
156158

157159
When("the user inputs no", func() {
158160
BeforeEach(func() {
159-
input.Write([]byte("no\n"))
161+
_, err := input.Write([]byte("no\n"))
162+
Expect(err).NotTo(HaveOccurred())
160163
})
161164

162165
It("cancels the deletion", func() {

command/v6/delete_org_command_test.go

+8-4
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,8 @@ var _ = Describe("delete-org Command", func() {
173173
When("the '-f' flag is not provided", func() {
174174
When("the user chooses the default", func() {
175175
BeforeEach(func() {
176-
input.Write([]byte("\n"))
176+
_, err := input.Write([]byte("\n"))
177+
Expect(err).NotTo(HaveOccurred())
177178
})
178179

179180
It("does not delete the org", func() {
@@ -187,7 +188,8 @@ var _ = Describe("delete-org Command", func() {
187188

188189
When("the user inputs no", func() {
189190
BeforeEach(func() {
190-
input.Write([]byte("n\n"))
191+
_, err := input.Write([]byte("n\n"))
192+
Expect(err).NotTo(HaveOccurred())
191193
})
192194

193195
It("does not delete the org", func() {
@@ -201,7 +203,8 @@ var _ = Describe("delete-org Command", func() {
201203

202204
When("the user inputs yes", func() {
203205
BeforeEach(func() {
204-
input.Write([]byte("y\n"))
206+
_, err := input.Write([]byte("y\n"))
207+
Expect(err).NotTo(HaveOccurred())
205208
})
206209

207210
It("deletes the org", func() {
@@ -220,7 +223,8 @@ var _ = Describe("delete-org Command", func() {
220223

221224
When("the user input is invalid", func() {
222225
BeforeEach(func() {
223-
input.Write([]byte("e\n\n"))
226+
_, err := input.Write([]byte("e\n\n"))
227+
Expect(err).NotTo(HaveOccurred())
224228
})
225229

226230
It("asks the user again", func() {

command/v6/login_command_test.go

+52-26
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,8 @@ var _ = Describe("login Command", func() {
158158
When("config does not have an API endpoint set and the user enters the endpoint at the prompt", func() {
159159
BeforeEach(func() {
160160
cmd.APIEndpoint = ""
161-
input.Write([]byte("api.example.com\n"))
161+
_, err := input.Write([]byte("api.example.com\n"))
162+
Expect(err).NotTo(HaveOccurred())
162163
fakeConfig.TargetReturnsOnCall(0, "")
163164
fakeConfig.TargetReturnsOnCall(1, "https://api.example.com")
164165
})
@@ -209,7 +210,8 @@ var _ = Describe("login Command", func() {
209210
When("the user inputs an empty API", func() {
210211
BeforeEach(func() {
211212
cmd.APIEndpoint = ""
212-
input.Write([]byte("\n\napi.example.com\n"))
213+
_, err := input.Write([]byte("\n\napi.example.com\n"))
214+
Expect(err).NotTo(HaveOccurred())
213215
fakeConfig.TargetReturnsOnCall(0, "")
214216
fakeConfig.TargetReturnsOnCall(1, "https://api.example.com")
215217
})
@@ -417,7 +419,8 @@ var _ = Describe("login Command", func() {
417419

418420
When("the password is incorrect", func() {
419421
BeforeEach(func() {
420-
input.Write([]byte("other-password\n"))
422+
_, err := input.Write([]byte("other-password\n"))
423+
Expect(err).NotTo(HaveOccurred())
421424
fakeActor.AuthenticateReturns(errors.New("bad creds"))
422425
})
423426

@@ -429,7 +432,8 @@ var _ = Describe("login Command", func() {
429432

430433
When("there have been too many failed login attempts", func() {
431434
BeforeEach(func() {
432-
input.Write([]byte("other-password\n"))
435+
_, err := input.Write([]byte("other-password\n"))
436+
Expect(err).NotTo(HaveOccurred())
433437
fakeActor.AuthenticateReturns(
434438
uaa.AccountLockedError{
435439
Message: "Your account has been locked because of too many failed attempts to login.",
@@ -502,7 +506,8 @@ var _ = Describe("login Command", func() {
502506

503507
When("no authentication flags are set", func() {
504508
BeforeEach(func() {
505-
input.Write([]byte("faker\nsomeaccount\nsomepassword\ngarbage\n"))
509+
_, err := input.Write([]byte("faker\nsomeaccount\nsomepassword\ngarbage\n"))
510+
Expect(err).NotTo(HaveOccurred())
506511
})
507512

508513
It("displays text prompts, starting with username, then password prompts, starting with password", func() {
@@ -633,7 +638,8 @@ var _ = Describe("login Command", func() {
633638
When("authenticating succeeds", func() {
634639
BeforeEach(func() {
635640
fakeConfig.CurrentUserNameReturns("potatoface", nil)
636-
input.Write([]byte("faker\nsomeaccount\nsomepassword\ngarbage\n"))
641+
_, err := input.Write([]byte("faker\nsomeaccount\nsomepassword\ngarbage\n"))
642+
Expect(err).NotTo(HaveOccurred())
637643
})
638644

639645
It("displays OK and a status summary", func() {
@@ -649,7 +655,8 @@ var _ = Describe("login Command", func() {
649655
When("authenticating fails", func() {
650656
BeforeEach(func() {
651657
fakeActor.AuthenticateReturns(errors.New("something died"))
652-
input.Write([]byte("faker\nsomeaccount\nsomepassword\ngarbage\nfaker\nsomeaccount\nsomepassword\ngarbage\nfaker\nsomeaccount\nsomepassword\ngarbage\n"))
658+
_, err := input.Write([]byte("faker\nsomeaccount\nsomepassword\ngarbage\nfaker\nsomeaccount\nsomepassword\ngarbage\nfaker\nsomeaccount\nsomepassword\ngarbage\n"))
659+
Expect(err).NotTo(HaveOccurred())
653660
})
654661

655662
It("prints the error message three times", func() {
@@ -678,7 +685,8 @@ var _ = Describe("login Command", func() {
678685
When("authenticating fails with a bad credentials error", func() {
679686
BeforeEach(func() {
680687
fakeActor.AuthenticateReturns(uaa.UnauthorizedError{Message: "Bad credentials"})
681-
input.Write([]byte("faker\nsomeaccount\nsomepassword\ngarbage\nfaker\nsomeaccount\nsomepassword\ngarbage\nfaker\nsomeaccount\nsomepassword\ngarbage\n"))
688+
_, err := input.Write([]byte("faker\nsomeaccount\nsomepassword\ngarbage\nfaker\nsomeaccount\nsomepassword\ngarbage\nfaker\nsomeaccount\nsomepassword\ngarbage\n"))
689+
Expect(err).NotTo(HaveOccurred())
682690
})
683691

684692
It("converts the error before printing it", func() {
@@ -719,7 +727,8 @@ var _ = Describe("login Command", func() {
719727
BeforeEach(func() {
720728
fakeConfig.TargetReturns(fakeAPI)
721729

722-
input.Write([]byte("some-passcode\n"))
730+
_, err := input.Write([]byte("some-passcode\n"))
731+
Expect(err).NotTo(HaveOccurred())
723732
fakeActor.GetLoginPromptsReturns(map[string]coreconfig.AuthPrompt{
724733
"passcode": {
725734
DisplayName: "some-sso-prompt",
@@ -809,7 +818,8 @@ var _ = Describe("login Command", func() {
809818
Message: "Bad credentials",
810819
})
811820
fakeConfig.CurrentUserNameReturns("", nil)
812-
input.Write([]byte("some-passcode\n"))
821+
_, err := input.Write([]byte("some-passcode\n"))
822+
Expect(err).NotTo(HaveOccurred())
813823
})
814824

815825
It("re-prompts two more times", func() {
@@ -1043,7 +1053,8 @@ var _ = Describe("login Command", func() {
10431053
fakeConfig.TargetedOrganizationReturns(configv3.Organization{
10441054
GUID: "targeted-org-guid1"})
10451055
fakeConfig.TargetedOrganizationNameReturns("targeted-org-name")
1046-
input.Write([]byte("2\n"))
1056+
_, err := input.Write([]byte("2\n"))
1057+
Expect(err).NotTo(HaveOccurred())
10471058
})
10481059

10491060
It("prompts the user to select an org", func() {
@@ -1070,7 +1081,8 @@ var _ = Describe("login Command", func() {
10701081

10711082
When("the position is invalid", func() {
10721083
BeforeEach(func() {
1073-
input.Write([]byte("4\n"))
1084+
_, err := input.Write([]byte("4\n"))
1085+
Expect(err).NotTo(HaveOccurred())
10741086
})
10751087

10761088
It("reprompts the user", func() {
@@ -1091,7 +1103,8 @@ var _ = Describe("login Command", func() {
10911103
When("the user selects an org by name", func() {
10921104
When("the list contains that org", func() {
10931105
BeforeEach(func() {
1094-
input.Write([]byte("some-org-name2\n"))
1106+
_, err := input.Write([]byte("some-org-name2\n"))
1107+
Expect(err).NotTo(HaveOccurred())
10951108
})
10961109

10971110
It("prompts the user to select an org", func() {
@@ -1113,7 +1126,8 @@ var _ = Describe("login Command", func() {
11131126

11141127
When("the org is not in the list", func() {
11151128
BeforeEach(func() {
1116-
input.Write([]byte("invalid-org\n"))
1129+
_, err := input.Write([]byte("invalid-org\n"))
1130+
Expect(err).NotTo(HaveOccurred())
11171131
})
11181132

11191133
It("returns an error", func() {
@@ -1166,7 +1180,8 @@ var _ = Describe("login Command", func() {
11661180
When("the user selects an org by name", func() {
11671181
When("the list contains that org", func() {
11681182
BeforeEach(func() {
1169-
input.Write([]byte("org37\n"))
1183+
_, err := input.Write([]byte("org37\n"))
1184+
Expect(err).NotTo(HaveOccurred())
11701185
})
11711186

11721187
It("prompts the user to select an org", func() {
@@ -1185,7 +1200,8 @@ var _ = Describe("login Command", func() {
11851200

11861201
When("the org is not in the list", func() {
11871202
BeforeEach(func() {
1188-
input.Write([]byte("invalid-org\n"))
1203+
_, err := input.Write([]byte("invalid-org\n"))
1204+
Expect(err).NotTo(HaveOccurred())
11891205
})
11901206

11911207
It("returns an error", func() {
@@ -1421,7 +1437,8 @@ var _ = Describe("login Command", func() {
14211437
When("the user selects a space by list position", func() {
14221438
When("the position is valid", func() {
14231439
BeforeEach(func() {
1424-
input.Write([]byte("2\n"))
1440+
_, err := input.Write([]byte("2\n"))
1441+
Expect(err).NotTo(HaveOccurred())
14251442
})
14261443

14271444
It("targets that space", func() {
@@ -1436,7 +1453,8 @@ var _ = Describe("login Command", func() {
14361453

14371454
When("the position is invalid", func() {
14381455
BeforeEach(func() {
1439-
input.Write([]byte("-1\n"))
1456+
_, err := input.Write([]byte("-1\n"))
1457+
Expect(err).NotTo(HaveOccurred())
14401458
})
14411459

14421460
It("reprompts the user", func() {
@@ -1463,7 +1481,8 @@ var _ = Describe("login Command", func() {
14631481
When("the user selects a space by name", func() {
14641482
When("the list contains that space", func() {
14651483
BeforeEach(func() {
1466-
input.Write([]byte("some-space-name2\n"))
1484+
_, err := input.Write([]byte("some-space-name2\n"))
1485+
Expect(err).NotTo(HaveOccurred())
14671486
})
14681487

14691488
It("targets that space", func() {
@@ -1478,7 +1497,8 @@ var _ = Describe("login Command", func() {
14781497

14791498
When("the space is not in the list", func() {
14801499
BeforeEach(func() {
1481-
input.Write([]byte("invalid-space\n"))
1500+
_, err := input.Write([]byte("invalid-space\n"))
1501+
Expect(err).NotTo(HaveOccurred())
14821502
})
14831503

14841504
It("returns an error", func() {
@@ -1515,7 +1535,8 @@ var _ = Describe("login Command", func() {
15151535
When("the user enters text which is both a space name and a digit", func() {
15161536
When("the entry is a valid position", func() {
15171537
BeforeEach(func() {
1518-
input.Write([]byte("3\n"))
1538+
_, err := input.Write([]byte("3\n"))
1539+
Expect(err).NotTo(HaveOccurred())
15191540
})
15201541

15211542
It("targets the space at the index specified", func() {
@@ -1530,7 +1551,8 @@ var _ = Describe("login Command", func() {
15301551

15311552
When("the entry is an invalid position", func() {
15321553
BeforeEach(func() {
1533-
input.Write([]byte("100\n"))
1554+
_, err := input.Write([]byte("100\n"))
1555+
Expect(err).NotTo(HaveOccurred())
15341556
})
15351557

15361558
It("reprompts the user", func() {
@@ -1578,7 +1600,8 @@ var _ = Describe("login Command", func() {
15781600
When("the user selects an space by name", func() {
15791601
When("the list contains that space", func() {
15801602
BeforeEach(func() {
1581-
input.Write([]byte("space-37\n"))
1603+
_, err := input.Write([]byte("space-37\n"))
1604+
Expect(err).NotTo(HaveOccurred())
15821605
})
15831606

15841607
It("targets that space", func() {
@@ -1592,7 +1615,8 @@ var _ = Describe("login Command", func() {
15921615

15931616
When("the name is a valid list position, but it does not match a space name", func() {
15941617
BeforeEach(func() {
1595-
input.Write([]byte("31\n"))
1618+
_, err := input.Write([]byte("31\n"))
1619+
Expect(err).NotTo(HaveOccurred())
15961620
})
15971621

15981622
It("returns an error", func() {
@@ -1607,7 +1631,8 @@ var _ = Describe("login Command", func() {
16071631

16081632
When("the space is not in the list", func() {
16091633
BeforeEach(func() {
1610-
input.Write([]byte("invalid-space\n"))
1634+
_, err := input.Write([]byte("invalid-space\n"))
1635+
Expect(err).NotTo(HaveOccurred())
16111636
})
16121637

16131638
It("returns an error", func() {
@@ -1671,7 +1696,8 @@ var _ = Describe("login Command", func() {
16711696
nil,
16721697
)
16731698

1674-
input.Write([]byte("2\n"))
1699+
_, err := input.Write([]byte("2\n"))
1700+
Expect(err).NotTo(HaveOccurred())
16751701
})
16761702

16771703
It("outputs targeted org", func() {

command/v6/logs_command.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
package v6
22

33
import (
4-
"code.cloudfoundry.org/cli/actor/actionerror"
54
"context"
65
"os"
76
"os/signal"
87
"time"
98

9+
"code.cloudfoundry.org/cli/actor/actionerror"
10+
1011
"code.cloudfoundry.org/cli/actor/sharedaction"
1112
"code.cloudfoundry.org/cli/actor/v2action"
1213
"code.cloudfoundry.org/cli/actor/v3action"

command/v6/marketplace_command.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ func (cmd *MarketplaceCommand) displayServiceSummaries(serviceSummaries []v2acti
147147
if len(serviceSummaries) == 0 {
148148
cmd.UI.DisplayText("No service offerings found")
149149
} else {
150-
var table = [][]string{}
150+
var table [][]string
151151
if cmd.NoPlans {
152152
tableHeaders := []string{"service", "description", "broker"}
153153
table = [][]string{tableHeaders}

0 commit comments

Comments
 (0)