From 389314f9a7138321c8e45d69c87b47e61ba8a736 Mon Sep 17 00:00:00 2001 From: Jason Wells Date: Sun, 28 Aug 2022 08:43:45 -0700 Subject: [PATCH] Fix lint errors. Signed-off-by: Jason Wells --- cmd/jiralert/main.go | 2 +- pkg/config/config.go | 6 +++--- pkg/config/config_test.go | 2 +- pkg/notify/notify.go | 3 ++- pkg/notify/notify_test.go | 30 +++++++++++++++--------------- 5 files changed, 22 insertions(+), 21 deletions(-) diff --git a/cmd/jiralert/main.go b/cmd/jiralert/main.go index 4b643a3..dd6c56c 100644 --- a/cmd/jiralert/main.go +++ b/cmd/jiralert/main.go @@ -22,7 +22,7 @@ import ( "runtime" "strconv" - "github.com/andygrunwald/go-jira" + jira "github.com/andygrunwald/go-jira" "github.com/go-kit/kit/log" "github.com/go-kit/kit/log/level" diff --git a/pkg/config/config.go b/pkg/config/config.go index 08b72b3..5dd8b27 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -28,7 +28,7 @@ import ( "github.com/go-kit/kit/log/level" "github.com/trivago/tgo/tcontainer" - "gopkg.in/yaml.v2" + yaml "gopkg.in/yaml.v2" ) // Secret is a string that must not be revealed on marshaling. @@ -351,7 +351,7 @@ var durationRE = regexp.MustCompile("^([0-9]+)(y|w|d|h|m|s|ms)$") func ParseDuration(durationStr string) (Duration, error) { matches := durationRE.FindStringSubmatch(durationStr) if len(matches) != 3 { - return 0, fmt.Errorf("not a valid duration string: %q", durationStr) + return Duration(time.Duration(0)), fmt.Errorf("not a valid duration string: %q", durationStr) } var ( n, _ = strconv.Atoi(matches[1]) @@ -373,7 +373,7 @@ func ParseDuration(durationStr string) (Duration, error) { case "ms": // Value already correct default: - return 0, fmt.Errorf("invalid time unit in duration string: %q", unit) + return Duration(time.Duration(0)), fmt.Errorf("invalid time unit in duration string: %q", unit) } return Duration(dur), nil } diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go index 32c85bd..f2c4c3b 100644 --- a/pkg/config/config_test.go +++ b/pkg/config/config_test.go @@ -21,7 +21,7 @@ import ( "github.com/go-kit/kit/log" "github.com/stretchr/testify/require" - "gopkg.in/yaml.v2" + yaml "gopkg.in/yaml.v2" ) const testConf = ` diff --git a/pkg/notify/notify.go b/pkg/notify/notify.go index b85de41..c026b1d 100644 --- a/pkg/notify/notify.go +++ b/pkg/notify/notify.go @@ -21,7 +21,7 @@ import ( "strings" "time" - "github.com/andygrunwald/go-jira" + jira "github.com/andygrunwald/go-jira" "github.com/go-kit/kit/log" "github.com/go-kit/kit/log/level" "github.com/pkg/errors" @@ -164,6 +164,7 @@ func (r *Receiver) Notify(data *alertmanager.Data, hashJiraLabel bool) (bool, er if len(r.conf.Components) > 0 { issue.Fields.Components = make([]*jira.Component, 0, len(r.conf.Components)) for _, component := range r.conf.Components { + //nolint:typecheck // lint flags issueComp as not being used, even though it's referenced below. issueComp, err := r.tmpl.Execute(component, data) if err != nil { return false, errors.Wrap(err, "render issue component") diff --git a/pkg/notify/notify_test.go b/pkg/notify/notify_test.go index 19c10ef..93b8bd7 100644 --- a/pkg/notify/notify_test.go +++ b/pkg/notify/notify_test.go @@ -21,7 +21,7 @@ import ( "github.com/trivago/tgo/tcontainer" - "github.com/andygrunwald/go-jira" + jira "github.com/andygrunwald/go-jira" "github.com/go-kit/kit/log" "github.com/pkg/errors" "github.com/prometheus-community/jiralert/pkg/alertmanager" @@ -203,9 +203,9 @@ func TestNotify_JIRAInteraction(t *testing.T) { initJira: func(t *testing.T) *fakeJira { return newTestFakeJira() }, inputAlert: &alertmanager.Data{ Alerts: alertmanager.Alerts{ - {Status: alertmanager.AlertFiring}, - {Status: "not firing"}, - {Status: alertmanager.AlertFiring}, + alertmanager.Alert{Status: alertmanager.AlertFiring}, + alertmanager.Alert{Status: "not firing"}, + alertmanager.Alert{Status: alertmanager.AlertFiring}, }, Status: alertmanager.AlertFiring, GroupLabels: alertmanager.KV{"a": "b", "c": "d"}, @@ -246,8 +246,8 @@ func TestNotify_JIRAInteraction(t *testing.T) { }, inputAlert: &alertmanager.Data{ Alerts: alertmanager.Alerts{ - {Status: "not firing"}, - {Status: alertmanager.AlertFiring}, // Only one firing now. + alertmanager.Alert{Status: "not firing"}, + alertmanager.Alert{Status: alertmanager.AlertFiring}, // Only one firing now. }, Status: alertmanager.AlertFiring, GroupLabels: alertmanager.KV{"a": "b", "c": "d"}, @@ -289,8 +289,8 @@ func TestNotify_JIRAInteraction(t *testing.T) { }, inputAlert: &alertmanager.Data{ Alerts: alertmanager.Alerts{ - {Status: "not firing"}, - {Status: alertmanager.AlertFiring}, // Only one firing now. + alertmanager.Alert{Status: "not firing"}, + alertmanager.Alert{Status: alertmanager.AlertFiring}, // Only one firing now. }, Status: alertmanager.AlertFiring, GroupLabels: alertmanager.KV{"a": "b", "c": "d"}, @@ -341,8 +341,8 @@ func TestNotify_JIRAInteraction(t *testing.T) { }, inputAlert: &alertmanager.Data{ Alerts: alertmanager.Alerts{ - {Status: "not firing"}, - {Status: alertmanager.AlertFiring}, // Only one firing now. + alertmanager.Alert{Status: "not firing"}, + alertmanager.Alert{Status: alertmanager.AlertFiring}, // Only one firing now. }, Status: alertmanager.AlertFiring, GroupLabels: alertmanager.KV{"a": "b", "c": "d"}, @@ -396,8 +396,8 @@ func TestNotify_JIRAInteraction(t *testing.T) { }, inputAlert: &alertmanager.Data{ Alerts: alertmanager.Alerts{ - {Status: "not firing"}, - {Status: alertmanager.AlertFiring}, // Only one firing now. + alertmanager.Alert{Status: "not firing"}, + alertmanager.Alert{Status: alertmanager.AlertFiring}, // Only one firing now. }, Status: alertmanager.AlertFiring, GroupLabels: alertmanager.KV{"a": "b", "c": "d"}, @@ -451,8 +451,8 @@ func TestNotify_JIRAInteraction(t *testing.T) { }, inputAlert: &alertmanager.Data{ Alerts: alertmanager.Alerts{ - {Status: "not firing"}, - {Status: alertmanager.AlertFiring}, // Only one firing now. + alertmanager.Alert{Status: "not firing"}, + alertmanager.Alert{Status: alertmanager.AlertFiring}, // Only one firing now. }, Status: alertmanager.AlertFiring, GroupLabels: alertmanager.KV{"a": "b", "c": "d"}, @@ -497,7 +497,7 @@ func TestNotify_JIRAInteraction(t *testing.T) { inputConfig: testReceiverConfigAutoResolve(), inputAlert: &alertmanager.Data{ Alerts: alertmanager.Alerts{ - {Status: "resolved"}, + alertmanager.Alert{Status: "resolved"}, }, Status: alertmanager.AlertResolved, GroupLabels: alertmanager.KV{"a": "b", "c": "d"},