start making staticcheck happier

This commit is contained in:
Daniel Martí
2019-05-27 10:14:26 +01:00
committed by Cory Bennett
parent 89fe2ecf16
commit 30998cbb18
8 changed files with 16 additions and 21 deletions
+6 -5
View File
@@ -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(
-3
View File
@@ -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 {
+2 -2
View File
@@ -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)
+1 -1
View File
@@ -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] = ' '
+2 -3
View File
@@ -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 {
+1 -1
View File
@@ -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"`
}
+2 -4
View File
@@ -47,16 +47,14 @@ 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 {
} else if !globals.Quiet.Value {
log.Notice("Skipping %s, found customizations to template", templateFile)
}
}
}
return nil
}
+1 -1
View File
@@ -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...)