From bb5aaa2dce70cb78487bc498ffe6de07cca93685 Mon Sep 17 00:00:00 2001 From: Mario Trangoni Date: Tue, 18 Sep 2018 23:18:39 +0200 Subject: [PATCH 1/3] pkg/services/sqlstore/alert_notification.go: Simplify err check $ gometalinter --vendor --disable=all --enable=megacheck --deadline=10m ./... pkg/services/sqlstore/alert_notification.go:242:3:warning: 'if err != nil { return err }; return nil' can be simplified to 'return err' (S1013) (megacheck) --- pkg/services/sqlstore/alert_notification.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/pkg/services/sqlstore/alert_notification.go b/pkg/services/sqlstore/alert_notification.go index 19ed960638e..31867910ddb 100644 --- a/pkg/services/sqlstore/alert_notification.go +++ b/pkg/services/sqlstore/alert_notification.go @@ -239,11 +239,8 @@ func RecordNotificationJournal(ctx context.Context, cmd *m.RecordNotificationJou Success: cmd.Success, } - if _, err := sess.Insert(journalEntry); err != nil { - return err - } - - return nil + _, err := sess.Insert(journalEntry) + return err }) } From f19fd1a9b0e662bdaf9f7dafd967c16fd91a8196 Mon Sep 17 00:00:00 2001 From: Mario Trangoni Date: Tue, 18 Sep 2018 23:27:06 +0200 Subject: [PATCH 2/3] pkg/plugins/dashboards_updater.go: Simplify err check $ gometalinter --vendor --disable=all --enable=megacheck --deadline=10m ./... pkg/plugins/dashboards_updater.go:51:2:warning: 'if err != nil { return err }; return nil' can be simplified to 'return err' (S1013) (megacheck) --- pkg/plugins/dashboards_updater.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/pkg/plugins/dashboards_updater.go b/pkg/plugins/dashboards_updater.go index ebe11ed32d4..616d4541bec 100644 --- a/pkg/plugins/dashboards_updater.go +++ b/pkg/plugins/dashboards_updater.go @@ -48,11 +48,7 @@ func autoUpdateAppDashboard(pluginDashInfo *PluginDashboardInfoDTO, orgId int64) Path: pluginDashInfo.Path, } - if err := bus.Dispatch(&updateCmd); err != nil { - return err - } - - return nil + return bus.Dispatch(&updateCmd) } func syncPluginDashboards(pluginDef *PluginBase, orgId int64) { From 13a1d0a026c4cadd61dac8847776e51493bc4255 Mon Sep 17 00:00:00 2001 From: Mario Trangoni Date: Tue, 18 Sep 2018 23:36:02 +0200 Subject: [PATCH 3/3] pkg/tsdb/elasticsearch/client/client.go: use time.Since instead of time.Now().Sub $ gometalinter --vendor --disable=all --enable=megacheck --deadline=10m ./... pkg/tsdb/elasticsearch/client/client.go:147:13:warning: should use time.Since instead of time.Now().Sub (S1012) (megacheck) pkg/tsdb/elasticsearch/client/client.go:190:14:warning: should use time.Since instead of time.Now().Sub (S1012) (megacheck) pkg/tsdb/elasticsearch/client/client.go:218:13:warning: should use time.Since instead of time.Now().Sub (S1012) (megacheck) --- pkg/tsdb/elasticsearch/client/client.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/tsdb/elasticsearch/client/client.go b/pkg/tsdb/elasticsearch/client/client.go index 78973b3faa6..4ebe0db8f89 100644 --- a/pkg/tsdb/elasticsearch/client/client.go +++ b/pkg/tsdb/elasticsearch/client/client.go @@ -144,7 +144,7 @@ func (c *baseClientImpl) encodeBatchRequests(requests []*multiRequest) ([]byte, payload.WriteString(body + "\n") } - elapsed := time.Now().Sub(start) + elapsed := time.Since(start) clientLog.Debug("Encoded batch requests to json", "took", elapsed) return payload.Bytes(), nil @@ -187,7 +187,7 @@ func (c *baseClientImpl) executeRequest(method, uriPath string, body []byte) (*h start := time.Now() defer func() { - elapsed := time.Now().Sub(start) + elapsed := time.Since(start) clientLog.Debug("Executed request", "took", elapsed) }() return ctxhttp.Do(c.ctx, httpClient, req) @@ -215,7 +215,7 @@ func (c *baseClientImpl) ExecuteMultisearch(r *MultiSearchRequest) (*MultiSearch return nil, err } - elapsed := time.Now().Sub(start) + elapsed := time.Since(start) clientLog.Debug("Decoded multisearch json response", "took", elapsed) msr.Status = res.StatusCode