diff --git a/.circleci/config.yml b/.circleci/config.yml index 7cb1ba7beb3..f6b7a7f9d38 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -826,7 +826,7 @@ jobs: command: | # To save memory, run in two batches golangci-lint run -v -j 4 --config scripts/go/configs/ci/.golangci.toml -E deadcode -E depguard -E dogsled \ - -E errcheck -E goconst -E golint -E gosec -E gosimple -E govet -E scopelint ./pkg/... + -E errcheck -E goconst -E golint -E gosec -E gosimple -E govet -E scopelint -E whitespace ./pkg/... golangci-lint run -v -j 4 --config scripts/go/configs/ci/.golangci.toml -E ineffassign \ -E rowserrcheck -E staticcheck -E structcheck -E typecheck -E unconvert -E unused -E varcheck ./pkg/... ./scripts/go/bin/revive -formatter stylish -config ./scripts/go/configs/revive.toml ./pkg/... diff --git a/pkg/api/admin.go b/pkg/api/admin.go index bc265e48aa5..65d550a8d1d 100644 --- a/pkg/api/admin.go +++ b/pkg/api/admin.go @@ -39,7 +39,6 @@ func AdminGetSettings(c *models.ReqContext) { } func AdminGetStats(c *models.ReqContext) { - statsQuery := models.GetAdminStatsQuery{} if err := bus.Dispatch(&statsQuery); err != nil { diff --git a/pkg/api/admin_users_test.go b/pkg/api/admin_users_test.go index c7b32f65976..aeab835bb21 100644 --- a/pkg/api/admin_users_test.go +++ b/pkg/api/admin_users_test.go @@ -21,7 +21,6 @@ const ( func TestAdminApiEndpoint(t *testing.T) { role := models.ROLE_ADMIN Convey("Given a server admin attempts to remove themself as an admin", t, func() { - updateCmd := dtos.AdminUpdateUserPermissionsForm{ IsGrafanaAdmin: false, } diff --git a/pkg/api/alerting_test.go b/pkg/api/alerting_test.go index 11d309b299a..a64ab697937 100644 --- a/pkg/api/alerting_test.go +++ b/pkg/api/alerting_test.go @@ -13,7 +13,6 @@ import ( func TestAlertingApiEndpoint(t *testing.T) { Convey("Given an alert in a dashboard with an acl", t, func() { - singleAlert := &models.Alert{Id: 1, DashboardId: 1, Name: "singlealert"} bus.AddHandler("test", func(query *models.GetAlertByIdQuery) error { diff --git a/pkg/api/annotations.go b/pkg/api/annotations.go index 362d1ba664c..40f6c48720d 100644 --- a/pkg/api/annotations.go +++ b/pkg/api/annotations.go @@ -11,7 +11,6 @@ import ( ) func GetAnnotations(c *models.ReqContext) Response { - query := &annotations.ItemQuery{ From: c.QueryInt64("from"), To: c.QueryInt64("to"), diff --git a/pkg/api/api.go b/pkg/api/api.go index 14de9043c53..bb6d5d217ab 100644 --- a/pkg/api/api.go +++ b/pkg/api/api.go @@ -112,7 +112,6 @@ func (hs *HTTPServer) registerRoutes() { // authed api r.Group("/api", func(apiRoute routing.RouteRegister) { - // user (signed in) apiRoute.Group("/user", func(userRoute routing.RouteRegister) { userRoute.Get("/", Wrap(GetSignedInUser)) @@ -383,7 +382,6 @@ func (hs *HTTPServer) registerRoutes() { // error test r.Get("/metrics/error", Wrap(GenerateError)) - }, reqSignedIn) // admin api diff --git a/pkg/api/common.go b/pkg/api/common.go index 19dc976b2c8..1c1e3e0e317 100644 --- a/pkg/api/common.go +++ b/pkg/api/common.go @@ -31,7 +31,6 @@ type NormalResponse struct { } func Wrap(action interface{}) macaron.Handler { - return func(c *models.ReqContext) { var res Response val, err := c.Invoke(action) @@ -48,7 +47,6 @@ func Wrap(action interface{}) macaron.Handler { func (r *NormalResponse) WriteTo(ctx *models.ReqContext) { if r.err != nil { ctx.Logger.Error(r.errMessage, "error", r.err, "remote_addr", ctx.RemoteAddr()) - } header := ctx.Resp.Header() diff --git a/pkg/api/dashboard.go b/pkg/api/dashboard.go index 2ec3bfd3d07..950b7860c4e 100644 --- a/pkg/api/dashboard.go +++ b/pkg/api/dashboard.go @@ -458,7 +458,6 @@ func GetDashboardVersion(c *models.ReqContext) Response { // POST /api/dashboards/calculate-diff performs diffs on two dashboards func CalculateDashboardDiff(c *models.ReqContext, apiOptions dtos.CalculateDiffOptions) Response { - guardianBase := guardian.New(apiOptions.Base.DashboardId, c.OrgId, c.SignedInUser) if canSave, err := guardianBase.CanSave(); err != nil || !canSave { return dashboardGuardianResponse(err) diff --git a/pkg/api/dashboard_test.go b/pkg/api/dashboard_test.go index b58cf217d3a..f1b9a962288 100644 --- a/pkg/api/dashboard_test.go +++ b/pkg/api/dashboard_test.go @@ -716,7 +716,6 @@ func TestDashboardApiEndpoint(t *testing.T) { }) Convey("Post dashboard response tests", t, func() { - // This tests that a valid request returns correct response Convey("Given a correct request for creating a dashboard", func() { @@ -953,7 +952,6 @@ func TestDashboardApiEndpoint(t *testing.T) { }) Convey("Given provisioned dashboard", t, func() { - bus.AddHandler("test", func(query *models.GetDashboardsBySlugQuery) error { query.Result = []*models.Dashboard{{}} return nil @@ -1062,7 +1060,6 @@ func GetDashboardShouldReturn200(sc *scenarioContext) dtos.DashboardFullWithMeta } func CallGetDashboard(sc *scenarioContext, hs *HTTPServer) { - sc.handlerFunc = hs.GetDashboard sc.fakeReqWithParams("GET", sc.url, map[string]string{}).exec() } diff --git a/pkg/api/datasources.go b/pkg/api/datasources.go index 967487fb8d6..560d4ef59a2 100644 --- a/pkg/api/datasources.go +++ b/pkg/api/datasources.go @@ -225,7 +225,6 @@ func fillWithSecureJSONData(cmd *models.UpdateDataSourceCommand) error { secureJSONData := ds.SecureJsonData.Decrypt() for k, v := range secureJSONData { - if _, ok := cmd.SecureJsonData[k]; !ok { cmd.SecureJsonData[k] = v } diff --git a/pkg/api/datasources_test.go b/pkg/api/datasources_test.go index 26962ad30f1..1927252a559 100644 --- a/pkg/api/datasources_test.go +++ b/pkg/api/datasources_test.go @@ -19,7 +19,6 @@ const ( func TestDataSourcesProxy(t *testing.T) { Convey("Given a user is logged in", t, func() { loggedInUserScenario("When calling GET on", "/api/datasources/", func(sc *scenarioContext) { - // Stubs the database query bus.AddHandler("test", func(query *models.GetDataSourcesQuery) error { So(query.OrgId, ShouldEqual, TestOrgID) diff --git a/pkg/api/live/conn.go b/pkg/api/live/conn.go index a1d43004cf5..ec2ac100dd5 100644 --- a/pkg/api/live/conn.go +++ b/pkg/api/live/conn.go @@ -93,7 +93,6 @@ func (c *connection) handleMessage(message []byte) { case "unsubscribe": c.hub.subChannel <- &streamSubscription{name: streamName, conn: c, remove: true} } - } func (c *connection) write(mt int, payload []byte) error { diff --git a/pkg/api/live/stream_manager.go b/pkg/api/live/stream_manager.go index e310c6dc01d..cc0ab81b630 100644 --- a/pkg/api/live/stream_manager.go +++ b/pkg/api/live/stream_manager.go @@ -88,7 +88,6 @@ func NewStream(name string) *Stream { } func (s *Stream) Push(packet *models.StreamPacket) { - messageBytes, _ := simplejson.NewFromAny(packet).Encode() for _, sub := range s.subscribers { diff --git a/pkg/api/pluginproxy/ds_proxy_test.go b/pkg/api/pluginproxy/ds_proxy_test.go index da415b5752e..d47f14a0640 100644 --- a/pkg/api/pluginproxy/ds_proxy_test.go +++ b/pkg/api/pluginproxy/ds_proxy_test.go @@ -30,7 +30,6 @@ import ( ) func TestDSRouteRule(t *testing.T) { - Convey("DataSourceProxy", t, func() { Convey("Plugin with routes", func() { plugin := &plugins.DataSourcePlugin{ diff --git a/pkg/api/pluginproxy/pluginproxy.go b/pkg/api/pluginproxy/pluginproxy.go index 85415ea2f6c..4cf8260cf6f 100644 --- a/pkg/api/pluginproxy/pluginproxy.go +++ b/pkg/api/pluginproxy/pluginproxy.go @@ -60,7 +60,6 @@ func NewApiPluginProxy(ctx *models.ReqContext, proxyPath string, route *plugins. targetURL, _ := url.Parse(route.URL) director := func(req *http.Request) { - req.URL.Scheme = targetURL.Scheme req.URL.Host = targetURL.Host req.Host = targetURL.Host diff --git a/pkg/api/pluginproxy/pluginproxy_test.go b/pkg/api/pluginproxy/pluginproxy_test.go index bff1b634755..c10f8a259a5 100644 --- a/pkg/api/pluginproxy/pluginproxy_test.go +++ b/pkg/api/pluginproxy/pluginproxy_test.go @@ -13,7 +13,6 @@ import ( ) func TestPluginProxy(t *testing.T) { - Convey("When getting proxy headers", t, func() { route := &plugins.AppPluginRoute{ Headers: []plugins.AppPluginRouteHeader{ @@ -129,7 +128,6 @@ func TestPluginProxy(t *testing.T) { So(route.URL, ShouldEqual, "{{.JsonData.dynamicUrl}}") }) }) - } // getPluginProxiedRequest is a helper for easier setup of tests based on global config and ReqContext. diff --git a/pkg/api/preferences.go b/pkg/api/preferences.go index e47ea0e3b54..f9eed7a6ec5 100644 --- a/pkg/api/preferences.go +++ b/pkg/api/preferences.go @@ -8,7 +8,6 @@ import ( // POST /api/preferences/set-home-dash func SetHomeDashboard(c *models.ReqContext, cmd models.SavePreferencesCommand) Response { - cmd.UserId = c.UserId cmd.OrgId = c.OrgId diff --git a/pkg/api/routing/route_register.go b/pkg/api/routing/route_register.go index 7a054ad0a24..b8781254ec4 100644 --- a/pkg/api/routing/route_register.go +++ b/pkg/api/routing/route_register.go @@ -72,10 +72,8 @@ type routeRegister struct { } func (rr *routeRegister) Insert(pattern string, fn func(RouteRegister), handlers ...macaron.Handler) { - //loop over all groups at current level for _, g := range rr.groups { - // apply routes if the prefix matches the pattern if g.prefix == pattern { g.Group("", fn) diff --git a/pkg/api/routing/route_register_test.go b/pkg/api/routing/route_register_test.go index 62e8989ff92..9b4e4755bcf 100644 --- a/pkg/api/routing/route_register_test.go +++ b/pkg/api/routing/route_register_test.go @@ -108,7 +108,6 @@ func TestRouteGroupedRegister(t *testing.T) { user.Group("/admin", func(admin RouteRegister) { admin.Delete("", emptyHandler("3")) admin.Get("/all", emptyHandler("3"), emptyHandler("4"), emptyHandler("5")) - }, emptyHandler("3")) }) @@ -235,7 +234,6 @@ func TestNamedMiddlewareRouteRegister(t *testing.T) { user.Group("/admin", func(admin RouteRegister) { admin.Delete("", emptyHandler("3")) admin.Get("/all", emptyHandler("3"), emptyHandler("4"), emptyHandler("5")) - }, emptyHandler("3")) }) diff --git a/pkg/api/stars.go b/pkg/api/stars.go index 3a6640cacf4..6af609db9d3 100644 --- a/pkg/api/stars.go +++ b/pkg/api/stars.go @@ -24,7 +24,6 @@ func StarDashboard(c *models.ReqContext) Response { } func UnstarDashboard(c *models.ReqContext) Response { - cmd := models.UnstarDashboardCommand{UserId: c.UserId, DashboardId: c.ParamsInt64(":id")} if cmd.DashboardId <= 0 { diff --git a/pkg/cmd/grafana-cli/commands/listremote_command.go b/pkg/cmd/grafana-cli/commands/listremote_command.go index ee2713cd376..1cc8b8b177a 100644 --- a/pkg/cmd/grafana-cli/commands/listremote_command.go +++ b/pkg/cmd/grafana-cli/commands/listremote_command.go @@ -21,7 +21,6 @@ func (cmd Command) listRemoteCommand(c utils.CommandLine) error { logger.Infof("id: %v version: %s\n", plugin.Id, ver.Version) } } - } return nil diff --git a/pkg/components/apikeygen/apikeygen_test.go b/pkg/components/apikeygen/apikeygen_test.go index c488ebe2846..844696e66e5 100644 --- a/pkg/components/apikeygen/apikeygen_test.go +++ b/pkg/components/apikeygen/apikeygen_test.go @@ -8,7 +8,6 @@ import ( ) func TestApiKeyGen(t *testing.T) { - Convey("When generating new api key", t, func() { result, err := New(12, "Cool key") So(err, ShouldBeNil) diff --git a/pkg/components/dashdiffs/formatter_basic.go b/pkg/components/dashdiffs/formatter_basic.go index fc13a24694e..1e89723cc99 100644 --- a/pkg/components/dashdiffs/formatter_basic.go +++ b/pkg/components/dashdiffs/formatter_basic.go @@ -162,7 +162,6 @@ func (b *BasicDiff) Basic(lines []*JSONLine) []*BasicBlock { // know there's a change somewhere in the JSON tree, but we // don't know exactly where, so we go deeper. } else { - // if the change is anything but unchanged, continue processing // // we keep "narrowing" the key as we go deeper, in order to diff --git a/pkg/components/dashdiffs/formatter_json.go b/pkg/components/dashdiffs/formatter_json.go index 10c7befe1bf..cd2bbe15885 100644 --- a/pkg/components/dashdiffs/formatter_json.go +++ b/pkg/components/dashdiffs/formatter_json.go @@ -240,7 +240,6 @@ func (f *JSONFormatter) processItem(value interface{}, deltas []diff.Delta, posi positionStr := position.String() if len(matchedDeltas) > 0 { for _, matchedDelta := range matchedDeltas { - switch matchedDelta := matchedDelta.(type) { case *diff.Object: switch value.(type) { @@ -314,7 +313,6 @@ func (f *JSONFormatter) processItem(value interface{}, deltas []diff.Delta, posi default: return errors.New("Unknown Delta type detected") } - } } else { f.printRecursive(positionStr, value, ChangeUnchanged) diff --git a/pkg/components/dashdiffs/formatter_test.go b/pkg/components/dashdiffs/formatter_test.go index 472d998feb5..b43b014e03d 100644 --- a/pkg/components/dashdiffs/formatter_test.go +++ b/pkg/components/dashdiffs/formatter_test.go @@ -61,7 +61,6 @@ func TestDiff(t *testing.T) { ) Convey("Testing dashboard diffs", t, func() { - // Compute the diff between the two JSON objects baseData, err := simplejson.NewJson([]byte(leftJSON)) So(err, ShouldBeNil) diff --git a/pkg/components/imguploader/imguploader.go b/pkg/components/imguploader/imguploader.go index 3a2bbca263e..2e7a4358070 100644 --- a/pkg/components/imguploader/imguploader.go +++ b/pkg/components/imguploader/imguploader.go @@ -27,7 +27,6 @@ var ( ) func NewImageUploader() (ImageUploader, error) { - switch setting.ImageUploadProvider { case "s3": s3sec, err := setting.Raw.GetSection("external_image_storage.s3") diff --git a/pkg/components/imguploader/webdavuploader_test.go b/pkg/components/imguploader/webdavuploader_test.go index 0178c9cda6c..125e190a52d 100644 --- a/pkg/components/imguploader/webdavuploader_test.go +++ b/pkg/components/imguploader/webdavuploader_test.go @@ -9,7 +9,6 @@ import ( ) func TestUploadToWebdav(t *testing.T) { - // Can be tested with this docker container: https://hub.docker.com/r/morrisjobke/webdav/ SkipConvey("[Integration test] for external_image_store.webdav", t, func() { webdavUploader, _ := NewWebdavImageUploader("http://localhost:8888/webdav/", "test", "test", "") diff --git a/pkg/events/events_test.go b/pkg/events/events_test.go index 9fcf41f76d5..6c587b2da1a 100644 --- a/pkg/events/events_test.go +++ b/pkg/events/events_test.go @@ -12,7 +12,6 @@ type TestEvent struct { } func TestEventCreation(t *testing.T) { - Convey("Event to wire event", t, func() { e := TestEvent{ Timestamp: time.Unix(1231421123, 223), @@ -22,5 +21,4 @@ func TestEventCreation(t *testing.T) { So(e.Timestamp.Unix(), ShouldEqual, wire.Timestamp.Unix()) So(wire.EventType, ShouldEqual, "TestEvent") }) - } diff --git a/pkg/infra/log/file_test.go b/pkg/infra/log/file_test.go index 97a3b8fe82f..7a7f32a1441 100644 --- a/pkg/infra/log/file_test.go +++ b/pkg/infra/log/file_test.go @@ -17,7 +17,6 @@ func (w *FileLogWriter) WriteLine(line string) error { } func TestLogFile(t *testing.T) { - Convey("When logging to file", t, func() { fileLogWrite := NewFileWriter() So(fileLogWrite, ShouldNotBeNil) diff --git a/pkg/infra/log/log.go b/pkg/infra/log/log.go index a7e62d33c0b..fb4cf89301f 100644 --- a/pkg/infra/log/log.go +++ b/pkg/infra/log/log.go @@ -264,7 +264,6 @@ func ReadLoggingConfig(modes []string, logsPath string, cfg *ini.File) error { func LogFilterHandler(maxLevel log15.Lvl, filters map[string]log15.Lvl, h log15.Handler) log15.Handler { return log15.FilterHandler(func(r *log15.Record) (pass bool) { - if len(filters) > 0 { for i := 0; i < len(r.Ctx); i += 2 { key, ok := r.Ctx[i].(string) diff --git a/pkg/infra/metrics/metrics.go b/pkg/infra/metrics/metrics.go index 4f51e4f36b6..31d2fcb4182 100644 --- a/pkg/infra/metrics/metrics.go +++ b/pkg/infra/metrics/metrics.go @@ -571,7 +571,6 @@ func initMetricVars() { StatsTotalDashboardVersions, StatsTotalAnnotations, ) - } func newCounterVecStartingAtZero(opts prometheus.CounterOpts, labels []string, labelValues ...string) *prometheus.CounterVec { diff --git a/pkg/infra/remotecache/database_storage.go b/pkg/infra/remotecache/database_storage.go index 8a22ad0591e..0964e7b7ceb 100644 --- a/pkg/infra/remotecache/database_storage.go +++ b/pkg/infra/remotecache/database_storage.go @@ -130,7 +130,6 @@ func (dc *databaseCache) Delete(key string) error { return err }) - } // CacheData is the struct representing the table in the database diff --git a/pkg/infra/remotecache/redis_storage_test.go b/pkg/infra/remotecache/redis_storage_test.go index 5e972fba71d..0ba9dcc907e 100644 --- a/pkg/infra/remotecache/redis_storage_test.go +++ b/pkg/infra/remotecache/redis_storage_test.go @@ -95,6 +95,5 @@ func Test_parseRedisConnStr(t *testing.T) { } assert.NoError(t, err, reason) assert.EqualValues(t, testCase.OutputOptions, options, reason) - } } diff --git a/pkg/infra/usagestats/usage_stats_test.go b/pkg/infra/usagestats/usage_stats_test.go index 917ccd6d3a2..e47ae223980 100644 --- a/pkg/infra/usagestats/usage_stats_test.go +++ b/pkg/infra/usagestats/usage_stats_test.go @@ -33,7 +33,6 @@ func TestMetrics(t *testing.T) { var getSystemStatsQuery *models.GetSystemStatsQuery uss.Bus.AddHandler(func(query *models.GetSystemStatsQuery) error { - query.Result = &models.SystemStats{ Dashboards: 1, Datasources: 2, @@ -273,7 +272,6 @@ func TestMetrics(t *testing.T) { So(metrics.Get("stats.auth_enabled.oauth_grafana_com.count").MustInt(), ShouldEqual, 1) So(metrics.Get("stats.packaging.deb.count").MustInt(), ShouldEqual, 1) - }) }) diff --git a/pkg/login/ldap_login.go b/pkg/login/ldap_login.go index 3e865b96232..ccd31303e0f 100644 --- a/pkg/login/ldap_login.go +++ b/pkg/login/ldap_login.go @@ -77,7 +77,6 @@ func DisableExternalUser(username string) error { userInfo := userQuery.Result if !userInfo.IsDisabled { - ldapLogger.Debug( "Disabling external user", "user", diff --git a/pkg/login/social/azuread_oauth_test.go b/pkg/login/social/azuread_oauth_test.go index 7fc04a9b733..3a0f15081b5 100644 --- a/pkg/login/social/azuread_oauth_test.go +++ b/pkg/login/social/azuread_oauth_test.go @@ -251,7 +251,6 @@ func TestSocialAzureAD_UserInfo(t *testing.T) { if err != nil { t.Error(err) } - } token := &oauth2.Token{} diff --git a/pkg/login/social/github_oauth.go b/pkg/login/social/github_oauth.go index 1ef08c60212..70a5492e804 100644 --- a/pkg/login/social/github_oauth.go +++ b/pkg/login/social/github_oauth.go @@ -114,7 +114,6 @@ func (s *SocialGithub) FetchTeamMemberships(client *http.Client) ([]GithubTeam, teams := make([]GithubTeam, 0) for hasMore { - response, err := HttpGet(client, url) if err != nil { return nil, fmt.Errorf("Error getting team memberships: %s", err) @@ -136,7 +135,6 @@ func (s *SocialGithub) FetchTeamMemberships(client *http.Client) ([]GithubTeam, } func (s *SocialGithub) HasMoreRecords(headers http.Header) (string, bool) { - value, exists := headers["Link"] if !exists { return "", false @@ -152,7 +150,6 @@ func (s *SocialGithub) HasMoreRecords(headers http.Header) (string, bool) { url := matches[1] return url, true - } func (s *SocialGithub) FetchOrganizations(client *http.Client, organizationsUrl string) ([]string, error) { @@ -181,7 +178,6 @@ func (s *SocialGithub) FetchOrganizations(client *http.Client, organizationsUrl } func (s *SocialGithub) UserInfo(client *http.Client, token *oauth2.Token) (*BasicUserInfo, error) { - var data struct { Id int `json:"id"` Login string `json:"login"` diff --git a/pkg/login/social/gitlab_oauth.go b/pkg/login/social/gitlab_oauth.go index 7e59851cbc7..a2705f9d227 100644 --- a/pkg/login/social/gitlab_oauth.go +++ b/pkg/login/social/gitlab_oauth.go @@ -90,7 +90,6 @@ func (s *SocialGitlab) GetGroupsPage(client *http.Client, url string) ([]string, } func (s *SocialGitlab) UserInfo(client *http.Client, token *oauth2.Token) (*BasicUserInfo, error) { - var data struct { Id int Username string diff --git a/pkg/middleware/auth_proxy/auth_proxy.go b/pkg/middleware/auth_proxy/auth_proxy.go index 15bd662e90a..08009f8eea7 100644 --- a/pkg/middleware/auth_proxy/auth_proxy.go +++ b/pkg/middleware/auth_proxy/auth_proxy.go @@ -102,7 +102,6 @@ func New(options *Options) *AuthProxy { // IsEnabled checks if the proxy auth is enabled func (auth *AuthProxy) IsEnabled() bool { - // Bail if the setting is not enabled return auth.enabled } diff --git a/pkg/middleware/auth_test.go b/pkg/middleware/auth_test.go index 0688b458ded..a5859a31483 100644 --- a/pkg/middleware/auth_test.go +++ b/pkg/middleware/auth_test.go @@ -9,7 +9,6 @@ import ( ) func TestMiddlewareAuth(t *testing.T) { - Convey("Given the grafana middleware", t, func() { reqSignIn := Auth(&AuthOptions{ReqSignedIn: true}) diff --git a/pkg/middleware/dashboard_redirect_test.go b/pkg/middleware/dashboard_redirect_test.go index c646b27d30b..5730bf15d14 100644 --- a/pkg/middleware/dashboard_redirect_test.go +++ b/pkg/middleware/dashboard_redirect_test.go @@ -80,5 +80,4 @@ func TestMiddlewareDashboardRedirect(t *testing.T) { }) }) }) - } diff --git a/pkg/middleware/middleware_test.go b/pkg/middleware/middleware_test.go index 8ac28318ef5..fcc91b6e1e2 100644 --- a/pkg/middleware/middleware_test.go +++ b/pkg/middleware/middleware_test.go @@ -46,7 +46,6 @@ func TestMiddleWareSecurityHeaders(t *testing.T) { setting.ERR_TEMPLATE_NAME = errorTemplate Convey("Given the grafana middleware", t, func() { - middlewareScenario(t, "middleware should get correct x-xss-protection header", func(sc *scenarioContext) { setting.XSSProtectionHeader = true sc.fakeReq("GET", "/api/").exec() diff --git a/pkg/middleware/org_redirect_test.go b/pkg/middleware/org_redirect_test.go index 86f9136356d..f0698ba30e4 100644 --- a/pkg/middleware/org_redirect_test.go +++ b/pkg/middleware/org_redirect_test.go @@ -11,7 +11,6 @@ import ( ) func TestOrgRedirectMiddleware(t *testing.T) { - Convey("Can redirect to correct org", t, func() { middlewareScenario(t, "when setting a correct org for the user", func(sc *scenarioContext) { sc.withTokenSessionCookie("token") diff --git a/pkg/middleware/quota_test.go b/pkg/middleware/quota_test.go index 174d9bf7286..75135e20612 100644 --- a/pkg/middleware/quota_test.go +++ b/pkg/middleware/quota_test.go @@ -13,7 +13,6 @@ import ( ) func TestMiddlewareQuota(t *testing.T) { - Convey("Given the grafana quota middleware", t, func() { setting.AnonymousEnabled = false setting.Quota = setting.QuotaSettings{ diff --git a/pkg/models/dashboard_acl_test.go b/pkg/models/dashboard_acl_test.go index 35357ff1cc9..220701f89de 100644 --- a/pkg/models/dashboard_acl_test.go +++ b/pkg/models/dashboard_acl_test.go @@ -9,7 +9,6 @@ import ( ) func TestDashboardAclModel(t *testing.T) { - Convey("When printing a PermissionType", t, func() { view := PERMISSION_VIEW printed := fmt.Sprint(view) diff --git a/pkg/models/dashboards_test.go b/pkg/models/dashboards_test.go index 39fd61a9e2c..d94d620ae07 100644 --- a/pkg/models/dashboards_test.go +++ b/pkg/models/dashboards_test.go @@ -9,7 +9,6 @@ import ( ) func TestDashboardModel(t *testing.T) { - Convey("Generate full dashboard url", t, func() { setting.AppUrl = "http://grafana.local/" fullUrl := GetFullDashboardUrl("uid", "my-dashboard") diff --git a/pkg/plugins/dashboard_importer.go b/pkg/plugins/dashboard_importer.go index f2905fd4048..beef921db44 100644 --- a/pkg/plugins/dashboard_importer.go +++ b/pkg/plugins/dashboard_importer.go @@ -113,7 +113,6 @@ type DashTemplateEvaluator struct { } func (this *DashTemplateEvaluator) findInput(varName string, varType string) *ImportDashboardInput { - for _, input := range this.inputs { if varType == input.Type && (input.Name == varName || input.Name == "*") { return &input @@ -146,7 +145,6 @@ func (this *DashTemplateEvaluator) Eval() (*simplejson.Json, error) { } func (this *DashTemplateEvaluator) evalValue(source *simplejson.Json) interface{} { - sourceValue := source.Interface() switch v := sourceValue.(type) { diff --git a/pkg/plugins/dashboard_importer_test.go b/pkg/plugins/dashboard_importer_test.go index c78da3ec91d..f8882cf5eaf 100644 --- a/pkg/plugins/dashboard_importer_test.go +++ b/pkg/plugins/dashboard_importer_test.go @@ -80,7 +80,6 @@ func TestDashboardImport(t *testing.T) { inputs := res.Get("__inputs") So(inputs.Interface(), ShouldBeNil) }) - }) } diff --git a/pkg/plugins/dashboards_test.go b/pkg/plugins/dashboards_test.go index 3d2b77285d6..91cb009367d 100644 --- a/pkg/plugins/dashboards_test.go +++ b/pkg/plugins/dashboards_test.go @@ -65,5 +65,4 @@ func TestPluginDashboards(t *testing.T) { So(dashboards[1].ImportedRevision, ShouldEqual, 0) }) }) - } diff --git a/pkg/plugins/frontend_plugin.go b/pkg/plugins/frontend_plugin.go index 89464a30138..555476d9a9d 100644 --- a/pkg/plugins/frontend_plugin.go +++ b/pkg/plugins/frontend_plugin.go @@ -53,7 +53,6 @@ func (fp *FrontendPluginBase) setPathsBasedOnApp(app *AppPlugin) { } func (fp *FrontendPluginBase) handleModuleDefaults() { - if isExternalPlugin(fp.PluginDir) { fp.Module = path.Join("plugins", fp.Id, "module") fp.BaseUrl = path.Join("public/plugins", fp.Id) diff --git a/pkg/plugins/frontend_plugin_test.go b/pkg/plugins/frontend_plugin_test.go index 311f9fcc510..8164a440f7c 100644 --- a/pkg/plugins/frontend_plugin_test.go +++ b/pkg/plugins/frontend_plugin_test.go @@ -8,7 +8,6 @@ import ( ) func TestFrontendPlugin(t *testing.T) { - Convey("When setting paths based on App on Windows", t, func() { setting.StaticRootPath = "c:\\grafana\\public" diff --git a/pkg/services/alerting/conditions/evaluator_test.go b/pkg/services/alerting/conditions/evaluator_test.go index fb06357df9e..ce3100b59e4 100644 --- a/pkg/services/alerting/conditions/evaluator_test.go +++ b/pkg/services/alerting/conditions/evaluator_test.go @@ -57,7 +57,6 @@ func TestEvaluators(t *testing.T) { So(err, ShouldBeNil) So(evaluator.Eval(null.FloatFromPtr(nil)), ShouldBeTrue) - }) }) } diff --git a/pkg/services/alerting/conditions/query_test.go b/pkg/services/alerting/conditions/query_test.go index 3d9cadfda4c..9decc1d4e05 100644 --- a/pkg/services/alerting/conditions/query_test.go +++ b/pkg/services/alerting/conditions/query_test.go @@ -16,11 +16,8 @@ import ( ) func TestQueryCondition(t *testing.T) { - Convey("when evaluating query condition", t, func() { - queryConditionScenario("Given avg() and > 100", func(ctx *queryConditionTestContext) { - ctx.reducer = `{"type": "avg"}` ctx.evaluator = `{"type": "gt", "params": [100]}` @@ -216,7 +213,6 @@ func (ctx *queryConditionTestContext) exec() (*alerting.ConditionResult, error) func queryConditionScenario(desc string, fn queryConditionScenarioFunc) { Convey(desc, func() { - bus.AddHandler("test", func(query *models.GetDataSourceByIdQuery) error { query.Result = &models.DataSource{Id: 1, Type: "graphite"} return nil diff --git a/pkg/services/alerting/conditions/reducer_test.go b/pkg/services/alerting/conditions/reducer_test.go index 1794e81b17e..0f9ffc13d34 100644 --- a/pkg/services/alerting/conditions/reducer_test.go +++ b/pkg/services/alerting/conditions/reducer_test.go @@ -12,7 +12,6 @@ import ( func TestSimpleReducer(t *testing.T) { Convey("Test simple reducer by calculating", t, func() { - Convey("sum", func() { result := testReducer("sum", 1, 2, 3) So(result, ShouldEqual, float64(6)) diff --git a/pkg/services/alerting/engine_test.go b/pkg/services/alerting/engine_test.go index fe866ee2f62..d2367690c38 100644 --- a/pkg/services/alerting/engine_test.go +++ b/pkg/services/alerting/engine_test.go @@ -49,7 +49,6 @@ func TestEngineProcessJob(t *testing.T) { job := &Job{running: true, Rule: &Rule{}} Convey("Should trigger retry if needed", func() { - Convey("error + not last attempt -> retry", func() { engine.evalHandler = NewFakeEvalHandler(0) @@ -94,7 +93,6 @@ func TestEngineProcessJob(t *testing.T) { }) Convey("Should trigger as many retries as needed", func() { - Convey("never success -> max retries number", func() { expectedAttempts := setting.AlertingMaxAttempts evalHandler := NewFakeEvalHandler(0) diff --git a/pkg/services/alerting/extractor.go b/pkg/services/alerting/extractor.go index 6fb109d71a2..497b1feaefe 100644 --- a/pkg/services/alerting/extractor.go +++ b/pkg/services/alerting/extractor.go @@ -82,7 +82,6 @@ func (e *DashAlertExtractor) getAlertFromPanels(jsonWithPanels *simplejson.Json, collapsedJSON, collapsed := panel.CheckGet("collapsed") // check if the panel is collapsed if collapsed && collapsedJSON.MustBool() { - // extract alerts from sub panels for collapsed panels alertSlice, err := e.getAlertFromPanels(panel, validateAlertFunc) if err != nil { diff --git a/pkg/services/alerting/extractor_test.go b/pkg/services/alerting/extractor_test.go index 86f0725e4ce..58c864a5a47 100644 --- a/pkg/services/alerting/extractor_test.go +++ b/pkg/services/alerting/extractor_test.go @@ -13,9 +13,7 @@ import ( ) func TestAlertRuleExtraction(t *testing.T) { - Convey("Parsing alert rules from dashboard json", t, func() { - RegisterCondition("query", func(model *simplejson.Json, index int) (Condition, error) { return &FakeCondition{}, nil }) @@ -80,7 +78,6 @@ func TestAlertRuleExtraction(t *testing.T) { }) Convey("Parsing and validating dashboard containing graphite alerts", func() { - dashJSON, err := simplejson.NewJson(json) So(err, ShouldBeNil) diff --git a/pkg/services/alerting/notifiers/alertmanager_test.go b/pkg/services/alerting/notifiers/alertmanager_test.go index fe9649443c1..58b553a257b 100644 --- a/pkg/services/alerting/notifiers/alertmanager_test.go +++ b/pkg/services/alerting/notifiers/alertmanager_test.go @@ -80,7 +80,6 @@ func TestWhenAlertManagerShouldNotify(t *testing.T) { //nolint:goconst func TestAlertmanagerNotifier(t *testing.T) { Convey("Alertmanager notifier tests", t, func() { - Convey("Parsing alert notification from settings", func() { Convey("empty settings should return error", func() { json := `{ }` diff --git a/pkg/services/alerting/notifiers/dingding.go b/pkg/services/alerting/notifiers/dingding.go index 740399168a7..9149f3a6665 100644 --- a/pkg/services/alerting/notifiers/dingding.go +++ b/pkg/services/alerting/notifiers/dingding.go @@ -57,7 +57,6 @@ func init() { }, }, }) - } func newDingDingNotifier(model *models.AlertNotification) (alerting.Notifier, error) { @@ -113,7 +112,6 @@ func (dd *DingDingNotifier) Notify(evalContext *alerting.EvalContext) error { } func (dd *DingDingNotifier) genBody(evalContext *alerting.EvalContext, messageURL string) ([]byte, error) { - q := url.Values{ "pc_slide": {"false"}, "url": {messageURL}, diff --git a/pkg/services/alerting/notifiers/dingding_test.go b/pkg/services/alerting/notifiers/dingding_test.go index 03b1a545e19..aa3f0b8852c 100644 --- a/pkg/services/alerting/notifiers/dingding_test.go +++ b/pkg/services/alerting/notifiers/dingding_test.go @@ -24,7 +24,6 @@ func TestDingDingNotifier(t *testing.T) { _, err := newDingDingNotifier(model) So(err, ShouldNotBeNil) - }) Convey("settings should trigger incident", func() { json := `{ "url": "https://www.google.com" }` diff --git a/pkg/services/alerting/notifiers/discord.go b/pkg/services/alerting/notifiers/discord.go index 54432940db1..dbcb22609ea 100644 --- a/pkg/services/alerting/notifiers/discord.go +++ b/pkg/services/alerting/notifiers/discord.go @@ -105,7 +105,6 @@ func (dn *DiscordNotifier) Notify(evalContext *alerting.EvalContext) error { fields := make([]map[string]interface{}, 0) for _, evt := range evalContext.EvalMatches { - fields = append(fields, map[string]interface{}{ "name": evt.Metric, "value": evt.Value.FullString(), diff --git a/pkg/services/alerting/notifiers/discord_test.go b/pkg/services/alerting/notifiers/discord_test.go index d1cbff6b859..f31027b2512 100644 --- a/pkg/services/alerting/notifiers/discord_test.go +++ b/pkg/services/alerting/notifiers/discord_test.go @@ -10,7 +10,6 @@ import ( func TestDiscordNotifier(t *testing.T) { Convey("Telegram notifier tests", t, func() { - Convey("Parsing alert notification from settings", func() { Convey("empty settings should return error", func() { json := `{ }` diff --git a/pkg/services/alerting/notifiers/email_test.go b/pkg/services/alerting/notifiers/email_test.go index b0c57f2f254..62c15e17741 100644 --- a/pkg/services/alerting/notifiers/email_test.go +++ b/pkg/services/alerting/notifiers/email_test.go @@ -10,7 +10,6 @@ import ( func TestEmailNotifier(t *testing.T) { Convey("Email notifier tests", t, func() { - Convey("Parsing alert notification from settings", func() { Convey("empty settings should return error", func() { json := `{ }` diff --git a/pkg/services/alerting/notifiers/googlechat_test.go b/pkg/services/alerting/notifiers/googlechat_test.go index 25dd5053397..27063851e5e 100644 --- a/pkg/services/alerting/notifiers/googlechat_test.go +++ b/pkg/services/alerting/notifiers/googlechat_test.go @@ -10,7 +10,6 @@ import ( func TestGoogleChatNotifier(t *testing.T) { Convey("Google Hangouts Chat notifier tests", t, func() { - Convey("Parsing alert notification from settings", func() { Convey("empty settings should return error", func() { json := `{ }` diff --git a/pkg/services/alerting/notifiers/hipchat.go b/pkg/services/alerting/notifiers/hipchat.go index ad4160f59db..8c76e7045b0 100644 --- a/pkg/services/alerting/notifiers/hipchat.go +++ b/pkg/services/alerting/notifiers/hipchat.go @@ -64,7 +64,6 @@ func init() { }, }, }) - } const ( diff --git a/pkg/services/alerting/notifiers/hipchat_test.go b/pkg/services/alerting/notifiers/hipchat_test.go index c8ef46bec1b..02ff0305ac5 100644 --- a/pkg/services/alerting/notifiers/hipchat_test.go +++ b/pkg/services/alerting/notifiers/hipchat_test.go @@ -11,7 +11,6 @@ import ( //nolint:goconst func TestHipChatNotifier(t *testing.T) { Convey("HipChat notifier tests", t, func() { - Convey("Parsing alert notification from settings", func() { Convey("empty settings should return error", func() { json := `{ }` diff --git a/pkg/services/alerting/notifiers/kafka_test.go b/pkg/services/alerting/notifiers/kafka_test.go index ba3b60ec23e..f22874268c2 100644 --- a/pkg/services/alerting/notifiers/kafka_test.go +++ b/pkg/services/alerting/notifiers/kafka_test.go @@ -10,7 +10,6 @@ import ( func TestKafkaNotifier(t *testing.T) { Convey("Kafka notifier tests", t, func() { - Convey("Parsing alert notification from settings", func() { Convey("empty settings should return error", func() { json := `{ }` diff --git a/pkg/services/alerting/notifiers/line_test.go b/pkg/services/alerting/notifiers/line_test.go index f8f50cc9b95..47438a3b33f 100644 --- a/pkg/services/alerting/notifiers/line_test.go +++ b/pkg/services/alerting/notifiers/line_test.go @@ -22,7 +22,6 @@ func TestLineNotifier(t *testing.T) { _, err := NewLINENotifier(model) So(err, ShouldNotBeNil) - }) Convey("settings should trigger incident", func() { json := ` diff --git a/pkg/services/alerting/notifiers/opsgenie_test.go b/pkg/services/alerting/notifiers/opsgenie_test.go index d01807280fa..d8bd7e9bfe2 100644 --- a/pkg/services/alerting/notifiers/opsgenie_test.go +++ b/pkg/services/alerting/notifiers/opsgenie_test.go @@ -13,7 +13,6 @@ import ( func TestOpsGenieNotifier(t *testing.T) { Convey("OpsGenie notifier tests", t, func() { - Convey("Parsing alert notification from settings", func() { Convey("empty settings should return error", func() { json := `{ }` diff --git a/pkg/services/alerting/notifiers/pagerduty.go b/pkg/services/alerting/notifiers/pagerduty.go index ee9dd6cfd8c..e2d8c6e5a02 100644 --- a/pkg/services/alerting/notifiers/pagerduty.go +++ b/pkg/services/alerting/notifiers/pagerduty.go @@ -134,7 +134,6 @@ type PagerdutyNotifier struct { // buildEventPayload is responsible for building the event payload body for sending to Pagerduty v2 API func (pn *PagerdutyNotifier) buildEventPayload(evalContext *alerting.EvalContext) ([]byte, error) { - eventType := "trigger" if evalContext.Rule.State == models.AlertStateOK { eventType = "resolve" @@ -241,7 +240,6 @@ func (pn *PagerdutyNotifier) buildEventPayload(evalContext *alerting.EvalContext // Notify sends an alert notification to PagerDuty func (pn *PagerdutyNotifier) Notify(evalContext *alerting.EvalContext) error { - if evalContext.Rule.State == models.AlertStateOK && !pn.AutoResolve { pn.log.Info("Not sending a trigger to Pagerduty", "state", evalContext.Rule.State, "auto resolve", pn.AutoResolve) return nil diff --git a/pkg/services/alerting/notifiers/pushover_test.go b/pkg/services/alerting/notifiers/pushover_test.go index 7b2d51a176f..764d2a39608 100644 --- a/pkg/services/alerting/notifiers/pushover_test.go +++ b/pkg/services/alerting/notifiers/pushover_test.go @@ -14,7 +14,6 @@ import ( func TestPushoverNotifier(t *testing.T) { Convey("Pushover notifier tests", t, func() { - Convey("Parsing alert notification from settings", func() { Convey("empty settings should return error", func() { json := `{ }` @@ -65,7 +64,6 @@ func TestPushoverNotifier(t *testing.T) { func TestGenPushoverBody(t *testing.T) { Convey("Pushover body generation tests", t, func() { - Convey("Given common sounds", func() { sirenSound := "siren_sound_tst" successSound := "success_sound_tst" @@ -93,6 +91,5 @@ func TestGenPushoverBody(t *testing.T) { So(strings.Contains(pushoverBody.String(), successSound), ShouldBeTrue) }) }) - }) } diff --git a/pkg/services/alerting/notifiers/sensu.go b/pkg/services/alerting/notifiers/sensu.go index 170ed508b05..4ffa959a97f 100644 --- a/pkg/services/alerting/notifiers/sensu.go +++ b/pkg/services/alerting/notifiers/sensu.go @@ -78,7 +78,6 @@ func init() { }, }, }) - } // NewSensuNotifier is the constructor for the Sensu Notifier. diff --git a/pkg/services/alerting/notifiers/sensu_test.go b/pkg/services/alerting/notifiers/sensu_test.go index 0c73a493ee8..70ef43b73ef 100644 --- a/pkg/services/alerting/notifiers/sensu_test.go +++ b/pkg/services/alerting/notifiers/sensu_test.go @@ -10,7 +10,6 @@ import ( func TestSensuNotifier(t *testing.T) { Convey("Sensu notifier tests", t, func() { - Convey("Parsing alert notification from settings", func() { Convey("empty settings should return error", func() { json := `{ }` diff --git a/pkg/services/alerting/notifiers/slack_test.go b/pkg/services/alerting/notifiers/slack_test.go index a27471cacc5..a4592ebe931 100644 --- a/pkg/services/alerting/notifiers/slack_test.go +++ b/pkg/services/alerting/notifiers/slack_test.go @@ -10,7 +10,6 @@ import ( func TestSlackNotifier(t *testing.T) { Convey("Slack notifier tests", t, func() { - Convey("Parsing alert notification from settings", func() { Convey("empty settings should return error", func() { json := `{ }` diff --git a/pkg/services/alerting/notifiers/teams.go b/pkg/services/alerting/notifiers/teams.go index 3742c855141..e30a10bcbfc 100644 --- a/pkg/services/alerting/notifiers/teams.go +++ b/pkg/services/alerting/notifiers/teams.go @@ -33,7 +33,6 @@ func init() { }, }, }) - } // NewTeamsNotifier is the constructor for Teams notifier. diff --git a/pkg/services/alerting/notifiers/teams_test.go b/pkg/services/alerting/notifiers/teams_test.go index 10ec7edca28..40b56e5b5c4 100644 --- a/pkg/services/alerting/notifiers/teams_test.go +++ b/pkg/services/alerting/notifiers/teams_test.go @@ -10,7 +10,6 @@ import ( func TestTeamsNotifier(t *testing.T) { Convey("Teams notifier tests", t, func() { - Convey("Parsing alert notification from settings", func() { Convey("empty settings should return error", func() { json := `{ }` diff --git a/pkg/services/alerting/notifiers/telegram.go b/pkg/services/alerting/notifiers/telegram.go index fe665889364..ab7dbdc720e 100644 --- a/pkg/services/alerting/notifiers/telegram.go +++ b/pkg/services/alerting/notifiers/telegram.go @@ -68,7 +68,6 @@ func init() { }, }, }) - } // TelegramNotifier is responsible for sending @@ -247,7 +246,6 @@ func generateImageCaption(evalContext *alerting.EvalContext, ruleURL string, met if len(message) > captionLengthLimit { message = message[0:captionLengthLimit] - } if len(ruleURL) > 0 { diff --git a/pkg/services/alerting/notifiers/telegram_test.go b/pkg/services/alerting/notifiers/telegram_test.go index 3559555439e..893081575f6 100644 --- a/pkg/services/alerting/notifiers/telegram_test.go +++ b/pkg/services/alerting/notifiers/telegram_test.go @@ -12,7 +12,6 @@ import ( func TestTelegramNotifier(t *testing.T) { Convey("Telegram notifier tests", t, func() { - Convey("Parsing alert notification from settings", func() { Convey("empty settings should return error", func() { json := `{ }` @@ -68,7 +67,6 @@ func TestTelegramNotifier(t *testing.T) { }) Convey("When generating a message", func() { - Convey("URL should be skipped if it's too long", func() { evalContext := alerting.NewEvalContext(context.Background(), &alerting.Rule{ diff --git a/pkg/services/alerting/notifiers/threema.go b/pkg/services/alerting/notifiers/threema.go index 7cc20f7e722..0be9cd695ff 100644 --- a/pkg/services/alerting/notifiers/threema.go +++ b/pkg/services/alerting/notifiers/threema.go @@ -98,7 +98,6 @@ func init() { }, }, }) - } // ThreemaNotifier is responsible for sending diff --git a/pkg/services/alerting/notifiers/threema_test.go b/pkg/services/alerting/notifiers/threema_test.go index 8ec77db4212..d22e5813505 100644 --- a/pkg/services/alerting/notifiers/threema_test.go +++ b/pkg/services/alerting/notifiers/threema_test.go @@ -11,7 +11,6 @@ import ( func TestThreemaNotifier(t *testing.T) { Convey("Threema notifier tests", t, func() { - Convey("Parsing alert notification from settings", func() { Convey("empty settings should return error", func() { json := `{ }` diff --git a/pkg/services/alerting/notifiers/victorops_test.go b/pkg/services/alerting/notifiers/victorops_test.go index 258d2900a22..00b00f61389 100644 --- a/pkg/services/alerting/notifiers/victorops_test.go +++ b/pkg/services/alerting/notifiers/victorops_test.go @@ -10,7 +10,6 @@ import ( func TestVictoropsNotifier(t *testing.T) { Convey("Victorops notifier tests", t, func() { - Convey("Parsing alert notification from settings", func() { Convey("empty settings should return error", func() { json := `{ }` diff --git a/pkg/services/alerting/notifiers/webhook.go b/pkg/services/alerting/notifiers/webhook.go index 916272a380c..60a2aa90bef 100644 --- a/pkg/services/alerting/notifiers/webhook.go +++ b/pkg/services/alerting/notifiers/webhook.go @@ -74,7 +74,6 @@ func init() { }, }, }) - } // NewWebHookNotifier is the constructor for diff --git a/pkg/services/alerting/notifiers/webhook_test.go b/pkg/services/alerting/notifiers/webhook_test.go index b8c001b6e60..6f311ba39e6 100644 --- a/pkg/services/alerting/notifiers/webhook_test.go +++ b/pkg/services/alerting/notifiers/webhook_test.go @@ -10,7 +10,6 @@ import ( func TestWebhookNotifier(t *testing.T) { Convey("Webhook notifier tests", t, func() { - Convey("Parsing alert notification from settings", func() { Convey("empty settings should return error", func() { json := `{ }` diff --git a/pkg/services/alerting/result_handler.go b/pkg/services/alerting/result_handler.go index 4a5beb36065..1b3af28703d 100644 --- a/pkg/services/alerting/result_handler.go +++ b/pkg/services/alerting/result_handler.go @@ -71,7 +71,6 @@ func (handler *defaultResultHandler) handle(evalContext *EvalContext) error { handler.log.Error("Failed to save state", "error", err) } else { - // StateChanges is used for de duping alert notifications // when two servers are raising. This makes sure that the server // with the last state change always sends a notification. diff --git a/pkg/services/alerting/rule_test.go b/pkg/services/alerting/rule_test.go index 04164000965..1c7875b4849 100644 --- a/pkg/services/alerting/rule_test.go +++ b/pkg/services/alerting/rule_test.go @@ -49,7 +49,6 @@ func TestAlertRuleFrequencyParsing(t *testing.T) { func TestAlertRuleModel(t *testing.T) { sqlstore.InitTestDB(t) Convey("Testing alert rule", t, func() { - RegisterCondition("test", func(model *simplejson.Json, index int) (Condition, error) { return &FakeCondition{}, nil }) diff --git a/pkg/services/alerting/test_rule.go b/pkg/services/alerting/test_rule.go index 79659d6a8ca..8bc2d483884 100644 --- a/pkg/services/alerting/test_rule.go +++ b/pkg/services/alerting/test_rule.go @@ -25,7 +25,6 @@ func init() { } func handleAlertTestCommand(cmd *AlertTestCommand) error { - dash := models.NewDashboardFromJson(cmd.Dashboard) extractor := NewDashAlertExtractor(dash, cmd.OrgID, cmd.User) diff --git a/pkg/services/auth/auth_token.go b/pkg/services/auth/auth_token.go index da6ab6628ff..4a4d0e9e637 100644 --- a/pkg/services/auth/auth_token.go +++ b/pkg/services/auth/auth_token.go @@ -38,7 +38,6 @@ func (s *UserAuthTokenService) Init() error { } func (s *UserAuthTokenService) ActiveTokenCount(ctx context.Context) (int64, error) { - var count int64 var err error err = s.SQLStore.WithDbSession(ctx, func(dbSession *sqlstore.DBSession) error { @@ -119,9 +118,7 @@ func (s *UserAuthTokenService) LookupToken(ctx context.Context, unhashedToken st Get(&model) return err - }) - if err != nil { return nil, err } @@ -373,7 +370,6 @@ func (s *UserAuthTokenService) GetUserToken(ctx context.Context, userId, userTok } func (s *UserAuthTokenService) GetUserTokens(ctx context.Context, userId int64) ([]*models.UserToken, error) { - result := []*models.UserToken{} err := s.SQLStore.WithDbSession(ctx, func(dbSession *sqlstore.DBSession) error { var tokens []*userAuthToken @@ -382,7 +378,6 @@ func (s *UserAuthTokenService) GetUserTokens(ctx context.Context, userId int64) s.createdAfterParam(), s.rotatedAfterParam()). Find(&tokens) - if err != nil { return err } diff --git a/pkg/services/auth/token_cleanup_test.go b/pkg/services/auth/token_cleanup_test.go index 2df42eb724c..bb80d91a955 100644 --- a/pkg/services/auth/token_cleanup_test.go +++ b/pkg/services/auth/token_cleanup_test.go @@ -10,7 +10,6 @@ import ( ) func TestUserAuthTokenCleanup(t *testing.T) { - Convey("Test user auth token cleanup", t, func() { ctx := createTestContext(t) ctx.tokenService.Cfg.LoginMaxInactiveLifetimeDays = 7 diff --git a/pkg/services/cleanup/cleanup_test.go b/pkg/services/cleanup/cleanup_test.go index 259701339dd..448123fa8a7 100644 --- a/pkg/services/cleanup/cleanup_test.go +++ b/pkg/services/cleanup/cleanup_test.go @@ -38,5 +38,4 @@ func TestCleanUpTmpFiles(t *testing.T) { So(service.shouldCleanupTempFile(weekAgo, now), ShouldBeFalse) }) }) - } diff --git a/pkg/services/dashboards/dashboard_service.go b/pkg/services/dashboards/dashboard_service.go index c8342f09306..9a224880f0c 100644 --- a/pkg/services/dashboards/dashboard_service.go +++ b/pkg/services/dashboards/dashboard_service.go @@ -277,7 +277,6 @@ func (dr *dashboardServiceImpl) SaveFolderForProvisionedDashboards(dto *SaveDash } func (dr *dashboardServiceImpl) SaveDashboard(dto *SaveDashboardDTO, allowUiUpdate bool) (*models.Dashboard, error) { - cmd, err := dr.buildSaveDashboardCommand(dto, true, !allowUiUpdate) if err != nil { return nil, err diff --git a/pkg/services/dashboards/dashboard_service_test.go b/pkg/services/dashboards/dashboard_service_test.go index e348abf0eee..1d2ff667741 100644 --- a/pkg/services/dashboards/dashboard_service_test.go +++ b/pkg/services/dashboards/dashboard_service_test.go @@ -224,7 +224,6 @@ func TestDashboardService(t *testing.T) { _, err := service.SaveProvisionedDashboard(dto, nil) So(err, ShouldBeNil) So(dto.Dashboard.Data.Get("refresh").MustString(), ShouldEqual, "5m") - }) }) diff --git a/pkg/services/ldap/ldap.go b/pkg/services/ldap/ldap.go index d9112b0a22a..9cfae9423c0 100644 --- a/pkg/services/ldap/ldap.go +++ b/pkg/services/ldap/ldap.go @@ -532,7 +532,6 @@ func (server *Server) requestMemberOf(entry *ldap.Entry) ([]string, error) { if len(groupSearchResult.Entries) > 0 { for _, group := range groupSearchResult.Entries { - memberOf = append( memberOf, getAttribute(groupIDAttribute, group), diff --git a/pkg/services/ldap/ldap_private_test.go b/pkg/services/ldap/ldap_private_test.go index 0382cdc5987..789d81beb4b 100644 --- a/pkg/services/ldap/ldap_private_test.go +++ b/pkg/services/ldap/ldap_private_test.go @@ -241,5 +241,4 @@ func TestLDAPPrivateMethods(t *testing.T) { So(result, ShouldEqual, "cn=test,dc=grafana,dc=org") }) }) - } diff --git a/pkg/services/login/login_test.go b/pkg/services/login/login_test.go index de800ee4a08..a133dc301ee 100644 --- a/pkg/services/login/login_test.go +++ b/pkg/services/login/login_test.go @@ -17,7 +17,6 @@ func Test_syncOrgRoles_doesNotBreakWhenTryingToRemoveLastOrgAdmin(t *testing.T) bus.ClearBusHandlers() defer bus.ClearBusHandlers() bus.AddHandler("test", func(q *models.GetUserOrgListQuery) error { - q.Result = createUserOrgDTO() return nil @@ -53,7 +52,6 @@ func Test_syncOrgRoles_whenTryingToRemoveLastOrgLogsError(t *testing.T) { bus.ClearBusHandlers() defer bus.ClearBusHandlers() bus.AddHandler("test", func(q *models.GetUserOrgListQuery) error { - q.Result = createUserOrgDTO() return nil diff --git a/pkg/services/multildap/multildap.go b/pkg/services/multildap/multildap.go index 90964ddd7cb..0f4447af729 100644 --- a/pkg/services/multildap/multildap.go +++ b/pkg/services/multildap/multildap.go @@ -70,14 +70,12 @@ func New(configs []*ldap.ServerConfig) IMultiLDAP { // Ping dials each of the LDAP servers and returns their status. If the server is unavailable, it also returns the error. func (multiples *MultiLDAP) Ping() ([]*ServerStatus, error) { - if len(multiples.configs) == 0 { return nil, ErrNoLDAPServers } serverStatuses := []*ServerStatus{} for _, config := range multiples.configs { - status := &ServerStatus{} status.Host = config.Host @@ -104,7 +102,6 @@ func (multiples *MultiLDAP) Ping() ([]*ServerStatus, error) { func (multiples *MultiLDAP) Login(query *models.LoginUserQuery) ( *models.ExternalUserInfo, error, ) { - if len(multiples.configs) == 0 { return nil, ErrNoLDAPServers } @@ -125,12 +122,11 @@ func (multiples *MultiLDAP) Login(query *models.LoginUserQuery) ( defer server.Close() user, err := server.Login(query) + // FIXME if user != nil { return user, nil } - if err != nil { - if isSilentError(err) { logger.Debug( "unable to login with LDAP - skipping server", @@ -155,7 +151,6 @@ func (multiples *MultiLDAP) User(login string) ( ldap.ServerConfig, error, ) { - if len(multiples.configs) == 0 { return nil, ldap.ServerConfig{}, ErrNoLDAPServers } diff --git a/pkg/services/multildap/multildap_test.go b/pkg/services/multildap/multildap_test.go index 1c338c69377..b9660a51bf1 100644 --- a/pkg/services/multildap/multildap_test.go +++ b/pkg/services/multildap/multildap_test.go @@ -469,7 +469,6 @@ type mockLDAP struct { // Login test fn func (mock *mockLDAP) Login(*models.LoginUserQuery) (*models.ExternalUserInfo, error) { - mock.loginCalledTimes = mock.loginCalledTimes + 1 return mock.loginReturn, mock.loginErrReturn } diff --git a/pkg/services/notifications/codes_test.go b/pkg/services/notifications/codes_test.go index bda0e3333f9..d2b1f3a6179 100644 --- a/pkg/services/notifications/codes_test.go +++ b/pkg/services/notifications/codes_test.go @@ -9,7 +9,6 @@ import ( ) func TestEmailCodes(t *testing.T) { - Convey("When generating code", t, func() { setting.EmailCodeValidMinutes = 120 @@ -34,7 +33,5 @@ func TestEmailCodes(t *testing.T) { So(err, ShouldBeNil) So(isValid, ShouldBeFalse) }) - }) - } diff --git a/pkg/services/notifications/notifications_test.go b/pkg/services/notifications/notifications_test.go index c6f7e6304a2..e7680c3943d 100644 --- a/pkg/services/notifications/notifications_test.go +++ b/pkg/services/notifications/notifications_test.go @@ -10,7 +10,6 @@ import ( ) func TestNotifications(t *testing.T) { - Convey("Given the notifications service", t, func() { setting.StaticRootPath = "../../../public/" diff --git a/pkg/services/provisioning/dashboards/config_reader_test.go b/pkg/services/provisioning/dashboards/config_reader_test.go index 160663fe5b7..e1b22c6bd91 100644 --- a/pkg/services/provisioning/dashboards/config_reader_test.go +++ b/pkg/services/provisioning/dashboards/config_reader_test.go @@ -18,7 +18,6 @@ var ( func TestDashboardsAsConfig(t *testing.T) { t.Run("Dashboards as configuration", func(t *testing.T) { - logger := log.New("test-logger") t.Run("default values should be applied", func(t *testing.T) { diff --git a/pkg/services/provisioning/dashboards/file_reader.go b/pkg/services/provisioning/dashboards/file_reader.go index 4d73acb74ca..c0e65f3fe85 100644 --- a/pkg/services/provisioning/dashboards/file_reader.go +++ b/pkg/services/provisioning/dashboards/file_reader.go @@ -65,7 +65,6 @@ func NewDashboardFileReader(cfg *config, log log.Logger) (*FileReader, error) { // pollChanges periodically runs startWalkingDisk based on interval specified in the config. func (fr *FileReader) pollChanges(ctx context.Context) { - ticker := time.NewTicker(time.Duration(int64(time.Second) * fr.Cfg.UpdateIntervalSeconds)) for { select { diff --git a/pkg/services/provisioning/dashboards/file_reader_test.go b/pkg/services/provisioning/dashboards/file_reader_test.go index a9734043439..33fe6a0a683 100644 --- a/pkg/services/provisioning/dashboards/file_reader_test.go +++ b/pkg/services/provisioning/dashboards/file_reader_test.go @@ -96,7 +96,6 @@ func TestDashboardFileReader(t *testing.T) { logger := log.New("test.logger") Convey("Reading dashboards from disk", func() { - cfg := &config{ Name: "Default", Type: "file", @@ -342,7 +341,6 @@ func TestDashboardFileReader(t *testing.T) { So(len(fakeService.provisioned["Default"]), ShouldEqual, 1) So(fakeService.provisioned["Default"][0].ExternalId, ShouldEqual, absPath1) - }) Convey("Missing dashboard should be deleted if DisableDeletion = false", func() { diff --git a/pkg/services/provisioning/notifiers/alert_notifications.go b/pkg/services/provisioning/notifiers/alert_notifications.go index e032d8e80dc..5831077f131 100644 --- a/pkg/services/provisioning/notifiers/alert_notifications.go +++ b/pkg/services/provisioning/notifiers/alert_notifications.go @@ -70,7 +70,6 @@ func (dc *NotificationProvisioner) deleteNotifications(notificationToDelete []*d func (dc *NotificationProvisioner) mergeNotifications(notificationToMerge []*notificationFromConfig) error { for _, notification := range notificationToMerge { - if notification.OrgID == 0 && notification.OrgName != "" { getOrg := &models.GetOrgByNameQuery{Name: notification.OrgName} if err := bus.Dispatch(getOrg); err != nil { diff --git a/pkg/services/provisioning/notifiers/config_reader.go b/pkg/services/provisioning/notifiers/config_reader.go index 338728df9f2..fe6aad52014 100644 --- a/pkg/services/provisioning/notifiers/config_reader.go +++ b/pkg/services/provisioning/notifiers/config_reader.go @@ -140,7 +140,6 @@ func validateRequiredField(notifications []*notificationsAsConfig) error { } func validateNotifications(notifications []*notificationsAsConfig) error { - for i := range notifications { if notifications[i].Notifications == nil { continue diff --git a/pkg/services/provisioning/notifiers/config_reader_test.go b/pkg/services/provisioning/notifiers/config_reader_test.go index e59da75d955..73ff2bf3f9c 100644 --- a/pkg/services/provisioning/notifiers/config_reader_test.go +++ b/pkg/services/provisioning/notifiers/config_reader_test.go @@ -257,7 +257,6 @@ func TestNotificationAsConfig(t *testing.T) { nt := notificationsQuery.Result[0] So(nt.Name, ShouldEqual, "default-notification-create") So(nt.OrgId, ShouldEqual, existingOrg2.Result.Id) - }) Convey("Config doesn't contain required field", func() { diff --git a/pkg/services/provisioning/provisioning.go b/pkg/services/provisioning/provisioning.go index f296b14a02d..5442637bff4 100644 --- a/pkg/services/provisioning/provisioning.go +++ b/pkg/services/provisioning/provisioning.go @@ -89,7 +89,6 @@ func (ps *provisioningServiceImpl) Run(ctx context.Context) error { } for { - // Wait for unlock. This is tied to new dashboardProvisioner to be instantiated before we start polling. ps.mutex.Lock() // Using background here because otherwise if root context was canceled the select later on would diff --git a/pkg/services/provisioning/provisioning_test.go b/pkg/services/provisioning/provisioning_test.go index f1977ee8d7a..e88c4861f54 100644 --- a/pkg/services/provisioning/provisioning_test.go +++ b/pkg/services/provisioning/provisioning_test.go @@ -37,7 +37,6 @@ func TestProvisioningServiceImpl(t *testing.T) { assert.False(t, serviceTest.serviceRunning, "Service should not be running") assert.Equal(t, context.Canceled, serviceTest.serviceError, "Service should have returned canceled error") - }) t.Run("Failed reloading does not stop polling with old provisioned", func(t *testing.T) { diff --git a/pkg/services/provisioning/values/values_test.go b/pkg/services/provisioning/values/values_test.go index bc5dd9f7809..0da5174c5ea 100644 --- a/pkg/services/provisioning/values/values_test.go +++ b/pkg/services/provisioning/values/values_test.go @@ -124,7 +124,6 @@ func TestValues(t *testing.T) { }) Convey("JSONValue", func() { - type Data struct { Val JSONValue `yaml:"val"` } @@ -237,7 +236,6 @@ func TestValues(t *testing.T) { "three": "$STRING", "four": "true", }) - }) }) diff --git a/pkg/services/quota/quota.go b/pkg/services/quota/quota.go index a661a6985c0..452b55029f8 100644 --- a/pkg/services/quota/quota.go +++ b/pkg/services/quota/quota.go @@ -47,7 +47,6 @@ func (qs *QuotaService) QuotaReached(c *models.ReqContext, target string) (bool, return true, nil } if target == "session" { - usedSessions, err := qs.AuthTokenService.ActiveTokenCount(c.Req.Context()) if err != nil { return false, err diff --git a/pkg/services/rendering/rendering.go b/pkg/services/rendering/rendering.go index 31693f10b04..d42a45ebe85 100644 --- a/pkg/services/rendering/rendering.go +++ b/pkg/services/rendering/rendering.go @@ -218,7 +218,6 @@ func (rs *RenderingService) getURL(path string) string { // &render=1 signals to the legacy redirect layer to return fmt.Sprintf("%s%s&render=1", rs.Cfg.RendererCallbackUrl, path) - } protocol := setting.Protocol diff --git a/pkg/services/sqlstore/annotation.go b/pkg/services/sqlstore/annotation.go index 22ae64e63c6..5c38b7b2be8 100644 --- a/pkg/services/sqlstore/annotation.go +++ b/pkg/services/sqlstore/annotation.go @@ -217,7 +217,6 @@ func (r *SqlAnnotationRepo) Find(query *annotations.ItemQuery) ([]*annotations.I } else { sql.WriteString(fmt.Sprintf(" AND (%s) = %d ", tagsSubQuery, len(tags))) } - } } diff --git a/pkg/services/sqlstore/annotation_test.go b/pkg/services/sqlstore/annotation_test.go index 85f67c7eaae..927731b60d6 100644 --- a/pkg/services/sqlstore/annotation_test.go +++ b/pkg/services/sqlstore/annotation_test.go @@ -279,7 +279,6 @@ func TestAnnotations(t *testing.T) { So(len(items), ShouldEqual, 0) }) }) - }) }) } diff --git a/pkg/services/sqlstore/apikey_test.go b/pkg/services/sqlstore/apikey_test.go index 0461c5b63a4..c1b96995006 100644 --- a/pkg/services/sqlstore/apikey_test.go +++ b/pkg/services/sqlstore/apikey_test.go @@ -27,7 +27,6 @@ func TestApiKeyDataAccess(t *testing.T) { assert.Nil(t, err) assert.NotNil(t, query.Result) }) - }) t.Run("Add non expiring key", func(t *testing.T) { diff --git a/pkg/services/sqlstore/dashboard_acl.go b/pkg/services/sqlstore/dashboard_acl.go index 55b70ef926b..dac29230ee0 100644 --- a/pkg/services/sqlstore/dashboard_acl.go +++ b/pkg/services/sqlstore/dashboard_acl.go @@ -73,9 +73,7 @@ func GetDashboardAclInfoList(query *models.GetDashboardAclInfoListQuery) error { WHERE da.dashboard_id = -1` query.Result = make([]*models.DashboardAclInfoDTO, 0) err = x.SQL(sql).Find(&query.Result) - } else { - rawSQL := ` -- get permissions for the dashboard and its parent folder SELECT diff --git a/pkg/services/sqlstore/dashboard_service_integration_test.go b/pkg/services/sqlstore/dashboard_service_integration_test.go index 582a4a0c5f1..0d5d64f16ab 100644 --- a/pkg/services/sqlstore/dashboard_service_integration_test.go +++ b/pkg/services/sqlstore/dashboard_service_integration_test.go @@ -129,7 +129,6 @@ func TestIntegratedDashboardService(t *testing.T) { // Given user has no permission to save permissionScenario("Given user has no permission to save", false, func(sc *dashboardPermissionScenarioContext) { - Convey("When creating a new dashboard in the General folder", func() { cmd := models.SaveDashboardCommand{ OrgId: testOrgId, @@ -370,7 +369,6 @@ func TestIntegratedDashboardService(t *testing.T) { // Given user has permission to save permissionScenario("Given user has permission to save", true, func(sc *dashboardPermissionScenarioContext) { - Convey("and overwrite flag is set to false", func() { shouldOverwrite := false diff --git a/pkg/services/sqlstore/dashboard_snapshot.go b/pkg/services/sqlstore/dashboard_snapshot.go index 10c3536b9ea..97fe4d7ca0c 100644 --- a/pkg/services/sqlstore/dashboard_snapshot.go +++ b/pkg/services/sqlstore/dashboard_snapshot.go @@ -39,7 +39,6 @@ func DeleteExpiredSnapshots(cmd *models.DeleteExpiredSnapshotsCommand) error { func CreateDashboardSnapshot(cmd *models.CreateDashboardSnapshotCommand) error { return inTransaction(func(sess *DBSession) error { - // never var expires = time.Now().Add(time.Hour * 24 * 365 * 50) if cmd.Expires > 0 { diff --git a/pkg/services/sqlstore/dashboard_snapshot_test.go b/pkg/services/sqlstore/dashboard_snapshot_test.go index f7d9161b5d6..f393f6fbdd5 100644 --- a/pkg/services/sqlstore/dashboard_snapshot_test.go +++ b/pkg/services/sqlstore/dashboard_snapshot_test.go @@ -12,7 +12,6 @@ import ( ) func TestDashboardSnapshotDBAccess(t *testing.T) { - Convey("Testing DashboardSnapshot data access", t, func() { InitTestDB(t) diff --git a/pkg/services/sqlstore/datasource.go b/pkg/services/sqlstore/datasource.go index 3ecdad32478..0f598b565a1 100644 --- a/pkg/services/sqlstore/datasource.go +++ b/pkg/services/sqlstore/datasource.go @@ -205,7 +205,6 @@ func UpdateDataSource(cmd *models.UpdateDataSourceCommand) error { // updates to datasources using the datasource.yaml file without knowing exactly what version // a datasource have in the db. updateSession = sess.Where("id=? and org_id=? and version < ?", ds.Id, ds.OrgId, ds.Version) - } else { updateSession = sess.Where("id=? and org_id=?", ds.Id, ds.OrgId) } diff --git a/pkg/services/sqlstore/migrations/alert_mig.go b/pkg/services/sqlstore/migrations/alert_mig.go index 97aa3cdf60d..7e9c8cce574 100644 --- a/pkg/services/sqlstore/migrations/alert_mig.go +++ b/pkg/services/sqlstore/migrations/alert_mig.go @@ -5,7 +5,6 @@ import ( ) func addAlertMigrations(mg *Migrator) { - alertV1 := Table{ Name: "alert", Columns: []*Column{ diff --git a/pkg/services/sqlstore/migrations/annotation_mig.go b/pkg/services/sqlstore/migrations/annotation_mig.go index 0ed75e6e64c..7ef0b7ee556 100644 --- a/pkg/services/sqlstore/migrations/annotation_mig.go +++ b/pkg/services/sqlstore/migrations/annotation_mig.go @@ -6,7 +6,6 @@ import ( ) func addAnnotationMig(mg *Migrator) { - table := Table{ Name: "annotation", Columns: []*Column{ diff --git a/pkg/services/sqlstore/migrations/dashboard_mig.go b/pkg/services/sqlstore/migrations/dashboard_mig.go index 9783958c7a1..6af020770ab 100644 --- a/pkg/services/sqlstore/migrations/dashboard_mig.go +++ b/pkg/services/sqlstore/migrations/dashboard_mig.go @@ -219,5 +219,4 @@ func addDashboardMigration(mg *Migrator) { Cols: []string{"title"}, Type: IndexType, })) - } diff --git a/pkg/services/sqlstore/migrations/plugin_setting.go b/pkg/services/sqlstore/migrations/plugin_setting.go index 66a984b56d4..f1eb3723871 100644 --- a/pkg/services/sqlstore/migrations/plugin_setting.go +++ b/pkg/services/sqlstore/migrations/plugin_setting.go @@ -3,7 +3,6 @@ package migrations import . "github.com/grafana/grafana/pkg/services/sqlstore/migrator" func addAppSettingsMigration(mg *Migrator) { - pluginSettingTable := Table{ Name: "plugin_setting", Columns: []*Column{ diff --git a/pkg/services/sqlstore/migrations/preferences_mig.go b/pkg/services/sqlstore/migrations/preferences_mig.go index d8134f11f79..de57b7f33fe 100644 --- a/pkg/services/sqlstore/migrations/preferences_mig.go +++ b/pkg/services/sqlstore/migrations/preferences_mig.go @@ -3,7 +3,6 @@ package migrations import . "github.com/grafana/grafana/pkg/services/sqlstore/migrator" func addPreferencesMigrations(mg *Migrator) { - mg.AddMigration("drop preferences table v2", NewDropTableMigration("preferences")) preferencesV2 := Table{ diff --git a/pkg/services/sqlstore/migrations/quota_mig.go b/pkg/services/sqlstore/migrations/quota_mig.go index 34f0da662a9..08e124e4d62 100644 --- a/pkg/services/sqlstore/migrations/quota_mig.go +++ b/pkg/services/sqlstore/migrations/quota_mig.go @@ -5,7 +5,6 @@ import ( ) func addQuotaMigration(mg *Migrator) { - var quotaV1 = Table{ Name: "quota", Columns: []*Column{ diff --git a/pkg/services/sqlstore/migrations/tag_mig.go b/pkg/services/sqlstore/migrations/tag_mig.go index 0303ddd6409..48da3a04034 100644 --- a/pkg/services/sqlstore/migrations/tag_mig.go +++ b/pkg/services/sqlstore/migrations/tag_mig.go @@ -3,7 +3,6 @@ package migrations import . "github.com/grafana/grafana/pkg/services/sqlstore/migrator" func addTagMigration(mg *Migrator) { - tagTable := Table{ Name: "tag", Columns: []*Column{ diff --git a/pkg/services/sqlstore/org.go b/pkg/services/sqlstore/org.go index 4f46d10077e..3362060cf6f 100644 --- a/pkg/services/sqlstore/org.go +++ b/pkg/services/sqlstore/org.go @@ -91,7 +91,6 @@ func isOrgNameTaken(name string, existingId int64, sess *DBSession) (bool, error func CreateOrg(cmd *models.CreateOrgCommand) error { return inTransaction(func(sess *DBSession) error { - if isNameTaken, err := isOrgNameTaken(cmd.Name, 0, sess); err != nil { return err } else if isNameTaken { @@ -131,7 +130,6 @@ func CreateOrg(cmd *models.CreateOrgCommand) error { func UpdateOrg(cmd *models.UpdateOrgCommand) error { return inTransaction(func(sess *DBSession) error { - if isNameTaken, err := isOrgNameTaken(cmd.Name, cmd.OrgId, sess); err != nil { return err } else if isNameTaken { diff --git a/pkg/services/sqlstore/org_test.go b/pkg/services/sqlstore/org_test.go index 961e1beca46..c5a2e0086aa 100644 --- a/pkg/services/sqlstore/org_test.go +++ b/pkg/services/sqlstore/org_test.go @@ -114,7 +114,6 @@ func TestAccountDataAccess(t *testing.T) { So(err, ShouldBeNil) So(orgUsersQuery.Result[1].Role, ShouldEqual, models.ROLE_ADMIN) - }) Convey("Can get logged in user projection", func() { @@ -282,7 +281,6 @@ func TestAccountDataAccess(t *testing.T) { So(permQuery.Result[0].OrgId, ShouldEqual, ac3.OrgId) So(permQuery.Result[0].UserId, ShouldEqual, ac3.Id) }) - }) }) }) diff --git a/pkg/services/sqlstore/playlist_test.go b/pkg/services/sqlstore/playlist_test.go index dbf92a3cca3..a599c76a5d4 100644 --- a/pkg/services/sqlstore/playlist_test.go +++ b/pkg/services/sqlstore/playlist_test.go @@ -9,7 +9,6 @@ import ( ) func TestPlaylistDataAccess(t *testing.T) { - Convey("Testing Playlist data access", t, func() { InitTestDB(t) diff --git a/pkg/services/sqlstore/plugin_setting.go b/pkg/services/sqlstore/plugin_setting.go index dd746cf5d86..a5ca6a7a0c9 100644 --- a/pkg/services/sqlstore/plugin_setting.go +++ b/pkg/services/sqlstore/plugin_setting.go @@ -107,9 +107,7 @@ func UpdatePluginSetting(cmd *models.UpdatePluginSettingCmd) error { func UpdatePluginSettingVersion(cmd *models.UpdatePluginSettingVersionCmd) error { return inTransaction(func(sess *DBSession) error { - _, err := sess.Exec("UPDATE plugin_setting SET plugin_version=? WHERE org_id=? AND plugin_id=?", cmd.PluginVersion, cmd.OrgId, cmd.PluginId) return err - }) } diff --git a/pkg/services/sqlstore/preferences.go b/pkg/services/sqlstore/preferences.go index eaf030a5ca7..24488029d52 100644 --- a/pkg/services/sqlstore/preferences.go +++ b/pkg/services/sqlstore/preferences.go @@ -80,7 +80,6 @@ func GetPreferences(query *models.GetPreferencesQuery) error { func SavePreferences(cmd *models.SavePreferencesCommand) error { return inTransaction(func(sess *DBSession) error { - var prefs models.Preferences exists, err := sess.Where("org_id=? AND user_id=? AND team_id=?", cmd.OrgId, cmd.UserId, cmd.TeamId).Get(&prefs) if err != nil { diff --git a/pkg/services/sqlstore/quota_test.go b/pkg/services/sqlstore/quota_test.go index f59e53e9455..86d6bd6fc3b 100644 --- a/pkg/services/sqlstore/quota_test.go +++ b/pkg/services/sqlstore/quota_test.go @@ -10,7 +10,6 @@ import ( ) func TestQuotaCommandsAndQueries(t *testing.T) { - Convey("Testing Quota commands & queries", t, func() { InitTestDB(t) userId := int64(1) @@ -101,7 +100,6 @@ func TestQuotaCommandsAndQueries(t *testing.T) { } So(res.Limit, ShouldEqual, limit) So(res.Used, ShouldEqual, used) - } }) }) diff --git a/pkg/services/sqlstore/sql_test_data.go b/pkg/services/sqlstore/sql_test_data.go index 4720a09dded..2e52b272b67 100644 --- a/pkg/services/sqlstore/sql_test_data.go +++ b/pkg/services/sqlstore/sql_test_data.go @@ -13,7 +13,6 @@ func init() { } func sqlRandomWalk(m1 string, m2 string, intWalker int64, floatWalker float64, sess *DBSession) error { - timeWalker := time.Now().UTC().Add(time.Hour * -200) now := time.Now().UTC() step := time.Minute diff --git a/pkg/services/sqlstore/sqlbuilder.go b/pkg/services/sqlstore/sqlbuilder.go index 1411bac890f..73d94fd16e4 100644 --- a/pkg/services/sqlstore/sqlbuilder.go +++ b/pkg/services/sqlstore/sqlbuilder.go @@ -29,7 +29,6 @@ func (sb *SqlBuilder) AddParams(params ...interface{}) { } func (sb *SqlBuilder) writeDashboardPermissionFilter(user *models.SignedInUser, permission models.PermissionType) { - if user.OrgRole == models.ROLE_ADMIN { return } diff --git a/pkg/services/sqlstore/star.go b/pkg/services/sqlstore/star.go index 9df5cc869f0..9db7bc7a5a6 100644 --- a/pkg/services/sqlstore/star.go +++ b/pkg/services/sqlstore/star.go @@ -35,7 +35,6 @@ func StarDashboard(cmd *models.StarDashboardCommand) error { } return inTransaction(func(sess *DBSession) error { - entity := models.Star{ UserId: cmd.UserId, DashboardId: cmd.DashboardId, diff --git a/pkg/services/sqlstore/stars_test.go b/pkg/services/sqlstore/stars_test.go index a74e5c7f2b2..3a226707e9f 100644 --- a/pkg/services/sqlstore/stars_test.go +++ b/pkg/services/sqlstore/stars_test.go @@ -8,7 +8,6 @@ import ( ) func TestUserStarsDataAccess(t *testing.T) { - Convey("Testing User Stars Data Access", t, func() { InitTestDB(t) diff --git a/pkg/services/sqlstore/team.go b/pkg/services/sqlstore/team.go index d411a6a11d6..085ef6986ec 100644 --- a/pkg/services/sqlstore/team.go +++ b/pkg/services/sqlstore/team.go @@ -48,7 +48,6 @@ func getTeamSelectSqlBase() string { func CreateTeam(cmd *models.CreateTeamCommand) error { return inTransaction(func(sess *DBSession) error { - if isNameTaken, err := isTeamNameTaken(cmd.OrgId, cmd.Name, 0, sess); err != nil { return err } else if isNameTaken { @@ -73,7 +72,6 @@ func CreateTeam(cmd *models.CreateTeamCommand) error { func UpdateTeam(cmd *models.UpdateTeamCommand) error { return inTransaction(func(sess *DBSession) error { - if isNameTaken, err := isTeamNameTaken(cmd.OrgId, cmd.Name, cmd.Id, sess); err != nil { return err } else if isNameTaken { diff --git a/pkg/services/sqlstore/team_test.go b/pkg/services/sqlstore/team_test.go index 51c8a651c9e..acbd314cf48 100644 --- a/pkg/services/sqlstore/team_test.go +++ b/pkg/services/sqlstore/team_test.go @@ -11,7 +11,6 @@ import ( ) func TestTeamCommandsAndQueries(t *testing.T) { - Convey("Testing Team commands & queries", t, func() { InitTestDB(t) diff --git a/pkg/services/sqlstore/temp_user.go b/pkg/services/sqlstore/temp_user.go index 6d7a4c73d36..42cadbf1cfc 100644 --- a/pkg/services/sqlstore/temp_user.go +++ b/pkg/services/sqlstore/temp_user.go @@ -25,7 +25,6 @@ func UpdateTempUserStatus(cmd *models.UpdateTempUserStatusCommand) error { func CreateTempUser(cmd *models.CreateTempUserCommand) error { return inTransaction(func(sess *DBSession) error { - // create user user := &models.TempUser{ Email: cmd.Email, diff --git a/pkg/services/sqlstore/temp_user_test.go b/pkg/services/sqlstore/temp_user_test.go index 83ff722ff30..956c45e6e4e 100644 --- a/pkg/services/sqlstore/temp_user_test.go +++ b/pkg/services/sqlstore/temp_user_test.go @@ -8,7 +8,6 @@ import ( ) func TestTempUserCommandsAndQueries(t *testing.T) { - Convey("Testing Temp User commands & queries", t, func() { InitTestDB(t) diff --git a/pkg/services/sqlstore/user.go b/pkg/services/sqlstore/user.go index 4cc6f83fe62..a02641b8bbf 100644 --- a/pkg/services/sqlstore/user.go +++ b/pkg/services/sqlstore/user.go @@ -213,7 +213,6 @@ func GetUserByEmail(query *models.GetUserByEmailQuery) error { func UpdateUser(cmd *models.UpdateUserCommand) error { return inTransaction(func(sess *DBSession) error { - user := models.User{ Name: cmd.Name, Email: cmd.Email, @@ -240,7 +239,6 @@ func UpdateUser(cmd *models.UpdateUserCommand) error { func ChangeUserPassword(cmd *models.ChangeUserPasswordCommand) error { return inTransaction(func(sess *DBSession) error { - user := models.User{ Password: cmd.NewPassword, Updated: time.Now(), @@ -614,7 +612,6 @@ func UpdateUserPermissions(cmd *models.UpdateUserPermissionsCommand) error { func SetUserHelpFlag(cmd *models.SetUserHelpFlagCommand) error { return inTransaction(func(sess *DBSession) error { - user := models.User{ Id: cmd.UserId, HelpFlags1: cmd.HelpFlags1, diff --git a/pkg/services/sqlstore/user_auth_test.go b/pkg/services/sqlstore/user_auth_test.go index cf897a22a59..2b6621a2035 100644 --- a/pkg/services/sqlstore/user_auth_test.go +++ b/pkg/services/sqlstore/user_auth_test.go @@ -167,7 +167,6 @@ func TestUserAuth(t *testing.T) { So(getAuthQuery.Result.OAuthAccessToken, ShouldEqual, token.AccessToken) So(getAuthQuery.Result.OAuthRefreshToken, ShouldEqual, token.RefreshToken) So(getAuthQuery.Result.OAuthTokenType, ShouldEqual, token.TokenType) - }) Convey("Always return the most recently used auth_module", func() { diff --git a/pkg/services/sqlstore/user_test.go b/pkg/services/sqlstore/user_test.go index 1d9c9164020..43427014be8 100644 --- a/pkg/services/sqlstore/user_test.go +++ b/pkg/services/sqlstore/user_test.go @@ -14,7 +14,6 @@ import ( ) func TestUserDataAccess(t *testing.T) { - Convey("Testing DB", t, func() { ss := InitTestDB(t) diff --git a/pkg/setting/setting_quota.go b/pkg/setting/setting_quota.go index c3a509219db..2cef170648c 100644 --- a/pkg/setting/setting_quota.go +++ b/pkg/setting/setting_quota.go @@ -90,5 +90,4 @@ func (cfg *Cfg) readQuotaSettings() { ApiKey: quota.Key("global_api_key").MustInt64(-1), Session: quota.Key("global_session").MustInt64(-1), } - } diff --git a/pkg/setting/setting_test.go b/pkg/setting/setting_test.go index 2a339ee9766..a33a8032250 100644 --- a/pkg/setting/setting_test.go +++ b/pkg/setting/setting_test.go @@ -21,7 +21,6 @@ const ( ) func TestLoadingSettings(t *testing.T) { - Convey("Testing loading settings from ini file", t, func() { skipStaticRootValidation = true @@ -276,7 +275,6 @@ func TestLoadingSettings(t *testing.T) { }) Convey("Test reading string values from .ini file", t, func() { - iniFile, err := ini.Load(path.Join(HomePath, "pkg/setting/testdata/invalid.ini")) So(err, ShouldBeNil) @@ -297,7 +295,6 @@ func TestLoadingSettings(t *testing.T) { So(err.Error(), ShouldEqual, "Invalid value for key 'root_url' in configuration file") So(value, ShouldEqual, "") }) - }) } diff --git a/pkg/tsdb/azuremonitor/applicationinsights-datasource.go b/pkg/tsdb/azuremonitor/applicationinsights-datasource.go index f88e6e45f05..ed533cc0338 100644 --- a/pkg/tsdb/azuremonitor/applicationinsights-datasource.go +++ b/pkg/tsdb/azuremonitor/applicationinsights-datasource.go @@ -130,7 +130,6 @@ func (e *ApplicationInsightsDatasource) buildQueries(queries []*tsdb.Query, time aggregation: insightsJSONModel.Aggregation, dimensions: insightsJSONModel.Dimensions, }) - } return applicationInsightsQueries, nil diff --git a/pkg/tsdb/azuremonitor/applicationinsights-datasource_test.go b/pkg/tsdb/azuremonitor/applicationinsights-datasource_test.go index dd2ab3df8ea..65a30f2fe10 100644 --- a/pkg/tsdb/azuremonitor/applicationinsights-datasource_test.go +++ b/pkg/tsdb/azuremonitor/applicationinsights-datasource_test.go @@ -121,7 +121,6 @@ func TestApplicationInsightsDatasource(t *testing.T) { So(queries[0].Target, ShouldEqual, "aggregation=Average&filter=blob+eq+%27%2A%27&interval=PT1M&segment=blob×pan=2018-03-15T13%3A00%3A00Z%2F2018-03-15T13%3A34%3A00Z") So(queries[0].Params["filter"][0], ShouldEqual, "blob eq '*'") - }) Convey("and has a dimension filter set to None", func() { @@ -208,7 +207,6 @@ func TestAppInsightsPluginRoutes(t *testing.T) { } }) } - } func TestInsightsDimensionsUnmarshalJSON(t *testing.T) { diff --git a/pkg/tsdb/azuremonitor/applicationinsights-metrics.go b/pkg/tsdb/azuremonitor/applicationinsights-metrics.go index cf267eb2b6e..09c3bb05108 100644 --- a/pkg/tsdb/azuremonitor/applicationinsights-metrics.go +++ b/pkg/tsdb/azuremonitor/applicationinsights-metrics.go @@ -124,7 +124,6 @@ func valFromLeafAP(ap map[string]interface{}, metric, agg string) (*float64, err metMap, ok := met.(map[string]interface{}) if !ok { return nil, fmt.Errorf("unexpected type for additional properties not found in leaf segment, want map[string]interface{}, but got %T", met) - } metVal, ok := metMap[agg] if !ok { diff --git a/pkg/tsdb/azuremonitor/applicationinsights-metrics_test.go b/pkg/tsdb/azuremonitor/applicationinsights-metrics_test.go index 53a3debce22..f1b52cbd062 100644 --- a/pkg/tsdb/azuremonitor/applicationinsights-metrics_test.go +++ b/pkg/tsdb/azuremonitor/applicationinsights-metrics_test.go @@ -113,10 +113,8 @@ func TestInsightsMetricsResultToFrame(t *testing.T) { if diff := cmp.Diff(tt.expectedFrame(), frame, data.FrameTestCompareOptions()...); diff != "" { t.Errorf("Result mismatch (-want +got):\n%s", diff) } - }) } - } func loadInsightsMetricsResponse(name string) (MetricsResult, error) { diff --git a/pkg/tsdb/azuremonitor/azure-log-analytics-datasource_test.go b/pkg/tsdb/azuremonitor/azure-log-analytics-datasource_test.go index 879a80c0d8a..13dcee69517 100644 --- a/pkg/tsdb/azuremonitor/azure-log-analytics-datasource_test.go +++ b/pkg/tsdb/azuremonitor/azure-log-analytics-datasource_test.go @@ -154,5 +154,4 @@ func TestPluginRoutes(t *testing.T) { } }) } - } diff --git a/pkg/tsdb/azuremonitor/azure-log-analytics-table-frame_test.go b/pkg/tsdb/azuremonitor/azure-log-analytics-table-frame_test.go index 28dc7cc10de..2c8858565cf 100644 --- a/pkg/tsdb/azuremonitor/azure-log-analytics-table-frame_test.go +++ b/pkg/tsdb/azuremonitor/azure-log-analytics-table-frame_test.go @@ -131,10 +131,8 @@ func TestLogTableToFrame(t *testing.T) { if diff := cmp.Diff(tt.expectedFrame(), frame, data.FrameTestCompareOptions()...); diff != "" { t.Errorf("Result mismatch (-want +got):\n%s", diff) } - }) } - } func loadLogAnalyticsTestFileWithNumber(name string) (AzureLogAnalyticsResponse, error) { diff --git a/pkg/tsdb/azuremonitor/insights-analytics-datasource.go b/pkg/tsdb/azuremonitor/insights-analytics-datasource.go index 238ae9b969d..e41f5a5c788 100644 --- a/pkg/tsdb/azuremonitor/insights-analytics-datasource.go +++ b/pkg/tsdb/azuremonitor/insights-analytics-datasource.go @@ -89,7 +89,6 @@ func (e *InsightsAnalyticsDatasource) buildQueries(queries []*tsdb.Query, timeRa qm.Target = qm.Params.Encode() iaQueries = append(iaQueries, &qm) - } return iaQueries, nil diff --git a/pkg/tsdb/azuremonitor/types.go b/pkg/tsdb/azuremonitor/types.go index b684b9326e4..71371ea1ab5 100644 --- a/pkg/tsdb/azuremonitor/types.go +++ b/pkg/tsdb/azuremonitor/types.go @@ -174,7 +174,6 @@ func (s *InsightsDimensions) UnmarshalJSON(data []byte) error { err := json.Unmarshal(data, &str) if err != nil { return fmt.Errorf("could not parse %q as string or array: %w", string(data), err) - } if str != "" { *s = InsightsDimensions{str} diff --git a/pkg/tsdb/azuremonitor/url-builder.go b/pkg/tsdb/azuremonitor/url-builder.go index 445f815e0cd..09dd4277bb7 100644 --- a/pkg/tsdb/azuremonitor/url-builder.go +++ b/pkg/tsdb/azuremonitor/url-builder.go @@ -17,7 +17,6 @@ type urlBuilder struct { // Build checks the metric definition property to see which form of the url // should be returned func (ub *urlBuilder) Build() string { - subscription := ub.Subscription if ub.Subscription == "" { diff --git a/pkg/tsdb/azuremonitor/url-builder_test.go b/pkg/tsdb/azuremonitor/url-builder_test.go index 2af784a7554..68a29f96e3a 100644 --- a/pkg/tsdb/azuremonitor/url-builder_test.go +++ b/pkg/tsdb/azuremonitor/url-builder_test.go @@ -8,7 +8,6 @@ import ( func TestURLBuilder(t *testing.T) { Convey("AzureMonitor URL Builder", t, func() { - Convey("when metric definition is in the short form", func() { ub := &urlBuilder{ DefaultSubscription: "default-sub", diff --git a/pkg/tsdb/cloudmonitoring/cloudmonitoring_test.go b/pkg/tsdb/cloudmonitoring/cloudmonitoring_test.go index b5023a7cff9..ccf696bd8eb 100644 --- a/pkg/tsdb/cloudmonitoring/cloudmonitoring_test.go +++ b/pkg/tsdb/cloudmonitoring/cloudmonitoring_test.go @@ -459,7 +459,6 @@ func TestCloudMonitoring(t *testing.T) { verifyDeepLink(dl, expectedTimeSelection, expectedTimeSeriesFilter) }) }) - }) Convey("Parse queries from frontend and build Google Cloud Monitoring API queries", func() { @@ -675,7 +674,6 @@ func TestCloudMonitoring(t *testing.T) { res := &tsdb.QueryResult{Meta: simplejson.New(), RefId: "A"} Convey("and the alias pattern is for metric type, a metric label and a resource label", func() { - query := &cloudMonitoringQuery{AliasBy: "{{metric.type}} - {{metric.label.instance_name}} - {{resource.label.zone}}", GroupBys: []string{"metric.label.instance_name", "resource.label.zone"}} err = executor.parseResponse(res, data, query) So(err, ShouldBeNil) @@ -689,7 +687,6 @@ func TestCloudMonitoring(t *testing.T) { }) Convey("and the alias pattern is for metric name", func() { - query := &cloudMonitoringQuery{AliasBy: "metric {{metric.name}} service {{metric.service}}", GroupBys: []string{"metric.label.instance_name", "resource.label.zone"}} err = executor.parseResponse(res, data, query) So(err, ShouldBeNil) diff --git a/pkg/tsdb/cloudwatch/cloudwatch_query_test.go b/pkg/tsdb/cloudwatch/cloudwatch_query_test.go index e1f6105d873..17a3ee4f57d 100644 --- a/pkg/tsdb/cloudwatch/cloudwatch_query_test.go +++ b/pkg/tsdb/cloudwatch/cloudwatch_query_test.go @@ -142,7 +142,6 @@ func TestCloudWatchQuery(t *testing.T) { Convey("it is not metric stat", func() { So(query.isMetricStat(), ShouldBeFalse) }) - }) Convey("and match exact is true", func() { @@ -158,7 +157,6 @@ func TestCloudWatchQuery(t *testing.T) { Convey("it is a metric stat", func() { So(query.isMetricStat(), ShouldBeTrue) }) - }) }) diff --git a/pkg/tsdb/cloudwatch/log_actions_test.go b/pkg/tsdb/cloudwatch/log_actions_test.go index 929327d0aee..aae7363026c 100644 --- a/pkg/tsdb/cloudwatch/log_actions_test.go +++ b/pkg/tsdb/cloudwatch/log_actions_test.go @@ -114,7 +114,6 @@ func TestExecuteStartQuery(t *testing.T) { assert.Equal(t, expectedResponse, response) assert.Equal(t, fmt.Errorf("invalid time range: start time must be before end time"), err) - } func TestHandleStartQuery(t *testing.T) { diff --git a/pkg/tsdb/cloudwatch/metric_data_query_builder_test.go b/pkg/tsdb/cloudwatch/metric_data_query_builder_test.go index 1b3a5f0096a..f81757e9ea4 100644 --- a/pkg/tsdb/cloudwatch/metric_data_query_builder_test.go +++ b/pkg/tsdb/cloudwatch/metric_data_query_builder_test.go @@ -28,7 +28,6 @@ func TestMetricDataQueryBuilder(t *testing.T) { }) Convey("and query has three dimension values for two given dimension keys", func() { - query := &cloudWatchQuery{ Namespace: "AWS/EC2", MetricName: "CPUUtilization", @@ -178,7 +177,6 @@ func TestMetricDataQueryBuilder(t *testing.T) { res := buildSearchExpression(query, "Average") So(res, ShouldEqual, `REMOVE_EMPTY(SEARCH('Namespace="AWS/EC2" MetricName="CPUUtilization" "LoadBalancer"=("lb1" OR "lb2" OR "lb3") "InstanceId"', 'Average', 300))`) }) - }) }) @@ -198,7 +196,6 @@ func TestMetricDataQueryBuilder(t *testing.T) { Convey("it should escape double quotes", func() { So(res, ShouldContainSubstring, `lb4\"\"`) }) - }) }) } diff --git a/pkg/tsdb/cloudwatch/metric_find_query_test.go b/pkg/tsdb/cloudwatch/metric_find_query_test.go index 571851c386c..ebcf05b8a01 100644 --- a/pkg/tsdb/cloudwatch/metric_find_query_test.go +++ b/pkg/tsdb/cloudwatch/metric_find_query_test.go @@ -43,7 +43,6 @@ func (m mockedRGTA) GetResourcesPages(in *resourcegroupstaggingapi.GetResourcesI } func TestCloudWatchMetrics(t *testing.T) { - t.Run("When calling getMetricsForCustomMetrics", func(t *testing.T) { dsInfo := &DatasourceInfo{ Region: "us-east-1", diff --git a/pkg/tsdb/cloudwatch/query_transformer_test.go b/pkg/tsdb/cloudwatch/query_transformer_test.go index 5e05e59b001..9ad7d1ca861 100644 --- a/pkg/tsdb/cloudwatch/query_transformer_test.go +++ b/pkg/tsdb/cloudwatch/query_transformer_test.go @@ -10,7 +10,6 @@ import ( func TestQueryTransformer(t *testing.T) { Convey("TestQueryTransformer", t, func() { Convey("when transforming queries", func() { - executor := &CloudWatchExecutor{} Convey("one cloudwatchQuery is generated when its request query has one stat", func() { requestQueries := []*requestQuery{ diff --git a/pkg/tsdb/cloudwatch/request_parser_test.go b/pkg/tsdb/cloudwatch/request_parser_test.go index 3c79cea26fd..75b64e67969 100644 --- a/pkg/tsdb/cloudwatch/request_parser_test.go +++ b/pkg/tsdb/cloudwatch/request_parser_test.go @@ -211,7 +211,6 @@ func TestRequestParser(t *testing.T) { So(res.Period, ShouldEqual, 86400) }) }) - }) }) } diff --git a/pkg/tsdb/elasticsearch/response_parser.go b/pkg/tsdb/elasticsearch/response_parser.go index 00f7dfb41d7..95e1d3f1882 100644 --- a/pkg/tsdb/elasticsearch/response_parser.go +++ b/pkg/tsdb/elasticsearch/response_parser.go @@ -158,10 +158,8 @@ func (rp *responseParser) processBuckets(aggs map[string]interface{}, target *Qu } } } - } return nil - } func (rp *responseParser) processMetrics(esAgg *simplejson.Json, target *Query, series *tsdb.TimeSeriesSlice, props map[string]string) error { @@ -424,7 +422,6 @@ func (rp *responseParser) nameSeries(seriesList *tsdb.TimeSeriesSlice, target *Q for _, series := range *seriesList { series.Name = rp.getSeriesName(series, target, metricTypeCount) } - } var aliasPatternRegex = regexp.MustCompile(`\{\{([\s\S]+?)\}\}`) @@ -519,7 +516,6 @@ func (rp *responseParser) getSeriesName(series *tsdb.TimeSeries, target *Query, } return strings.TrimSpace(name) + " " + metricName - } func (rp *responseParser) getMetricName(metric string) string { diff --git a/pkg/tsdb/frame_util.go b/pkg/tsdb/frame_util.go index d75542c29e9..d3b0d0c6535 100644 --- a/pkg/tsdb/frame_util.go +++ b/pkg/tsdb/frame_util.go @@ -92,5 +92,4 @@ func FrameToSeriesSlice(frame *data.Frame) (TimeSeriesSlice, error) { } return seriesSlice, nil - } diff --git a/pkg/tsdb/graphite/graphite_test.go b/pkg/tsdb/graphite/graphite_test.go index a36f2afe60a..bb243fba6fb 100644 --- a/pkg/tsdb/graphite/graphite_test.go +++ b/pkg/tsdb/graphite/graphite_test.go @@ -8,55 +8,39 @@ import ( func TestGraphiteFunctions(t *testing.T) { Convey("Testing Graphite Functions", t, func() { - Convey("formatting time range for now", func() { - timeRange := formatTimeRange("now") So(timeRange, ShouldEqual, "now") - }) Convey("formatting time range for now-1m", func() { - timeRange := formatTimeRange("now-1m") So(timeRange, ShouldEqual, "-1min") - }) Convey("formatting time range for now-1M", func() { - timeRange := formatTimeRange("now-1M") So(timeRange, ShouldEqual, "-1mon") - }) Convey("fix interval format in query for 1m", func() { - timeRange := fixIntervalFormat("aliasByNode(hitcount(averageSeries(app.grafana.*.dashboards.views.count), '1m'), 4)") So(timeRange, ShouldEqual, "aliasByNode(hitcount(averageSeries(app.grafana.*.dashboards.views.count), '1min'), 4)") - }) Convey("fix interval format in query for 1M", func() { - timeRange := fixIntervalFormat("aliasByNode(hitcount(averageSeries(app.grafana.*.dashboards.views.count), '1M'), 4)") So(timeRange, ShouldEqual, "aliasByNode(hitcount(averageSeries(app.grafana.*.dashboards.views.count), '1mon'), 4)") - }) Convey("should not override query for 1M", func() { - timeRange := fixIntervalFormat("app.grafana.*.dashboards.views.1M.count") So(timeRange, ShouldEqual, "app.grafana.*.dashboards.views.1M.count") - }) Convey("should not override query for 1m", func() { - timeRange := fixIntervalFormat("app.grafana.*.dashboards.views.1m.count") So(timeRange, ShouldEqual, "app.grafana.*.dashboards.views.1m.count") - }) - }) } diff --git a/pkg/tsdb/influxdb/flux/builder_test.go b/pkg/tsdb/influxdb/flux/builder_test.go index c3603e3075e..1b517db1fee 100644 --- a/pkg/tsdb/influxdb/flux/builder_test.go +++ b/pkg/tsdb/influxdb/flux/builder_test.go @@ -5,7 +5,6 @@ import ( ) func TestColumnIdentification(t *testing.T) { - t.Run("Test Tag Identification", func(t *testing.T) { tagNames := []string{"header", "value", "tag"} for _, item := range tagNames { diff --git a/pkg/tsdb/influxdb/flux/flux.go b/pkg/tsdb/influxdb/flux/flux.go index 7a6d91c5381..d71b9bf72cb 100644 --- a/pkg/tsdb/influxdb/flux/flux.go +++ b/pkg/tsdb/influxdb/flux/flux.go @@ -31,7 +31,6 @@ func Query(ctx context.Context, dsInfo *models.DataSource, tsdbQuery *tsdb.TsdbQ } for _, query := range tsdbQuery.Queries { - qm, err := GetQueryModelTSDB(query, tsdbQuery.TimeRange, dsInfo) if err != nil { tRes.Results[query.RefId] = &tsdb.QueryResult{Error: err} @@ -82,7 +81,6 @@ func RunnerFromDataSource(dsInfo *models.DataSource) (*Runner, error) { client: influxdb2.NewClient(url, token), org: org, }, nil - } // backendDataResponseToTSDBResponse takes the SDK's style response and changes it into a diff --git a/pkg/tsdb/influxdb/flux/macros.go b/pkg/tsdb/influxdb/flux/macros.go index f15f6324eeb..b119dc67fac 100644 --- a/pkg/tsdb/influxdb/flux/macros.go +++ b/pkg/tsdb/influxdb/flux/macros.go @@ -13,7 +13,6 @@ const variableFilter = `(?m)([a-zA-Z]+)\.([a-zA-Z]+)` // Interpolate processes macros func Interpolate(query QueryModel) (string, error) { - flux := query.RawQuery variableFilterExp, err := regexp.Compile(variableFilter) diff --git a/pkg/tsdb/influxdb/flux/macros_test.go b/pkg/tsdb/influxdb/flux/macros_test.go index 3a939bbc827..a2610a6db7b 100644 --- a/pkg/tsdb/influxdb/flux/macros_test.go +++ b/pkg/tsdb/influxdb/flux/macros_test.go @@ -36,7 +36,6 @@ func TestInterpolate(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - query := QueryModel{ RawQuery: tt.before, Options: options, diff --git a/pkg/tsdb/influxdb/influxdb.go b/pkg/tsdb/influxdb/influxdb.go index 7342d4c9101..683109117d0 100644 --- a/pkg/tsdb/influxdb/influxdb.go +++ b/pkg/tsdb/influxdb/influxdb.go @@ -44,7 +44,6 @@ func init() { } func (e *InfluxDBExecutor) Query(ctx context.Context, dsInfo *models.DataSource, tsdbQuery *tsdb.TsdbQuery) (*tsdb.Response, error) { - glog.Info("query", "q", tsdbQuery.Queries) version := dsInfo.JsonData.Get("version").MustString("") @@ -123,7 +122,6 @@ func (e *InfluxDBExecutor) getQuery(dsInfo *models.DataSource, queries []*tsdb.Q } func (e *InfluxDBExecutor) createRequest(dsInfo *models.DataSource, query string) (*http.Request, error) { - u, err := url.Parse(dsInfo.Url) if err != nil { return nil, err diff --git a/pkg/tsdb/influxdb/influxdb_test.go b/pkg/tsdb/influxdb/influxdb_test.go index 335335477b3..a6f4c654aa0 100644 --- a/pkg/tsdb/influxdb/influxdb_test.go +++ b/pkg/tsdb/influxdb/influxdb_test.go @@ -37,7 +37,6 @@ func TestInfluxDB(t *testing.T) { Convey("has an empty body", func() { So(req.Body, ShouldEqual, nil) }) - }) Convey("createRequest with POST httpMode", func() { @@ -60,7 +59,6 @@ func TestInfluxDB(t *testing.T) { testBody := testBodyValues.Encode() So(string(body[:]), ShouldEqual, testBody) }) - }) Convey("createRequest with PUT httpMode", func() { @@ -70,8 +68,6 @@ func TestInfluxDB(t *testing.T) { Convey("should miserably fail", func() { So(err, ShouldEqual, ErrInvalidHttpMode) }) - }) - }) } diff --git a/pkg/tsdb/influxdb/model_parser.go b/pkg/tsdb/influxdb/model_parser.go index 94f37904eee..443c08b1250 100644 --- a/pkg/tsdb/influxdb/model_parser.go +++ b/pkg/tsdb/influxdb/model_parser.go @@ -139,7 +139,6 @@ func (*InfluxdbQueryParser) parseQueryPart(model *simplejson.Json) (*QueryPart, } return nil, err - } qp, err := NewQueryPart(typ, params) diff --git a/pkg/tsdb/influxdb/model_parser_test.go b/pkg/tsdb/influxdb/model_parser_test.go index 5cf1e1e7228..95af062eb97 100644 --- a/pkg/tsdb/influxdb/model_parser_test.go +++ b/pkg/tsdb/influxdb/model_parser_test.go @@ -11,7 +11,6 @@ import ( func TestInfluxdbQueryParser(t *testing.T) { Convey("Influxdb query parser", t, func() { - parser := &InfluxdbQueryParser{} dsInfo := &models.DataSource{ JsonData: simplejson.New(), diff --git a/pkg/tsdb/influxdb/query.go b/pkg/tsdb/influxdb/query.go index 169e8945aae..75610024c2d 100644 --- a/pkg/tsdb/influxdb/query.go +++ b/pkg/tsdb/influxdb/query.go @@ -93,7 +93,6 @@ func (query *Query) renderSelectors(queryContext *tsdb.TsdbQuery) string { var selectors []string for _, sel := range query.Selects { - stk := "" for _, s := range *sel { stk = s.Render(query, queryContext, stk) diff --git a/pkg/tsdb/influxdb/query_test.go b/pkg/tsdb/influxdb/query_test.go index f85419c8ae2..16ebb038c1e 100644 --- a/pkg/tsdb/influxdb/query_test.go +++ b/pkg/tsdb/influxdb/query_test.go @@ -11,9 +11,7 @@ import ( ) func TestInfluxdbQueryBuilder(t *testing.T) { - Convey("Influxdb query builder", t, func() { - qp1, _ := NewQueryPart("field", []string{"value"}) qp2, _ := NewQueryPart("mean", []string{}) @@ -202,5 +200,4 @@ func TestInfluxdbQueryBuilder(t *testing.T) { So(query.renderMeasurement(), ShouldEqual, ` FROM "policy"./apa/`) }) }) - } diff --git a/pkg/tsdb/mssql/macros_test.go b/pkg/tsdb/mssql/macros_test.go index 829a8b1ff1a..341ccc56c14 100644 --- a/pkg/tsdb/mssql/macros_test.go +++ b/pkg/tsdb/mssql/macros_test.go @@ -153,7 +153,6 @@ func TestMacroEngine(t *testing.T) { }) Convey("interpolate __unixEpochGroup function", func() { - sql, err := engine.Interpolate(query, timeRange, "SELECT $__unixEpochGroup(time_column,'5m')") So(err, ShouldBeNil) sql2, err := engine.Interpolate(query, timeRange, "SELECT $__unixEpochGroupAlias(time_column,'5m')") @@ -162,7 +161,6 @@ func TestMacroEngine(t *testing.T) { So(sql, ShouldEqual, "SELECT FLOOR(time_column/300)*300") So(sql2, ShouldEqual, sql+" AS [time]") }) - }) Convey("Given a time range between 1960-02-01 07:00 and 1965-02-03 08:00", func() { diff --git a/pkg/tsdb/mssql/mssql_test.go b/pkg/tsdb/mssql/mssql_test.go index fe9cb1c418a..3916db39ebe 100644 --- a/pkg/tsdb/mssql/mssql_test.go +++ b/pkg/tsdb/mssql/mssql_test.go @@ -306,7 +306,6 @@ func TestMSSQL(t *testing.T) { } So(points[6][0].Valid, ShouldBeFalse) - }) Convey("When doing a metric query using timeGroup and $__interval", func() { @@ -705,7 +704,6 @@ func TestMSSQL(t *testing.T) { queryResult := resp.Results["A"] So(queryResult.Error, ShouldBeNil) So(queryResult.Meta.Get(sqleng.MetaKeyExecutedQueryString).MustString(), ShouldEqual, "SELECT time FROM metric_values WHERE time > '2018-03-15T12:55:00Z' OR time < '2018-03-15T12:55:00Z' OR 1 < 1521118500 OR 1521118800 > 1 ORDER BY 1") - }) Convey("Given a stored procedure that takes @from and @to in epoch time", func() { diff --git a/pkg/tsdb/mysql/macros_test.go b/pkg/tsdb/mysql/macros_test.go index b00935ed4dd..c1945905a77 100644 --- a/pkg/tsdb/mysql/macros_test.go +++ b/pkg/tsdb/mysql/macros_test.go @@ -38,7 +38,6 @@ func TestMacroEngine(t *testing.T) { }) Convey("interpolate __timeGroup function", func() { - sql, err := engine.Interpolate(query, timeRange, "GROUP BY $__timeGroup(time_column,'5m')") So(err, ShouldBeNil) sql2, err := engine.Interpolate(query, timeRange, "GROUP BY $__timeGroupAlias(time_column,'5m')") @@ -49,7 +48,6 @@ func TestMacroEngine(t *testing.T) { }) Convey("interpolate __timeGroup function with spaces around arguments", func() { - sql, err := engine.Interpolate(query, timeRange, "GROUP BY $__timeGroup(time_column , '5m')") So(err, ShouldBeNil) sql2, err := engine.Interpolate(query, timeRange, "GROUP BY $__timeGroupAlias(time_column , '5m')") @@ -109,7 +107,6 @@ func TestMacroEngine(t *testing.T) { }) Convey("interpolate __unixEpochGroup function", func() { - sql, err := engine.Interpolate(query, timeRange, "SELECT $__unixEpochGroup(time_column,'5m')") So(err, ShouldBeNil) sql2, err := engine.Interpolate(query, timeRange, "SELECT $__unixEpochGroupAlias(time_column,'5m')") @@ -118,7 +115,6 @@ func TestMacroEngine(t *testing.T) { So(sql, ShouldEqual, "SELECT time_column DIV 300 * 300") So(sql2, ShouldEqual, sql+" AS \"time\"") }) - }) Convey("Given a time range between 1960-02-01 07:00 and 1965-02-03 08:00", func() { diff --git a/pkg/tsdb/mysql/mysql_test.go b/pkg/tsdb/mysql/mysql_test.go index 2a2ba9335cc..f361afb9ec0 100644 --- a/pkg/tsdb/mysql/mysql_test.go +++ b/pkg/tsdb/mysql/mysql_test.go @@ -303,7 +303,6 @@ func TestMySQL(t *testing.T) { // check for NULL values inserted by fill So(points[6][0].Valid, ShouldBeFalse) - }) Convey("When doing a metric query using timeGroup and $__interval", func() { @@ -393,7 +392,6 @@ func TestMySQL(t *testing.T) { So(points[3][0].Float64, ShouldEqual, 15.0) So(points[6][0].Float64, ShouldEqual, 20.0) }) - }) Convey("Given a table with metrics having multiple values and measurements", func() { @@ -779,7 +777,6 @@ func TestMySQL(t *testing.T) { queryResult := resp.Results["A"] So(queryResult.Error, ShouldBeNil) So(queryResult.Meta.Get(sqleng.MetaKeyExecutedQueryString).MustString(), ShouldEqual, "SELECT time FROM metric_values WHERE time > FROM_UNIXTIME(1521118500) OR time < FROM_UNIXTIME(1521118800) OR 1 < 1521118500 OR 1521118800 > 1 ORDER BY 1") - }) Convey("Given a table with event data", func() { diff --git a/pkg/tsdb/opentsdb/opentsdb.go b/pkg/tsdb/opentsdb/opentsdb.go index 5ca633a576f..c4c009f98ea 100644 --- a/pkg/tsdb/opentsdb/opentsdb.go +++ b/pkg/tsdb/opentsdb/opentsdb.go @@ -106,7 +106,6 @@ func (e *OpenTsdbExecutor) createRequest(dsInfo *models.DataSource, data OpenTsd } func (e *OpenTsdbExecutor) parseResponse(query OpenTsdbQuery, res *http.Response) (map[string]*tsdb.QueryResult, error) { - queryResults := make(map[string]*tsdb.QueryResult) queryRes := tsdb.NewQueryResult() @@ -150,7 +149,6 @@ func (e *OpenTsdbExecutor) parseResponse(query OpenTsdbQuery, res *http.Response } func (e *OpenTsdbExecutor) buildMetric(query *tsdb.Query) map[string]interface{} { - metric := make(map[string]interface{}) // Setting metric and aggregator @@ -174,7 +172,6 @@ func (e *OpenTsdbExecutor) buildMetric(query *tsdb.Query) map[string]interface{} // Setting rate options if query.Model.Get("shouldComputeRate").MustBool() { - metric["rate"] = true rateOptions := make(map[string]interface{}) rateOptions["counter"] = query.Model.Get("isCounter").MustBool() @@ -209,5 +206,4 @@ func (e *OpenTsdbExecutor) buildMetric(query *tsdb.Query) map[string]interface{} } return metric - } diff --git a/pkg/tsdb/opentsdb/opentsdb_test.go b/pkg/tsdb/opentsdb/opentsdb_test.go index fe03599f54d..98af4cb1256 100644 --- a/pkg/tsdb/opentsdb/opentsdb_test.go +++ b/pkg/tsdb/opentsdb/opentsdb_test.go @@ -10,11 +10,9 @@ import ( func TestOpenTsdbExecutor(t *testing.T) { Convey("OpenTsdb query testing", t, func() { - exec := &OpenTsdbExecutor{} Convey("Build metric with downsampling enabled", func() { - query := &tsdb.Query{ Model: simplejson.New(), } @@ -32,11 +30,9 @@ func TestOpenTsdbExecutor(t *testing.T) { So(metric["metric"], ShouldEqual, "cpu.average.percent") So(metric["aggregator"], ShouldEqual, "avg") So(metric["downsample"], ShouldEqual, "1m-avg") - }) Convey("Build metric with downsampling disabled", func() { - query := &tsdb.Query{ Model: simplejson.New(), } @@ -53,11 +49,9 @@ func TestOpenTsdbExecutor(t *testing.T) { So(len(metric), ShouldEqual, 2) So(metric["metric"], ShouldEqual, "cpu.average.percent") So(metric["aggregator"], ShouldEqual, "avg") - }) Convey("Build metric with downsampling enabled with params", func() { - query := &tsdb.Query{ Model: simplejson.New(), } @@ -78,7 +72,6 @@ func TestOpenTsdbExecutor(t *testing.T) { }) Convey("Build metric with tags with downsampling disabled", func() { - query := &tsdb.Query{ Model: simplejson.New(), } @@ -108,7 +101,6 @@ func TestOpenTsdbExecutor(t *testing.T) { }) Convey("Build metric with rate enabled but counter disabled", func() { - query := &tsdb.Query{ Model: simplejson.New(), } @@ -138,7 +130,6 @@ func TestOpenTsdbExecutor(t *testing.T) { }) Convey("Build metric with rate and counter enabled", func() { - query := &tsdb.Query{ Model: simplejson.New(), } @@ -171,6 +162,5 @@ func TestOpenTsdbExecutor(t *testing.T) { So(metric["rateOptions"].(map[string]interface{})["counterMax"], ShouldEqual, 45) So(metric["rateOptions"].(map[string]interface{})["resetValue"], ShouldEqual, 60) }) - }) } diff --git a/pkg/tsdb/postgres/macros.go b/pkg/tsdb/postgres/macros.go index fc1a0a7e343..fca904d9d9c 100644 --- a/pkg/tsdb/postgres/macros.go +++ b/pkg/tsdb/postgres/macros.go @@ -35,7 +35,6 @@ func (m *postgresMacroEngine) Interpolate(query *tsdb.Query, timeRange *tsdb.Tim var macroError error sql = m.ReplaceAllStringSubmatchFunc(rExp, sql, func(groups []string) string { - // detect if $__timeGroup is supposed to add AS time for pre 5.3 compatibility // if there is a ',' directly after the macro call $__timeGroup is probably used // in the old way. Inside window function ORDER BY $__timeGroup will be followed diff --git a/pkg/tsdb/postgres/macros_test.go b/pkg/tsdb/postgres/macros_test.go index eb14656c546..b11a3efccb4 100644 --- a/pkg/tsdb/postgres/macros_test.go +++ b/pkg/tsdb/postgres/macros_test.go @@ -59,7 +59,6 @@ func TestMacroEngine(t *testing.T) { }) Convey("interpolate __timeGroup function pre 5.3 compatibility", func() { - sql, err := engine.Interpolate(query, timeRange, "SELECT $__timeGroup(time_column,'5m'), value") So(err, ShouldBeNil) @@ -72,7 +71,6 @@ func TestMacroEngine(t *testing.T) { }) Convey("interpolate __timeGroup function", func() { - sql, err := engine.Interpolate(query, timeRange, "SELECT $__timeGroup(time_column,'5m')") So(err, ShouldBeNil) sql2, err := engine.Interpolate(query, timeRange, "SELECT $__timeGroupAlias(time_column,'5m')") @@ -83,7 +81,6 @@ func TestMacroEngine(t *testing.T) { }) Convey("interpolate __timeGroup function with spaces between args", func() { - sql, err := engine.Interpolate(query, timeRange, "$__timeGroup(time_column , '5m')") So(err, ShouldBeNil) sql2, err := engine.Interpolate(query, timeRange, "$__timeGroupAlias(time_column , '5m')") @@ -94,7 +91,6 @@ func TestMacroEngine(t *testing.T) { }) Convey("interpolate __timeGroup function with TimescaleDB enabled", func() { - sql, err := engineTS.Interpolate(query, timeRange, "GROUP BY $__timeGroup(time_column,'5m')") So(err, ShouldBeNil) @@ -102,7 +98,6 @@ func TestMacroEngine(t *testing.T) { }) Convey("interpolate __timeGroup function with spaces between args and TimescaleDB enabled", func() { - sql, err := engineTS.Interpolate(query, timeRange, "GROUP BY $__timeGroup(time_column , '5m')") So(err, ShouldBeNil) @@ -136,7 +131,6 @@ func TestMacroEngine(t *testing.T) { }) Convey("interpolate __unixEpochGroup function", func() { - sql, err := engine.Interpolate(query, timeRange, "SELECT $__unixEpochGroup(time_column,'5m')") So(err, ShouldBeNil) sql2, err := engine.Interpolate(query, timeRange, "SELECT $__unixEpochGroupAlias(time_column,'5m')") @@ -145,7 +139,6 @@ func TestMacroEngine(t *testing.T) { So(sql, ShouldEqual, "SELECT floor(time_column/300)*300") So(sql2, ShouldEqual, sql+" AS \"time\"") }) - }) Convey("Given a time range between 1960-02-01 07:00 and 1965-02-03 08:00", func() { @@ -213,8 +206,6 @@ func TestMacroEngine(t *testing.T) { So(sql, ShouldEqual, fmt.Sprintf("WHERE time_column BETWEEN '%s' AND '%s'", from.Format(time.RFC3339Nano), to.Format(time.RFC3339Nano))) }) - }) - }) } diff --git a/pkg/tsdb/postgres/postgres_test.go b/pkg/tsdb/postgres/postgres_test.go index bd33d836225..8ccbaf1ab5d 100644 --- a/pkg/tsdb/postgres/postgres_test.go +++ b/pkg/tsdb/postgres/postgres_test.go @@ -316,7 +316,6 @@ func TestPostgres(t *testing.T) { // check for NULL values inserted by fill So(points[6][0].Valid, ShouldBeFalse) - }) Convey("When doing a metric query using timeGroup with value fill enabled", func() { @@ -709,7 +708,6 @@ func TestPostgres(t *testing.T) { queryResult := resp.Results["A"] So(queryResult.Error, ShouldBeNil) So(queryResult.Meta.Get(sqleng.MetaKeyExecutedQueryString).MustString(), ShouldEqual, "SELECT time FROM metric_values WHERE time > '2018-03-15T12:55:00Z' OR time < '2018-03-15T12:55:00Z' OR 1 < 1521118500 OR 1521118800 > 1 ORDER BY 1") - }) }) diff --git a/pkg/tsdb/prometheus/prometheus_test.go b/pkg/tsdb/prometheus/prometheus_test.go index db41261ead9..0eec856be0b 100644 --- a/pkg/tsdb/prometheus/prometheus_test.go +++ b/pkg/tsdb/prometheus/prometheus_test.go @@ -155,6 +155,5 @@ func TestPrometheus(t *testing.T) { }) }) }) - }) } diff --git a/pkg/tsdb/sqleng/sql_engine_test.go b/pkg/tsdb/sqleng/sql_engine_test.go index 4cdf700ea98..00e5bdccbc0 100644 --- a/pkg/tsdb/sqleng/sql_engine_test.go +++ b/pkg/tsdb/sqleng/sql_engine_test.go @@ -58,7 +58,6 @@ func TestSqlEngine(t *testing.T) { So(sql, ShouldEqual, fmt.Sprintf("select %d", to.Unix())) }) - }) Convey("Given row values with time.Time as time columns", func() { diff --git a/pkg/tsdb/time_range_test.go b/pkg/tsdb/time_range_test.go index 4beb5914083..56a8955a00c 100644 --- a/pkg/tsdb/time_range_test.go +++ b/pkg/tsdb/time_range_test.go @@ -11,7 +11,6 @@ import ( func TestTimeRange(t *testing.T) { Convey("Time range", t, func() { - now := time.Now() Convey("Can parse 5m, now", func() { diff --git a/pkg/util/encryption_test.go b/pkg/util/encryption_test.go index df43a9a99d6..59919de8e54 100644 --- a/pkg/util/encryption_test.go +++ b/pkg/util/encryption_test.go @@ -7,9 +7,7 @@ import ( ) func TestEncryption(t *testing.T) { - Convey("When getting encryption key", t, func() { - key, err := encryptionKeyToBytes("secret", "salt") So(err, ShouldBeNil) So(len(key), ShouldEqual, 32) @@ -27,5 +25,4 @@ func TestEncryption(t *testing.T) { So(decryptErr, ShouldBeNil) So(string(decrypted), ShouldEqual, "grafana") }) - } diff --git a/pkg/util/url_test.go b/pkg/util/url_test.go index ae7660a4a43..7602d0badb2 100644 --- a/pkg/util/url_test.go +++ b/pkg/util/url_test.go @@ -8,7 +8,6 @@ import ( ) func TestUrl(t *testing.T) { - Convey("When joining two urls where right hand side is empty", t, func() { result := JoinURLFragments("http://localhost:8080", "") diff --git a/pkg/util/validation_test.go b/pkg/util/validation_test.go index 124da1b744b..dfd5fa12148 100644 --- a/pkg/util/validation_test.go +++ b/pkg/util/validation_test.go @@ -7,7 +7,6 @@ import ( ) func TestIsEmail(t *testing.T) { - Convey("When validating a string that is a valid email", t, func() { result := IsEmail("abc@def.com") diff --git a/scripts/go/configs/.golangci.toml b/scripts/go/configs/.golangci.toml index 304733530e9..5ff0e6bd138 100644 --- a/scripts/go/configs/.golangci.toml +++ b/scripts/go/configs/.golangci.toml @@ -37,7 +37,7 @@ enable = [ "unconvert", "unused", "varcheck", - # "whitespace", + "whitespace", ] # Disabled linters (might want them later)