From d99698f048b7c5486416b863aa9a73a671c54de7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Tue, 26 Nov 2019 16:18:20 +0100 Subject: [PATCH] Fix minor code issues discovered by staticcheck `honnef.co/go/tools/cmd/staticcheck` --- api/queries_issue.go | 6 +----- command/pr_test.go | 4 ++-- context/config_setup.go | 3 +++ 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/api/queries_issue.go b/api/queries_issue.go index da98e8442..54aab484f 100644 --- a/api/queries_issue.go +++ b/api/queries_issue.go @@ -203,9 +203,5 @@ func IssueList(client *Client, ghRepo Repo, state string, labels []string, assig return nil, err } - issues := []Issue{} - for _, issue := range resp.Repository.Issues.Nodes { - issues = append(issues, issue) - } - return issues, nil + return resp.Repository.Issues.Nodes, nil } diff --git a/command/pr_test.go b/command/pr_test.go index 47851a5e8..701874f13 100644 --- a/command/pr_test.go +++ b/command/pr_test.go @@ -147,7 +147,7 @@ func TestPRView_NoActiveBranch(t *testing.T) { }) defer restoreCmd() - output, err := test.RunCommand(RootCmd, "pr view") + _, err := test.RunCommand(RootCmd, "pr view") if err == nil || err.Error() != "the 'master' branch has no open pull requests" { t.Errorf("error running command `pr view`: %v", err) } @@ -157,7 +157,7 @@ func TestPRView_NoActiveBranch(t *testing.T) { } // Now run again but provide a PR number - output, err = test.RunCommand(RootCmd, "pr view 23") + output, err := test.RunCommand(RootCmd, "pr view 23") if err != nil { t.Errorf("error running command `pr view`: %v", err) } diff --git a/context/config_setup.go b/context/config_setup.go index bb7addbce..48a037a24 100644 --- a/context/config_setup.go +++ b/context/config_setup.go @@ -66,6 +66,9 @@ func setupConfigFile(filename string) (*configEntry, error) { defer config.Close() yamlData, err := yaml.Marshal(data) + if err != nil { + return nil, err + } n, err := config.Write(yamlData) if err == nil && n < len(yamlData) { err = io.ErrShortWrite