mirror of
https://github.com/Threnklyn/jira.git
synced 2026-05-19 04:33:28 +02:00
start making staticcheck happier
This commit is contained in:
committed by
Cory Bennett
parent
89fe2ecf16
commit
30998cbb18
@@ -101,9 +101,7 @@ func GetIssueWorklog(ua HttpClient, endpoint string, issue string) (*jiradata.Wo
|
|||||||
}
|
}
|
||||||
startAt = startAt + maxResults
|
startAt = startAt + maxResults
|
||||||
total = results.Total
|
total = results.Total
|
||||||
for _, worklog := range results.Worklogs {
|
worklogs = append(worklogs, results.Worklogs...)
|
||||||
worklogs = append(worklogs, worklog)
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
return nil, responseError(resp)
|
return nil, responseError(resp)
|
||||||
}
|
}
|
||||||
@@ -238,7 +236,7 @@ func GetIssueCreateMetaProject(ua HttpClient, endpoint string, projectKey string
|
|||||||
return project, nil
|
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)
|
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)
|
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"))
|
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(
|
req := oreo.RequestBuilder(uri).WithMethod("POST").WithHeader(
|
||||||
"X-Atlassian-Token", "no-check",
|
"X-Atlassian-Token", "no-check",
|
||||||
).WithHeader(
|
).WithHeader(
|
||||||
|
|||||||
@@ -2,11 +2,8 @@ package jira
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/coryb/oreo"
|
"github.com/coryb/oreo"
|
||||||
logging "gopkg.in/op/go-logging.v1"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var log = logging.MustGetLogger("jira")
|
|
||||||
|
|
||||||
const VERSION = "1.0.20"
|
const VERSION = "1.0.20"
|
||||||
|
|
||||||
type Jira struct {
|
type Jira struct {
|
||||||
|
|||||||
+2
-2
@@ -340,7 +340,7 @@ func (o *CommonOptions) editFile(fileName string) (changes bool, err error) {
|
|||||||
if oldCount != newCount {
|
if oldCount != newCount {
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
if bytes.Compare(oldBuf[:oldCount], newBuf[:newCount]) != 0 {
|
if !bytes.Equal(oldBuf[:oldCount], newBuf[:newCount]) {
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -352,7 +352,7 @@ func (o *CommonOptions) editFile(fileName string) (changes bool, err error) {
|
|||||||
return false, err
|
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 {
|
func EditLoop(opts *CommonOptions, input interface{}, output interface{}, submit func() error) error {
|
||||||
tmpFile, err := tmpTemplate(opts.Template.Value, input)
|
tmpFile, err := tmpTemplate(opts.Template.Value, input)
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ func TemplateProcessor() *template.Template {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"indent": func(spaces int, content string) string {
|
"indent": func(spaces int, content string) string {
|
||||||
indent := make([]rune, spaces+1, spaces+1)
|
indent := make([]rune, spaces+1)
|
||||||
indent[0] = '\n'
|
indent[0] = '\n'
|
||||||
for i := 1; i < spaces+1; i++ {
|
for i := 1; i < spaces+1; i++ {
|
||||||
indent[i] = ' '
|
indent[i] = ' '
|
||||||
|
|||||||
+2
-3
@@ -1,7 +1,6 @@
|
|||||||
package jiracli
|
package jiracli
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
@@ -31,7 +30,7 @@ func findClosestParentPath(fileName string) (string, error) {
|
|||||||
if len(paths) > 0 {
|
if len(paths) > 0 {
|
||||||
return paths[len(paths)-1], nil
|
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) {
|
func tmpYml(tmpFilePrefix string) (*os.File, error) {
|
||||||
@@ -86,7 +85,7 @@ func fuzzyAge(start string) (string, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
delta := time.Now().Sub(t)
|
delta := time.Since(t)
|
||||||
if delta.Minutes() < 2 {
|
if delta.Minutes() < 2 {
|
||||||
return "a minute", nil
|
return "a minute", nil
|
||||||
} else if dm := delta.Minutes(); dm < 45 {
|
} else if dm := delta.Minutes(); dm < 45 {
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ func CmdTransition(o *oreo.Client, globals *jiracli.GlobalOptions, opts *Transit
|
|||||||
*jiradata.Issue `yaml:",inline"`
|
*jiradata.Issue `yaml:",inline"`
|
||||||
// Yes, Meta and Transition are redundant, but this is for backwards compatibility
|
// Yes, Meta and Transition are redundant, but this is for backwards compatibility
|
||||||
// with old templates
|
// 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"`
|
Transition *jiradata.Transition `yaml:"transition,omitempty" json:"transition,omitempty"`
|
||||||
Overrides map[string]string `yaml:"overrides,omitempty" json:"overrides,omitempty"`
|
Overrides map[string]string `yaml:"overrides,omitempty" json:"overrides,omitempty"`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,15 +47,13 @@ func CmdUnexportTemplates(globals *jiracli.GlobalOptions, opts *ExportTemplatesO
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if bytes.Compare([]byte(template), contents) == 0 {
|
if bytes.Equal([]byte(template), contents) {
|
||||||
if !globals.Quiet.Value {
|
if !globals.Quiet.Value {
|
||||||
log.Notice("Removing %s, template identical to default", templateFile)
|
log.Notice("Removing %s, template identical to default", templateFile)
|
||||||
}
|
}
|
||||||
os.Remove(templateFile)
|
os.Remove(templateFile)
|
||||||
} else {
|
} else if !globals.Quiet.Value {
|
||||||
if !globals.Quiet.Value {
|
log.Notice("Skipping %s, found customizations to template", templateFile)
|
||||||
log.Notice("Skipping %s, found customizations to template", templateFile)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ func readJSON(input io.Reader, data interface{}) error {
|
|||||||
func URLJoin(endpoint string, paths ...string) string {
|
func URLJoin(endpoint string, paths ...string) string {
|
||||||
u, err := url.Parse(endpoint)
|
u, err := url.Parse(endpoint)
|
||||||
if err != nil {
|
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...)
|
paths = append([]string{u.Path}, paths...)
|
||||||
u.Path = path.Join(paths...)
|
u.Path = path.Join(paths...)
|
||||||
|
|||||||
Reference in New Issue
Block a user