X Tutup
Skip to content

Commit 734497a

Browse files
authored
Code fixes informed by golangci-lint failures (cli#738)
1 parent 876e825 commit 734497a

File tree

21 files changed

+52
-49
lines changed

21 files changed

+52
-49
lines changed

api/queries_issue_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func TestIssueList(t *testing.T) {
5252
}
5353

5454
bodyBytes, _ := ioutil.ReadAll(http.Requests[0].Body)
55-
json.Unmarshal(bodyBytes, &reqBody)
55+
_ = json.Unmarshal(bodyBytes, &reqBody)
5656
if reqLimit := reqBody.Variables["limit"].(float64); reqLimit != 100 {
5757
t.Errorf("expected 100, got %v", reqLimit)
5858
}
@@ -61,7 +61,7 @@ func TestIssueList(t *testing.T) {
6161
}
6262

6363
bodyBytes, _ = ioutil.ReadAll(http.Requests[1].Body)
64-
json.Unmarshal(bodyBytes, &reqBody)
64+
_ = json.Unmarshal(bodyBytes, &reqBody)
6565
if endCursor := reqBody.Variables["endCursor"].(string); endCursor != "ENDCURSOR" {
6666
t.Errorf("expected %q, got %q", "ENDCURSOR", endCursor)
6767
}

api/queries_repo_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func Test_RepoCreate(t *testing.T) {
3535
}
3636

3737
bodyBytes, _ := ioutil.ReadAll(http.Requests[0].Body)
38-
json.Unmarshal(bodyBytes, &reqBody)
38+
_ = json.Unmarshal(bodyBytes, &reqBody)
3939
if description := reqBody.Variables.Input["description"].(string); description != "roasted chesnuts" {
4040
t.Errorf("expected description to be %q, got %q", "roasted chesnuts", description)
4141
}

auth/oauth.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func (oa *OAuthFlow) ObtainAccessToken() (accessToken string, err error) {
6565
fmt.Fprintf(os.Stderr, " 2. Copy the contents of ~/.config/gh/config.yml to this system")
6666
}
6767

68-
http.Serve(listener, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
68+
_ = http.Serve(listener, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
6969
oa.logf("server handler: %s\n", r.URL.Path)
7070
if r.URL.Path != "/callback" {
7171
w.WriteHeader(404)

command/issue.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ func issueStatus(cmd *cobra.Command, args []string) error {
170170
if issuePayload.Assigned.TotalCount > 0 {
171171
printIssues(out, " ", issuePayload.Assigned.TotalCount, issuePayload.Assigned.Issues)
172172
} else {
173-
message := fmt.Sprintf(" There are no issues assigned to you")
173+
message := " There are no issues assigned to you"
174174
printMessage(out, message)
175175
}
176176
fmt.Fprintln(out)
@@ -427,7 +427,7 @@ func printIssues(w io.Writer, prefix string, totalCount int, issues []api.Issue)
427427
table.AddField(utils.FuzzyAgo(ago), nil, utils.Gray)
428428
table.EndRow()
429429
}
430-
table.Render()
430+
_ = table.Render()
431431
remaining := totalCount - len(issues)
432432
if remaining > 0 {
433433
fmt.Fprintf(w, utils.Gray("%sAnd %d more\n"), prefix, remaining)

command/issue_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ No issues match your search in OWNER/REPO
162162
Author string
163163
}
164164
}{}
165-
json.Unmarshal(bodyBytes, &reqBody)
165+
_ = json.Unmarshal(bodyBytes, &reqBody)
166166

167167
eq(t, reqBody.Variables.Assignee, "probablyCher")
168168
eq(t, reqBody.Variables.Labels, []string{"web", "bug"})
@@ -191,7 +191,7 @@ func TestIssueList_nullAssigneeLabels(t *testing.T) {
191191
reqBody := struct {
192192
Variables map[string]interface{}
193193
}{}
194-
json.Unmarshal(bodyBytes, &reqBody)
194+
_ = json.Unmarshal(bodyBytes, &reqBody)
195195

196196
_, assigneeDeclared := reqBody.Variables["assignee"]
197197
_, labelsDeclared := reqBody.Variables["labels"]
@@ -471,7 +471,7 @@ func TestIssueCreate(t *testing.T) {
471471
}
472472
}
473473
}{}
474-
json.Unmarshal(bodyBytes, &reqBody)
474+
_ = json.Unmarshal(bodyBytes, &reqBody)
475475

476476
eq(t, reqBody.Variables.Input.RepositoryID, "REPOID")
477477
eq(t, reqBody.Variables.Input.Title, "hello")

command/pr_checkout_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ func TestPRCheckout_urlArg_differentBase(t *testing.T) {
167167
Repo string
168168
}
169169
}{}
170-
json.Unmarshal(bodyBytes, &reqBody)
170+
_ = json.Unmarshal(bodyBytes, &reqBody)
171171

172172
eq(t, reqBody.Variables.Owner, "OTHER")
173173
eq(t, reqBody.Variables.Repo, "POE")
@@ -420,7 +420,7 @@ func TestPRCheckout_differentRepo_existingBranch(t *testing.T) {
420420
restoreCmd := run.SetPrepareCmd(func(cmd *exec.Cmd) run.Runnable {
421421
switch strings.Join(cmd.Args, " ") {
422422
case "git config branch.feature.merge":
423-
return &test.OutputStub{[]byte("refs/heads/feature\n"), nil}
423+
return &test.OutputStub{Out: []byte("refs/heads/feature\n")}
424424
default:
425425
ranCommands = append(ranCommands, cmd.Args)
426426
return &test.OutputStub{}
@@ -471,7 +471,7 @@ func TestPRCheckout_differentRepo_currentBranch(t *testing.T) {
471471
restoreCmd := run.SetPrepareCmd(func(cmd *exec.Cmd) run.Runnable {
472472
switch strings.Join(cmd.Args, " ") {
473473
case "git config branch.feature.merge":
474-
return &test.OutputStub{[]byte("refs/heads/feature\n"), nil}
474+
return &test.OutputStub{Out: []byte("refs/heads/feature\n")}
475475
default:
476476
ranCommands = append(ranCommands, cmd.Args)
477477
return &test.OutputStub{}

command/pr_create_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func TestPRCreate(t *testing.T) {
5454
}
5555
}
5656
}{}
57-
json.Unmarshal(bodyBytes, &reqBody)
57+
_ = json.Unmarshal(bodyBytes, &reqBody)
5858

5959
eq(t, reqBody.Variables.Input.RepositoryID, "REPOID")
6060
eq(t, reqBody.Variables.Input.Title, "my title")
@@ -316,7 +316,7 @@ func TestPRCreate_cross_repo_same_branch(t *testing.T) {
316316
}
317317
}
318318
}{}
319-
json.Unmarshal(bodyBytes, &reqBody)
319+
_ = json.Unmarshal(bodyBytes, &reqBody)
320320

321321
eq(t, reqBody.Variables.Input.RepositoryID, "REPOID0")
322322
eq(t, reqBody.Variables.Input.Title, "cross repo")
@@ -392,7 +392,7 @@ func TestPRCreate_survey_defaults_multicommit(t *testing.T) {
392392
}
393393
}
394394
}{}
395-
json.Unmarshal(bodyBytes, &reqBody)
395+
_ = json.Unmarshal(bodyBytes, &reqBody)
396396

397397
expectedBody := "- commit 0\n- commit 1\n"
398398

@@ -469,7 +469,7 @@ func TestPRCreate_survey_defaults_monocommit(t *testing.T) {
469469
}
470470
}
471471
}{}
472-
json.Unmarshal(bodyBytes, &reqBody)
472+
_ = json.Unmarshal(bodyBytes, &reqBody)
473473

474474
expectedBody := "was the color of a television, turned to a dead channel"
475475

@@ -527,7 +527,7 @@ func TestPRCreate_survey_autofill(t *testing.T) {
527527
}
528528
}
529529
}{}
530-
json.Unmarshal(bodyBytes, &reqBody)
530+
_ = json.Unmarshal(bodyBytes, &reqBody)
531531

532532
expectedBody := "was the color of a television, turned to a dead channel"
533533

command/pr_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ func RunCommand(cmd *cobra.Command, args string) (*cmdOut, error) {
5555
cmd.Flags().VisitAll(func(f *pflag.Flag) {
5656
switch v := f.Value.(type) {
5757
case pflag.SliceValue:
58-
v.Replace([]string{})
58+
_ = v.Replace([]string{})
5959
default:
6060
switch v.Type() {
6161
case "bool", "string", "int":
62-
v.Set(f.DefValue)
62+
_ = v.Set(f.DefValue)
6363
}
6464
}
6565
})
@@ -111,8 +111,8 @@ func TestPRStatus_fork(t *testing.T) {
111111
defer run.SetPrepareCmd(func(cmd *exec.Cmd) run.Runnable {
112112
switch strings.Join(cmd.Args, " ") {
113113
case `git config --get-regexp ^branch\.blueberries\.(remote|merge)$`:
114-
return &test.OutputStub{[]byte(`branch.blueberries.remote origin
115-
branch.blueberries.merge refs/heads/blueberries`), nil}
114+
return &test.OutputStub{Out: []byte(`branch.blueberries.remote origin
115+
branch.blueberries.merge refs/heads/blueberries`)}
116116
default:
117117
panic("not implemented")
118118
}
@@ -312,7 +312,7 @@ No pull requests match your search in OWNER/REPO
312312
Labels []string
313313
}
314314
}{}
315-
json.Unmarshal(bodyBytes, &reqBody)
315+
_ = json.Unmarshal(bodyBytes, &reqBody)
316316

317317
eq(t, reqBody.Variables.State, []string{"OPEN", "CLOSED", "MERGED"})
318318
eq(t, reqBody.Variables.Labels, []string{"one", "two", "three"})
@@ -357,7 +357,7 @@ func TestPRList_filteringClosed(t *testing.T) {
357357
State []string
358358
}
359359
}{}
360-
json.Unmarshal(bodyBytes, &reqBody)
360+
_ = json.Unmarshal(bodyBytes, &reqBody)
361361

362362
eq(t, reqBody.Variables.State, []string{"CLOSED", "MERGED"})
363363
}
@@ -381,7 +381,7 @@ func TestPRList_filteringAssignee(t *testing.T) {
381381
Q string
382382
}
383383
}{}
384-
json.Unmarshal(bodyBytes, &reqBody)
384+
_ = json.Unmarshal(bodyBytes, &reqBody)
385385

386386
eq(t, reqBody.Variables.Q, `repo:OWNER/REPO assignee:hubot is:pr sort:created-desc is:merged label:"needs tests" base:"develop"`)
387387
}

command/repo_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ func TestRepoCreate(t *testing.T) {
466466
}
467467

468468
bodyBytes, _ := ioutil.ReadAll(http.Requests[0].Body)
469-
json.Unmarshal(bodyBytes, &reqBody)
469+
_ = json.Unmarshal(bodyBytes, &reqBody)
470470
if repoName := reqBody.Variables.Input["name"].(string); repoName != "REPO" {
471471
t.Errorf("expected %q, got %q", "REPO", repoName)
472472
}
@@ -533,7 +533,7 @@ func TestRepoCreate_org(t *testing.T) {
533533
eq(t, http.Requests[0].URL.Path, "/users/ORG")
534534

535535
bodyBytes, _ := ioutil.ReadAll(http.Requests[1].Body)
536-
json.Unmarshal(bodyBytes, &reqBody)
536+
_ = json.Unmarshal(bodyBytes, &reqBody)
537537
if orgID := reqBody.Variables.Input["ownerId"].(string); orgID != "ORGID" {
538538
t.Errorf("expected %q, got %q", "ORGID", orgID)
539539
}
@@ -598,7 +598,7 @@ func TestRepoCreate_orgWithTeam(t *testing.T) {
598598
eq(t, http.Requests[0].URL.Path, "/orgs/ORG/teams/monkeys")
599599

600600
bodyBytes, _ := ioutil.ReadAll(http.Requests[1].Body)
601-
json.Unmarshal(bodyBytes, &reqBody)
601+
_ = json.Unmarshal(bodyBytes, &reqBody)
602602
if orgID := reqBody.Variables.Input["ownerId"].(string); orgID != "ORGID" {
603603
t.Errorf("expected %q, got %q", "ORGID", orgID)
604604
}

command/root.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ var versionCmd = &cobra.Command{
8585
Use: "version",
8686
Hidden: true,
8787
Run: func(cmd *cobra.Command, args []string) {
88-
fmt.Printf(versionOutput)
88+
fmt.Print(versionOutput)
8989
},
9090
}
9191

0 commit comments

Comments
 (0)
X Tutup