From 30998cbb18599a39be60152edcd664a2572dc75c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Mon, 27 May 2019 10:14:26 +0100 Subject: [PATCH] start making staticcheck happier --- issue.go | 11 ++++++----- jira.go | 3 --- jiracli/cli.go | 4 ++-- jiracli/templates.go | 2 +- jiracli/util.go | 5 ++--- jiracmd/transition.go | 2 +- jiracmd/unexportTemplates.go | 8 +++----- utils.go | 2 +- 8 files changed, 16 insertions(+), 21 deletions(-) diff --git a/issue.go b/issue.go index ea2069f..ef17b16 100644 --- a/issue.go +++ b/issue.go @@ -101,9 +101,7 @@ func GetIssueWorklog(ua HttpClient, endpoint string, issue string) (*jiradata.Wo } startAt = startAt + maxResults total = results.Total - for _, worklog := range results.Worklogs { - worklogs = append(worklogs, worklog) - } + worklogs = append(worklogs, results.Worklogs...) } else { return nil, responseError(resp) } @@ -238,7 +236,7 @@ func GetIssueCreateMetaProject(ua HttpClient, endpoint string, projectKey string return project, nil } } - return nil, fmt.Errorf("Project %s not found", projectKey) + return nil, fmt.Errorf("project %s not found", projectKey) } return nil, responseError(resp) } @@ -272,7 +270,7 @@ func GetIssueCreateMetaIssueType(ua HttpClient, endpoint string, projectKey, iss } } } - return nil, fmt.Errorf("Project %s and IssueType %s not found", projectKey, issueTypeName) + return nil, fmt.Errorf("project %s and IssueType %s not found", projectKey, issueTypeName) } return nil, responseError(resp) } @@ -563,6 +561,9 @@ func IssueAttachFile(ua HttpClient, endpoint string, issue, filename string, con } uri, err := url.Parse(URLJoin(endpoint, "rest/api/2/issue", issue, "attachments")) + if err != nil { + return nil, err + } req := oreo.RequestBuilder(uri).WithMethod("POST").WithHeader( "X-Atlassian-Token", "no-check", ).WithHeader( diff --git a/jira.go b/jira.go index d1726bc..6998e44 100644 --- a/jira.go +++ b/jira.go @@ -2,11 +2,8 @@ package jira import ( "github.com/coryb/oreo" - logging "gopkg.in/op/go-logging.v1" ) -var log = logging.MustGetLogger("jira") - const VERSION = "1.0.20" type Jira struct { diff --git a/jiracli/cli.go b/jiracli/cli.go index 5683879..f5ebc4a 100644 --- a/jiracli/cli.go +++ b/jiracli/cli.go @@ -340,7 +340,7 @@ func (o *CommonOptions) editFile(fileName string) (changes bool, err error) { if oldCount != newCount { return true, nil } - if bytes.Compare(oldBuf[:oldCount], newBuf[:newCount]) != 0 { + if !bytes.Equal(oldBuf[:oldCount], newBuf[:newCount]) { return true, nil } } @@ -352,7 +352,7 @@ func (o *CommonOptions) editFile(fileName string) (changes bool, err error) { return false, err } -var EditLoopAbort = fmt.Errorf("Edit Loop aborted by request") +var EditLoopAbort = fmt.Errorf("edit Loop aborted by request") func EditLoop(opts *CommonOptions, input interface{}, output interface{}, submit func() error) error { tmpFile, err := tmpTemplate(opts.Template.Value, input) diff --git a/jiracli/templates.go b/jiracli/templates.go index 057d360..d1e7675 100644 --- a/jiracli/templates.go +++ b/jiracli/templates.go @@ -119,7 +119,7 @@ func TemplateProcessor() *template.Template { } }, "indent": func(spaces int, content string) string { - indent := make([]rune, spaces+1, spaces+1) + indent := make([]rune, spaces+1) indent[0] = '\n' for i := 1; i < spaces+1; i++ { indent[i] = ' ' diff --git a/jiracli/util.go b/jiracli/util.go index decbeec..42d4704 100644 --- a/jiracli/util.go +++ b/jiracli/util.go @@ -1,7 +1,6 @@ package jiracli import ( - "errors" "fmt" "io" "io/ioutil" @@ -31,7 +30,7 @@ func findClosestParentPath(fileName string) (string, error) { if len(paths) > 0 { return paths[len(paths)-1], nil } - return "", errors.New(fmt.Sprintf("%s not found in parent directory hierarchy", fileName)) + return "", fmt.Errorf("%s not found in parent directory hierarchy", fileName) } func tmpYml(tmpFilePrefix string) (*os.File, error) { @@ -86,7 +85,7 @@ func fuzzyAge(start string) (string, error) { if err != nil { return "", err } - delta := time.Now().Sub(t) + delta := time.Since(t) if delta.Minutes() < 2 { return "a minute", nil } else if dm := delta.Minutes(); dm < 45 { diff --git a/jiracmd/transition.go b/jiracmd/transition.go index c376c66..361a1c5 100644 --- a/jiracmd/transition.go +++ b/jiracmd/transition.go @@ -129,7 +129,7 @@ func CmdTransition(o *oreo.Client, globals *jiracli.GlobalOptions, opts *Transit *jiradata.Issue `yaml:",inline"` // Yes, Meta and Transition are redundant, but this is for backwards compatibility // with old templates - Meta *jiradata.Transition `yaml:"meta,omitempty" json:"meta,omitemtpy"` + Meta *jiradata.Transition `yaml:"meta,omitempty" json:"meta,omitempty"` Transition *jiradata.Transition `yaml:"transition,omitempty" json:"transition,omitempty"` Overrides map[string]string `yaml:"overrides,omitempty" json:"overrides,omitempty"` } diff --git a/jiracmd/unexportTemplates.go b/jiracmd/unexportTemplates.go index 5c7fc72..c2daebc 100644 --- a/jiracmd/unexportTemplates.go +++ b/jiracmd/unexportTemplates.go @@ -47,15 +47,13 @@ func CmdUnexportTemplates(globals *jiracli.GlobalOptions, opts *ExportTemplatesO if err != nil { return err } - if bytes.Compare([]byte(template), contents) == 0 { + if bytes.Equal([]byte(template), contents) { if !globals.Quiet.Value { log.Notice("Removing %s, template identical to default", templateFile) } os.Remove(templateFile) - } else { - if !globals.Quiet.Value { - log.Notice("Skipping %s, found customizations to template", templateFile) - } + } else if !globals.Quiet.Value { + log.Notice("Skipping %s, found customizations to template", templateFile) } } return nil diff --git a/utils.go b/utils.go index 5a3be9f..d6eac96 100644 --- a/utils.go +++ b/utils.go @@ -27,7 +27,7 @@ func readJSON(input io.Reader, data interface{}) error { func URLJoin(endpoint string, paths ...string) string { u, err := url.Parse(endpoint) if err != nil { - panic(fmt.Errorf("Unable to parse endpoint: %s", endpoint)) + panic(fmt.Errorf("unable to parse endpoint: %s", endpoint)) } paths = append([]string{u.Path}, paths...) u.Path = path.Join(paths...)