Explorar el Código

Merge pull request #11613 from knweiss/gosimple

Code simplification (gosimple)
Carl Bergquist hace 7 años
padre
commit
8367199a2d
Se han modificado 45 ficheros con 89 adiciones y 174 borrados
  1. 1 1
      build.go
  2. 2 5
      pkg/api/avatar/avatar.go
  3. 1 1
      pkg/api/http_server.go
  4. 1 1
      pkg/cmd/grafana-cli/commands/install_command.go
  5. 1 1
      pkg/cmd/grafana-cli/commands/ls_command.go
  6. 1 2
      pkg/cmd/grafana-cli/commands/upgrade_all_command.go
  7. 0 7
      pkg/components/dynmap/dynmap.go
  8. 4 4
      pkg/components/dynmap/dynmap_test.go
  9. 1 4
      pkg/log/file.go
  10. 1 2
      pkg/login/ldap.go
  11. 1 5
      pkg/metrics/graphitebridge/graphite.go
  12. 2 2
      pkg/models/org_user.go
  13. 1 1
      pkg/plugins/datasource/wrapper/datasource_plugin_wrapper_test.go
  14. 3 3
      pkg/services/alerting/conditions/evaluator.go
  15. 1 1
      pkg/services/alerting/conditions/query.go
  16. 1 1
      pkg/services/alerting/extractor.go
  17. 1 1
      pkg/services/alerting/notifiers/telegram.go
  18. 2 2
      pkg/services/alerting/rule.go
  19. 2 2
      pkg/services/alerting/scheduler.go
  20. 1 2
      pkg/services/notifications/mailer.go
  21. 1 5
      pkg/services/provisioning/provisioning.go
  22. 1 6
      pkg/services/sqlstore/alert_notification.go
  23. 2 5
      pkg/services/sqlstore/annotation.go
  24. 2 2
      pkg/services/sqlstore/apikey.go
  25. 8 18
      pkg/services/sqlstore/dashboard.go
  26. 2 4
      pkg/services/sqlstore/dashboard_acl.go
  27. 1 1
      pkg/services/sqlstore/dashboard_snapshot.go
  28. 2 4
      pkg/services/sqlstore/migrator/dialect.go
  29. 1 2
      pkg/services/sqlstore/migrator/migrations.go
  30. 1 1
      pkg/services/sqlstore/migrator/types.go
  31. 1 1
      pkg/services/sqlstore/plugin_setting.go
  32. 4 4
      pkg/services/sqlstore/quota.go
  33. 0 4
      pkg/services/sqlstore/stats.go
  34. 1 5
      pkg/services/sqlstore/team.go
  35. 1 1
      pkg/services/sqlstore/temp_user.go
  36. 11 20
      pkg/services/sqlstore/user.go
  37. 1 1
      pkg/social/generic_oauth.go
  38. 0 3
      pkg/tsdb/cloudwatch/cloudwatch.go
  39. 4 15
      pkg/tsdb/cloudwatch/metric_find_query.go
  40. 1 4
      pkg/tsdb/cloudwatch/metric_find_query_test.go
  41. 5 5
      pkg/tsdb/mssql/mssql.go
  42. 4 4
      pkg/tsdb/mysql/mysql.go
  43. 5 5
      pkg/tsdb/postgres/postgres.go
  44. 1 1
      pkg/tsdb/sql_engine.go
  45. 1 5
      pkg/util/shortid_generator.go

+ 1 - 1
build.go

@@ -550,7 +550,7 @@ func shaFilesInDist() {
 			return nil
 			return nil
 		}
 		}
 
 
-		if strings.Contains(path, ".sha256") == false {
+		if !strings.Contains(path, ".sha256") {
 			err := shaFile(path)
 			err := shaFile(path)
 			if err != nil {
 			if err != nil {
 				log.Printf("Failed to create sha file. error: %v\n", err)
 				log.Printf("Failed to create sha file. error: %v\n", err)

+ 2 - 5
pkg/api/avatar/avatar.go

@@ -258,9 +258,6 @@ func (this *thunderTask) fetch() error {
 	this.Avatar.data = &bytes.Buffer{}
 	this.Avatar.data = &bytes.Buffer{}
 	writer := bufio.NewWriter(this.Avatar.data)
 	writer := bufio.NewWriter(this.Avatar.data)
 
 
-	if _, err = io.Copy(writer, resp.Body); err != nil {
-		return err
-	}
-
-	return nil
+	_, err = io.Copy(writer, resp.Body)
+	return err
 }
 }

+ 1 - 1
pkg/api/http_server.go

@@ -139,7 +139,7 @@ func (hs *HTTPServer) listenAndServeTLS(certfile, keyfile string) error {
 	}
 	}
 
 
 	hs.httpSrv.TLSConfig = tlsCfg
 	hs.httpSrv.TLSConfig = tlsCfg
-	hs.httpSrv.TLSNextProto = make(map[string]func(*http.Server, *tls.Conn, http.Handler), 0)
+	hs.httpSrv.TLSNextProto = make(map[string]func(*http.Server, *tls.Conn, http.Handler))
 
 
 	return hs.httpSrv.ListenAndServeTLS(setting.CertFile, setting.KeyFile)
 	return hs.httpSrv.ListenAndServeTLS(setting.CertFile, setting.KeyFile)
 }
 }

+ 1 - 1
pkg/cmd/grafana-cli/commands/install_command.go

@@ -33,7 +33,7 @@ func validateInput(c CommandLine, pluginFolder string) error {
 	fileInfo, err := os.Stat(pluginsDir)
 	fileInfo, err := os.Stat(pluginsDir)
 	if err != nil {
 	if err != nil {
 		if err = os.MkdirAll(pluginsDir, os.ModePerm); err != nil {
 		if err = os.MkdirAll(pluginsDir, os.ModePerm); err != nil {
-			return errors.New(fmt.Sprintf("pluginsDir (%s) is not a writable directory", pluginsDir))
+			return fmt.Errorf("pluginsDir (%s) is not a writable directory", pluginsDir)
 		}
 		}
 		return nil
 		return nil
 	}
 	}

+ 1 - 1
pkg/cmd/grafana-cli/commands/ls_command.go

@@ -24,7 +24,7 @@ var validateLsCommand = func(pluginDir string) error {
 		return fmt.Errorf("error: %s", err)
 		return fmt.Errorf("error: %s", err)
 	}
 	}
 
 
-	if pluginDirInfo.IsDir() == false {
+	if !pluginDirInfo.IsDir() {
 		return errors.New("plugin path is not a directory")
 		return errors.New("plugin path is not a directory")
 	}
 	}
 
 

+ 1 - 2
pkg/cmd/grafana-cli/commands/upgrade_all_command.go

@@ -53,8 +53,7 @@ func upgradeAllCommand(c CommandLine) error {
 	for _, p := range pluginsToUpgrade {
 	for _, p := range pluginsToUpgrade {
 		logger.Infof("Updating %v \n", p.Id)
 		logger.Infof("Updating %v \n", p.Id)
 
 
-		var err error
-		err = s.RemoveInstalledPlugin(pluginsDir, p.Id)
+		err := s.RemoveInstalledPlugin(pluginsDir, p.Id)
 		if err != nil {
 		if err != nil {
 			return err
 			return err
 		}
 		}

+ 0 - 7
pkg/components/dynmap/dynmap.go

@@ -585,7 +585,6 @@ func (v *Value) Null() error {
 	switch v.data.(type) {
 	switch v.data.(type) {
 	case nil:
 	case nil:
 		valid = v.exists // Valid only if j also exists, since other values could possibly also be nil
 		valid = v.exists // Valid only if j also exists, since other values could possibly also be nil
-		break
 	}
 	}
 
 
 	if valid {
 	if valid {
@@ -607,7 +606,6 @@ func (v *Value) Array() ([]*Value, error) {
 	switch v.data.(type) {
 	switch v.data.(type) {
 	case []interface{}:
 	case []interface{}:
 		valid = true
 		valid = true
-		break
 	}
 	}
 
 
 	// Unsure if this is a good way to use slices, it's probably not
 	// Unsure if this is a good way to use slices, it's probably not
@@ -638,7 +636,6 @@ func (v *Value) Number() (json.Number, error) {
 	switch v.data.(type) {
 	switch v.data.(type) {
 	case json.Number:
 	case json.Number:
 		valid = true
 		valid = true
-		break
 	}
 	}
 
 
 	if valid {
 	if valid {
@@ -687,7 +684,6 @@ func (v *Value) Boolean() (bool, error) {
 	switch v.data.(type) {
 	switch v.data.(type) {
 	case bool:
 	case bool:
 		valid = true
 		valid = true
-		break
 	}
 	}
 
 
 	if valid {
 	if valid {
@@ -709,7 +705,6 @@ func (v *Value) Object() (*Object, error) {
 	switch v.data.(type) {
 	switch v.data.(type) {
 	case map[string]interface{}:
 	case map[string]interface{}:
 		valid = true
 		valid = true
-		break
 	}
 	}
 
 
 	if valid {
 	if valid {
@@ -746,7 +741,6 @@ func (v *Value) ObjectArray() ([]*Object, error) {
 	switch v.data.(type) {
 	switch v.data.(type) {
 	case []interface{}:
 	case []interface{}:
 		valid = true
 		valid = true
-		break
 	}
 	}
 
 
 	// Unsure if this is a good way to use slices, it's probably not
 	// Unsure if this is a good way to use slices, it's probably not
@@ -782,7 +776,6 @@ func (v *Value) String() (string, error) {
 	switch v.data.(type) {
 	switch v.data.(type) {
 	case string:
 	case string:
 		valid = true
 		valid = true
-		break
 	}
 	}
 
 
 	if valid {
 	if valid {

+ 4 - 4
pkg/components/dynmap/dynmap_test.go

@@ -21,7 +21,7 @@ func NewAssert(t *testing.T) *Assert {
 }
 }
 
 
 func (assert *Assert) True(value bool, message string) {
 func (assert *Assert) True(value bool, message string) {
-	if value == false {
+	if !value {
 		log.Panicln("Assert: ", message)
 		log.Panicln("Assert: ", message)
 	}
 	}
 }
 }
@@ -119,13 +119,13 @@ func TestFirst(t *testing.T) {
 	assert.True(s == "" && err != nil, "nonexistent string fail")
 	assert.True(s == "" && err != nil, "nonexistent string fail")
 
 
 	b, err := j.GetBoolean("true")
 	b, err := j.GetBoolean("true")
-	assert.True(b == true && err == nil, "bool true test")
+	assert.True(b && err == nil, "bool true test")
 
 
 	b, err = j.GetBoolean("false")
 	b, err = j.GetBoolean("false")
-	assert.True(b == false && err == nil, "bool false test")
+	assert.True(!b && err == nil, "bool false test")
 
 
 	b, err = j.GetBoolean("invalid_field")
 	b, err = j.GetBoolean("invalid_field")
-	assert.True(b == false && err != nil, "bool invalid test")
+	assert.True(!b && err != nil, "bool invalid test")
 
 
 	list, err := j.GetValueArray("list")
 	list, err := j.GetValueArray("list")
 	assert.True(list != nil && err == nil, "list should be an array")
 	assert.True(list != nil && err == nil, "list should be an array")

+ 1 - 4
pkg/log/file.go

@@ -99,10 +99,7 @@ func (w *FileLogWriter) StartLogger() error {
 		return err
 		return err
 	}
 	}
 	w.mw.SetFd(fd)
 	w.mw.SetFd(fd)
-	if err = w.initFd(); err != nil {
-		return err
-	}
-	return nil
+	return w.initFd()
 }
 }
 
 
 func (w *FileLogWriter) docheck(size int) {
 func (w *FileLogWriter) docheck(size int) {

+ 1 - 2
pkg/login/ldap.go

@@ -403,8 +403,7 @@ func (a *ldapAuther) searchForUser(username string) (*LdapUserInfo, error) {
 		// If we are using a POSIX LDAP schema it won't support memberOf, so we manually search the groups
 		// If we are using a POSIX LDAP schema it won't support memberOf, so we manually search the groups
 		var groupSearchResult *ldap.SearchResult
 		var groupSearchResult *ldap.SearchResult
 		for _, groupSearchBase := range a.server.GroupSearchBaseDNs {
 		for _, groupSearchBase := range a.server.GroupSearchBaseDNs {
-			var filter_replace string
-			filter_replace = getLdapAttr(a.server.GroupSearchFilterUserAttribute, searchResult)
+			filter_replace := getLdapAttr(a.server.GroupSearchFilterUserAttribute, searchResult)
 			if a.server.GroupSearchFilterUserAttribute == "" {
 			if a.server.GroupSearchFilterUserAttribute == "" {
 				filter_replace = getLdapAttr(a.server.Attr.Username, searchResult)
 				filter_replace = getLdapAttr(a.server.Attr.Username, searchResult)
 			}
 			}

+ 1 - 5
pkg/metrics/graphitebridge/graphite.go

@@ -295,11 +295,7 @@ func writeMetric(buf *bufio.Writer, m model.Metric, mf *dto.MetricFamily) error
 		}
 		}
 	}
 	}
 
 
-	if err = addExtentionConventionForRollups(buf, mf, m); err != nil {
-		return err
-	}
-
-	return nil
+	return addExtentionConventionForRollups(buf, mf, m)
 }
 }
 
 
 func addExtentionConventionForRollups(buf *bufio.Writer, mf *dto.MetricFamily, m model.Metric) error {
 func addExtentionConventionForRollups(buf *bufio.Writer, mf *dto.MetricFamily, m model.Metric) error {

+ 2 - 2
pkg/models/org_user.go

@@ -48,9 +48,9 @@ func (r *RoleType) UnmarshalJSON(data []byte) error {
 
 
 	*r = RoleType(str)
 	*r = RoleType(str)
 
 
-	if (*r).IsValid() == false {
+	if !(*r).IsValid() {
 		if (*r) != "" {
 		if (*r) != "" {
-			return errors.New(fmt.Sprintf("JSON validation error: invalid role value: %s", *r))
+			return fmt.Errorf("JSON validation error: invalid role value: %s", *r)
 		}
 		}
 
 
 		*r = ROLE_VIEWER
 		*r = ROLE_VIEWER

+ 1 - 1
pkg/plugins/datasource/wrapper/datasource_plugin_wrapper_test.go

@@ -74,7 +74,7 @@ func TestMappingRowValue(t *testing.T) {
 
 
 	boolRowValue, _ := dpw.mapRowValue(&datasource.RowValue{Kind: datasource.RowValue_TYPE_BOOL, BoolValue: true})
 	boolRowValue, _ := dpw.mapRowValue(&datasource.RowValue{Kind: datasource.RowValue_TYPE_BOOL, BoolValue: true})
 	haveBool, ok := boolRowValue.(bool)
 	haveBool, ok := boolRowValue.(bool)
-	if !ok || haveBool != true {
+	if !ok || !haveBool {
 		t.Fatalf("Expected true, was %v", haveBool)
 		t.Fatalf("Expected true, was %v", haveBool)
 	}
 	}
 
 

+ 3 - 3
pkg/services/alerting/conditions/evaluator.go

@@ -20,7 +20,7 @@ type AlertEvaluator interface {
 type NoValueEvaluator struct{}
 type NoValueEvaluator struct{}
 
 
 func (e *NoValueEvaluator) Eval(reducedValue null.Float) bool {
 func (e *NoValueEvaluator) Eval(reducedValue null.Float) bool {
-	return reducedValue.Valid == false
+	return !reducedValue.Valid
 }
 }
 
 
 type ThresholdEvaluator struct {
 type ThresholdEvaluator struct {
@@ -45,7 +45,7 @@ func newThresholdEvaluator(typ string, model *simplejson.Json) (*ThresholdEvalua
 }
 }
 
 
 func (e *ThresholdEvaluator) Eval(reducedValue null.Float) bool {
 func (e *ThresholdEvaluator) Eval(reducedValue null.Float) bool {
-	if reducedValue.Valid == false {
+	if !reducedValue.Valid {
 		return false
 		return false
 	}
 	}
 
 
@@ -88,7 +88,7 @@ func newRangedEvaluator(typ string, model *simplejson.Json) (*RangedEvaluator, e
 }
 }
 
 
 func (e *RangedEvaluator) Eval(reducedValue null.Float) bool {
 func (e *RangedEvaluator) Eval(reducedValue null.Float) bool {
-	if reducedValue.Valid == false {
+	if !reducedValue.Valid {
 		return false
 		return false
 	}
 	}
 
 

+ 1 - 1
pkg/services/alerting/conditions/query.go

@@ -53,7 +53,7 @@ func (c *QueryCondition) Eval(context *alerting.EvalContext) (*alerting.Conditio
 		reducedValue := c.Reducer.Reduce(series)
 		reducedValue := c.Reducer.Reduce(series)
 		evalMatch := c.Evaluator.Eval(reducedValue)
 		evalMatch := c.Evaluator.Eval(reducedValue)
 
 
-		if reducedValue.Valid == false {
+		if !reducedValue.Valid {
 			emptySerieCount++
 			emptySerieCount++
 		}
 		}
 
 

+ 1 - 1
pkg/services/alerting/extractor.go

@@ -104,7 +104,7 @@ func (e *DashAlertExtractor) getAlertFromPanels(jsonWithPanels *simplejson.Json,
 
 
 		// backward compatibility check, can be removed later
 		// backward compatibility check, can be removed later
 		enabled, hasEnabled := jsonAlert.CheckGet("enabled")
 		enabled, hasEnabled := jsonAlert.CheckGet("enabled")
-		if hasEnabled && enabled.MustBool() == false {
+		if hasEnabled && !enabled.MustBool() {
 			continue
 			continue
 		}
 		}
 
 

+ 1 - 1
pkg/services/alerting/notifiers/telegram.go

@@ -219,7 +219,7 @@ func appendIfPossible(message string, extra string, sizeLimit int) string {
 
 
 func (this *TelegramNotifier) Notify(evalContext *alerting.EvalContext) error {
 func (this *TelegramNotifier) Notify(evalContext *alerting.EvalContext) error {
 	var cmd *m.SendWebhookSync
 	var cmd *m.SendWebhookSync
-	if evalContext.ImagePublicUrl == "" && this.UploadImage == true {
+	if evalContext.ImagePublicUrl == "" && this.UploadImage {
 		cmd = this.buildMessage(evalContext, true)
 		cmd = this.buildMessage(evalContext, true)
 	} else {
 	} else {
 		cmd = this.buildMessage(evalContext, false)
 		cmd = this.buildMessage(evalContext, false)

+ 2 - 2
pkg/services/alerting/rule.go

@@ -55,8 +55,8 @@ func (e ValidationError) Error() string {
 }
 }
 
 
 var (
 var (
-	ValueFormatRegex = regexp.MustCompile("^\\d+")
-	UnitFormatRegex  = regexp.MustCompile("\\w{1}$")
+	ValueFormatRegex = regexp.MustCompile(`^\d+`)
+	UnitFormatRegex  = regexp.MustCompile(`\w{1}$`)
 )
 )
 
 
 var unitMultiplier = map[string]int{
 var unitMultiplier = map[string]int{

+ 2 - 2
pkg/services/alerting/scheduler.go

@@ -15,7 +15,7 @@ type SchedulerImpl struct {
 
 
 func NewScheduler() Scheduler {
 func NewScheduler() Scheduler {
 	return &SchedulerImpl{
 	return &SchedulerImpl{
-		jobs: make(map[int64]*Job, 0),
+		jobs: make(map[int64]*Job),
 		log:  log.New("alerting.scheduler"),
 		log:  log.New("alerting.scheduler"),
 	}
 	}
 }
 }
@@ -23,7 +23,7 @@ func NewScheduler() Scheduler {
 func (s *SchedulerImpl) Update(rules []*Rule) {
 func (s *SchedulerImpl) Update(rules []*Rule) {
 	s.log.Debug("Scheduling update", "ruleCount", len(rules))
 	s.log.Debug("Scheduling update", "ruleCount", len(rules))
 
 
-	jobs := make(map[int64]*Job, 0)
+	jobs := make(map[int64]*Job)
 
 
 	for i, rule := range rules {
 	for i, rule := range rules {
 		var job *Job
 		var job *Job

+ 1 - 2
pkg/services/notifications/mailer.go

@@ -7,7 +7,6 @@ package notifications
 import (
 import (
 	"bytes"
 	"bytes"
 	"crypto/tls"
 	"crypto/tls"
-	"errors"
 	"fmt"
 	"fmt"
 	"html/template"
 	"html/template"
 	"net"
 	"net"
@@ -135,7 +134,7 @@ func buildEmailMessage(cmd *m.SendEmailCommand) (*Message, error) {
 		subjectText, hasSubject := subjectData["value"]
 		subjectText, hasSubject := subjectData["value"]
 
 
 		if !hasSubject {
 		if !hasSubject {
-			return nil, errors.New(fmt.Sprintf("Missing subject in Template %s", cmd.Template))
+			return nil, fmt.Errorf("Missing subject in Template %s", cmd.Template)
 		}
 		}
 
 
 		subjectTmpl, err := template.New("subject").Parse(subjectText.(string))
 		subjectTmpl, err := template.New("subject").Parse(subjectText.(string))

+ 1 - 5
pkg/services/provisioning/provisioning.go

@@ -20,11 +20,7 @@ func Init(ctx context.Context, homePath string, cfg *ini.File) error {
 
 
 	dashboardPath := path.Join(provisioningPath, "dashboards")
 	dashboardPath := path.Join(provisioningPath, "dashboards")
 	_, err := dashboards.Provision(ctx, dashboardPath)
 	_, err := dashboards.Provision(ctx, dashboardPath)
-	if err != nil {
-		return err
-	}
-
-	return nil
+	return err
 }
 }
 
 
 func makeAbsolute(path string, root string) string {
 func makeAbsolute(path string, root string) string {

+ 1 - 6
pkg/services/sqlstore/alert_notification.go

@@ -23,12 +23,7 @@ func DeleteAlertNotification(cmd *m.DeleteAlertNotificationCommand) error {
 	return inTransaction(func(sess *DBSession) error {
 	return inTransaction(func(sess *DBSession) error {
 		sql := "DELETE FROM alert_notification WHERE alert_notification.org_id = ? AND alert_notification.id = ?"
 		sql := "DELETE FROM alert_notification WHERE alert_notification.org_id = ? AND alert_notification.id = ?"
 		_, err := sess.Exec(sql, cmd.OrgId, cmd.Id)
 		_, err := sess.Exec(sql, cmd.OrgId, cmd.Id)
-
-		if err != nil {
-			return err
-		}
-
-		return nil
+		return err
 	})
 	})
 }
 }
 
 

+ 2 - 5
pkg/services/sqlstore/annotation.go

@@ -102,11 +102,8 @@ func (r *SqlAnnotationRepo) Update(item *annotations.Item) error {
 
 
 		existing.Tags = item.Tags
 		existing.Tags = item.Tags
 
 
-		if _, err := sess.Table("annotation").Id(existing.Id).Cols("epoch", "text", "region_id", "tags").Update(existing); err != nil {
-			return err
-		}
-
-		return nil
+		_, err = sess.Table("annotation").Id(existing.Id).Cols("epoch", "text", "region_id", "tags").Update(existing)
+		return err
 	})
 	})
 }
 }
 
 

+ 2 - 2
pkg/services/sqlstore/apikey.go

@@ -55,7 +55,7 @@ func GetApiKeyById(query *m.GetApiKeyByIdQuery) error {
 
 
 	if err != nil {
 	if err != nil {
 		return err
 		return err
-	} else if has == false {
+	} else if !has {
 		return m.ErrInvalidApiKey
 		return m.ErrInvalidApiKey
 	}
 	}
 
 
@@ -69,7 +69,7 @@ func GetApiKeyByName(query *m.GetApiKeyByNameQuery) error {
 
 
 	if err != nil {
 	if err != nil {
 		return err
 		return err
-	} else if has == false {
+	} else if !has {
 		return m.ErrInvalidApiKey
 		return m.ErrInvalidApiKey
 	}
 	}
 
 

+ 8 - 18
pkg/services/sqlstore/dashboard.go

@@ -63,7 +63,7 @@ func saveDashboard(sess *DBSession, cmd *m.SaveDashboardCommand) error {
 		}
 		}
 
 
 		// do not allow plugin dashboard updates without overwrite flag
 		// do not allow plugin dashboard updates without overwrite flag
-		if existing.PluginId != "" && cmd.Overwrite == false {
+		if existing.PluginId != "" && !cmd.Overwrite {
 			return m.UpdatePluginDashboardError{PluginId: existing.PluginId}
 			return m.UpdatePluginDashboardError{PluginId: existing.PluginId}
 		}
 		}
 	}
 	}
@@ -172,7 +172,7 @@ func GetDashboard(query *m.GetDashboardQuery) error {
 
 
 	if err != nil {
 	if err != nil {
 		return err
 		return err
-	} else if has == false {
+	} else if !has {
 		return m.ErrDashboardNotFound
 		return m.ErrDashboardNotFound
 	}
 	}
 
 
@@ -308,7 +308,7 @@ func DeleteDashboard(cmd *m.DeleteDashboardCommand) error {
 		has, err := sess.Get(&dashboard)
 		has, err := sess.Get(&dashboard)
 		if err != nil {
 		if err != nil {
 			return err
 			return err
-		} else if has == false {
+		} else if !has {
 			return m.ErrDashboardNotFound
 			return m.ErrDashboardNotFound
 		}
 		}
 
 
@@ -347,12 +347,7 @@ func GetDashboards(query *m.GetDashboardsQuery) error {
 
 
 	err := x.In("id", query.DashboardIds).Find(&dashboards)
 	err := x.In("id", query.DashboardIds).Find(&dashboards)
 	query.Result = dashboards
 	query.Result = dashboards
-
-	if err != nil {
-		return err
-	}
-
-	return nil
+	return err
 }
 }
 
 
 // GetDashboardPermissionsForUser returns the maximum permission the specified user has for a dashboard(s)
 // GetDashboardPermissionsForUser returns the maximum permission the specified user has for a dashboard(s)
@@ -431,12 +426,7 @@ func GetDashboardsByPluginId(query *m.GetDashboardsByPluginIdQuery) error {
 
 
 	err := x.Where(whereExpr, query.OrgId, query.PluginId).Find(&dashboards)
 	err := x.Where(whereExpr, query.OrgId, query.PluginId).Find(&dashboards)
 	query.Result = dashboards
 	query.Result = dashboards
-
-	if err != nil {
-		return err
-	}
-
-	return nil
+	return err
 }
 }
 
 
 type DashboardSlugDTO struct {
 type DashboardSlugDTO struct {
@@ -451,7 +441,7 @@ func GetDashboardSlugById(query *m.GetDashboardSlugByIdQuery) error {
 
 
 	if err != nil {
 	if err != nil {
 		return err
 		return err
-	} else if exists == false {
+	} else if !exists {
 		return m.ErrDashboardNotFound
 		return m.ErrDashboardNotFound
 	}
 	}
 
 
@@ -479,7 +469,7 @@ func GetDashboardUIDById(query *m.GetDashboardRefByIdQuery) error {
 
 
 	if err != nil {
 	if err != nil {
 		return err
 		return err
-	} else if exists == false {
+	} else if !exists {
 		return m.ErrDashboardNotFound
 		return m.ErrDashboardNotFound
 	}
 	}
 
 
@@ -569,7 +559,7 @@ func getExistingDashboardByIdOrUidForUpdate(sess *DBSession, cmd *m.ValidateDash
 	}
 	}
 
 
 	// do not allow plugin dashboard updates without overwrite flag
 	// do not allow plugin dashboard updates without overwrite flag
-	if existing.PluginId != "" && cmd.Overwrite == false {
+	if existing.PluginId != "" && !cmd.Overwrite {
 		return m.UpdatePluginDashboardError{PluginId: existing.PluginId}
 		return m.UpdatePluginDashboardError{PluginId: existing.PluginId}
 	}
 	}
 
 

+ 2 - 4
pkg/services/sqlstore/dashboard_acl.go

@@ -35,10 +35,8 @@ func UpdateDashboardAcl(cmd *m.UpdateDashboardAclCommand) error {
 
 
 		// Update dashboard HasAcl flag
 		// Update dashboard HasAcl flag
 		dashboard := m.Dashboard{HasAcl: true}
 		dashboard := m.Dashboard{HasAcl: true}
-		if _, err := sess.Cols("has_acl").Where("id=?", cmd.DashboardId).Update(&dashboard); err != nil {
-			return err
-		}
-		return nil
+		_, err = sess.Cols("has_acl").Where("id=?", cmd.DashboardId).Update(&dashboard)
+		return err
 	})
 	})
 }
 }
 
 

+ 1 - 1
pkg/services/sqlstore/dashboard_snapshot.go

@@ -80,7 +80,7 @@ func GetDashboardSnapshot(query *m.GetDashboardSnapshotQuery) error {
 
 
 	if err != nil {
 	if err != nil {
 		return err
 		return err
-	} else if has == false {
+	} else if !has {
 		return m.ErrDashboardSnapshotNotFound
 		return m.ErrDashboardSnapshotNotFound
 	}
 	}
 
 

+ 2 - 4
pkg/services/sqlstore/migrator/dialect.go

@@ -84,8 +84,7 @@ func (db *BaseDialect) DateTimeFunc(value string) string {
 }
 }
 
 
 func (b *BaseDialect) CreateTableSql(table *Table) string {
 func (b *BaseDialect) CreateTableSql(table *Table) string {
-	var sql string
-	sql = "CREATE TABLE IF NOT EXISTS "
+	sql := "CREATE TABLE IF NOT EXISTS "
 	sql += b.dialect.Quote(table.Name) + " (\n"
 	sql += b.dialect.Quote(table.Name) + " (\n"
 
 
 	pkList := table.PrimaryKeys
 	pkList := table.PrimaryKeys
@@ -162,8 +161,7 @@ func (db *BaseDialect) RenameTable(oldName string, newName string) string {
 
 
 func (db *BaseDialect) DropIndexSql(tableName string, index *Index) string {
 func (db *BaseDialect) DropIndexSql(tableName string, index *Index) string {
 	quote := db.dialect.Quote
 	quote := db.dialect.Quote
-	var name string
-	name = index.XName(tableName)
+	name := index.XName(tableName)
 	return fmt.Sprintf("DROP INDEX %v ON %s", quote(name), quote(tableName))
 	return fmt.Sprintf("DROP INDEX %v ON %s", quote(name), quote(tableName))
 }
 }
 
 

+ 1 - 2
pkg/services/sqlstore/migrator/migrations.go

@@ -1,7 +1,6 @@
 package migrator
 package migrator
 
 
 import (
 import (
-	"fmt"
 	"strings"
 	"strings"
 )
 )
 
 
@@ -113,7 +112,7 @@ func NewDropIndexMigration(table Table, index *Index) *DropIndexMigration {
 
 
 func (m *DropIndexMigration) Sql(dialect Dialect) string {
 func (m *DropIndexMigration) Sql(dialect Dialect) string {
 	if m.index.Name == "" {
 	if m.index.Name == "" {
-		m.index.Name = fmt.Sprintf("%s", strings.Join(m.index.Cols, "_"))
+		m.index.Name = strings.Join(m.index.Cols, "_")
 	}
 	}
 	return dialect.DropIndexSql(m.tableName, m.index)
 	return dialect.DropIndexSql(m.tableName, m.index)
 }
 }

+ 1 - 1
pkg/services/sqlstore/migrator/types.go

@@ -46,7 +46,7 @@ type Index struct {
 
 
 func (index *Index) XName(tableName string) string {
 func (index *Index) XName(tableName string) string {
 	if index.Name == "" {
 	if index.Name == "" {
-		index.Name = fmt.Sprintf("%s", strings.Join(index.Cols, "_"))
+		index.Name = strings.Join(index.Cols, "_")
 	}
 	}
 
 
 	if !strings.HasPrefix(index.Name, "UQE_") &&
 	if !strings.HasPrefix(index.Name, "UQE_") &&

+ 1 - 1
pkg/services/sqlstore/plugin_setting.go

@@ -36,7 +36,7 @@ func GetPluginSettingById(query *m.GetPluginSettingByIdQuery) error {
 	has, err := x.Get(&pluginSetting)
 	has, err := x.Get(&pluginSetting)
 	if err != nil {
 	if err != nil {
 		return err
 		return err
-	} else if has == false {
+	} else if !has {
 		return m.ErrPluginSettingNotFound
 		return m.ErrPluginSettingNotFound
 	}
 	}
 	query.Result = &pluginSetting
 	query.Result = &pluginSetting

+ 4 - 4
pkg/services/sqlstore/quota.go

@@ -31,7 +31,7 @@ func GetOrgQuotaByTarget(query *m.GetOrgQuotaByTargetQuery) error {
 	has, err := x.Get(&quota)
 	has, err := x.Get(&quota)
 	if err != nil {
 	if err != nil {
 		return err
 		return err
-	} else if has == false {
+	} else if !has {
 		quota.Limit = query.Default
 		quota.Limit = query.Default
 	}
 	}
 
 
@@ -108,7 +108,7 @@ func UpdateOrgQuota(cmd *m.UpdateOrgQuotaCmd) error {
 			return err
 			return err
 		}
 		}
 		quota.Limit = cmd.Limit
 		quota.Limit = cmd.Limit
-		if has == false {
+		if !has {
 			quota.Created = time.Now()
 			quota.Created = time.Now()
 			//No quota in the DB for this target, so create a new one.
 			//No quota in the DB for this target, so create a new one.
 			if _, err := sess.Insert(&quota); err != nil {
 			if _, err := sess.Insert(&quota); err != nil {
@@ -133,7 +133,7 @@ func GetUserQuotaByTarget(query *m.GetUserQuotaByTargetQuery) error {
 	has, err := x.Get(&quota)
 	has, err := x.Get(&quota)
 	if err != nil {
 	if err != nil {
 		return err
 		return err
-	} else if has == false {
+	} else if !has {
 		quota.Limit = query.Default
 		quota.Limit = query.Default
 	}
 	}
 
 
@@ -210,7 +210,7 @@ func UpdateUserQuota(cmd *m.UpdateUserQuotaCmd) error {
 			return err
 			return err
 		}
 		}
 		quota.Limit = cmd.Limit
 		quota.Limit = cmd.Limit
-		if has == false {
+		if !has {
 			quota.Created = time.Now()
 			quota.Created = time.Now()
 			//No quota in the DB for this target, so create a new one.
 			//No quota in the DB for this target, so create a new one.
 			if _, err := sess.Insert(&quota); err != nil {
 			if _, err := sess.Insert(&quota); err != nil {

+ 0 - 4
pkg/services/sqlstore/stats.go

@@ -19,10 +19,6 @@ func GetDataSourceStats(query *m.GetDataSourceStatsQuery) error {
 	var rawSql = `SELECT COUNT(*) as count, type FROM data_source GROUP BY type`
 	var rawSql = `SELECT COUNT(*) as count, type FROM data_source GROUP BY type`
 	query.Result = make([]*m.DataSourceStats, 0)
 	query.Result = make([]*m.DataSourceStats, 0)
 	err := x.SQL(rawSql).Find(&query.Result)
 	err := x.SQL(rawSql).Find(&query.Result)
-	if err != nil {
-		return err
-	}
-
 	return err
 	return err
 }
 }
 
 

+ 1 - 5
pkg/services/sqlstore/team.go

@@ -210,11 +210,7 @@ func GetTeamsByUser(query *m.GetTeamsByUserQuery) error {
 	sess.Where("team.org_id=? and team_member.user_id=?", query.OrgId, query.UserId)
 	sess.Where("team.org_id=? and team_member.user_id=?", query.OrgId, query.UserId)
 
 
 	err := sess.Find(&query.Result)
 	err := sess.Find(&query.Result)
-	if err != nil {
-		return err
-	}
-
-	return nil
+	return err
 }
 }
 
 
 // AddTeamMember adds a user to a team
 // AddTeamMember adds a user to a team

+ 1 - 1
pkg/services/sqlstore/temp_user.go

@@ -126,7 +126,7 @@ func GetTempUserByCode(query *m.GetTempUserByCodeQuery) error {
 
 
 	if err != nil {
 	if err != nil {
 		return err
 		return err
-	} else if has == false {
+	} else if !has {
 		return m.ErrTempUserNotFound
 		return m.ErrTempUserNotFound
 	}
 	}
 
 

+ 11 - 20
pkg/services/sqlstore/user.go

@@ -154,7 +154,7 @@ func GetUserById(query *m.GetUserByIdQuery) error {
 
 
 	if err != nil {
 	if err != nil {
 		return err
 		return err
-	} else if has == false {
+	} else if !has {
 		return m.ErrUserNotFound
 		return m.ErrUserNotFound
 	}
 	}
 
 
@@ -179,7 +179,7 @@ func GetUserByLogin(query *m.GetUserByLoginQuery) error {
 		return err
 		return err
 	}
 	}
 
 
-	if has == false && strings.Contains(query.LoginOrEmail, "@") {
+	if !has && strings.Contains(query.LoginOrEmail, "@") {
 		// If the user wasn't found, and it contains an "@" fallback to finding the
 		// If the user wasn't found, and it contains an "@" fallback to finding the
 		// user by email.
 		// user by email.
 		user = &m.User{Email: query.LoginOrEmail}
 		user = &m.User{Email: query.LoginOrEmail}
@@ -188,7 +188,7 @@ func GetUserByLogin(query *m.GetUserByLoginQuery) error {
 
 
 	if err != nil {
 	if err != nil {
 		return err
 		return err
-	} else if has == false {
+	} else if !has {
 		return m.ErrUserNotFound
 		return m.ErrUserNotFound
 	}
 	}
 
 
@@ -209,7 +209,7 @@ func GetUserByEmail(query *m.GetUserByEmailQuery) error {
 
 
 	if err != nil {
 	if err != nil {
 		return err
 		return err
-	} else if has == false {
+	} else if !has {
 		return m.ErrUserNotFound
 		return m.ErrUserNotFound
 	}
 	}
 
 
@@ -253,11 +253,8 @@ func ChangeUserPassword(cmd *m.ChangeUserPasswordCommand) error {
 			Updated:  time.Now(),
 			Updated:  time.Now(),
 		}
 		}
 
 
-		if _, err := sess.Id(cmd.UserId).Update(&user); err != nil {
-			return err
-		}
-
-		return nil
+		_, err := sess.Id(cmd.UserId).Update(&user)
+		return err
 	})
 	})
 }
 }
 
 
@@ -271,11 +268,8 @@ func UpdateUserLastSeenAt(cmd *m.UpdateUserLastSeenAtCommand) error {
 			LastSeenAt: time.Now(),
 			LastSeenAt: time.Now(),
 		}
 		}
 
 
-		if _, err := sess.Id(cmd.UserId).Update(&user); err != nil {
-			return err
-		}
-
-		return nil
+		_, err := sess.Id(cmd.UserId).Update(&user)
+		return err
 	})
 	})
 }
 }
 
 
@@ -310,7 +304,7 @@ func GetUserProfile(query *m.GetUserProfileQuery) error {
 
 
 	if err != nil {
 	if err != nil {
 		return err
 		return err
-	} else if has == false {
+	} else if !has {
 		return m.ErrUserNotFound
 		return m.ErrUserNotFound
 	}
 	}
 
 
@@ -479,10 +473,7 @@ func SetUserHelpFlag(cmd *m.SetUserHelpFlagCommand) error {
 			Updated:    time.Now(),
 			Updated:    time.Now(),
 		}
 		}
 
 
-		if _, err := sess.Id(cmd.UserId).Cols("help_flags1").Update(&user); err != nil {
-			return err
-		}
-
-		return nil
+		_, err := sess.Id(cmd.UserId).Cols("help_flags1").Update(&user)
+		return err
 	})
 	})
 }
 }

+ 1 - 1
pkg/social/generic_oauth.go

@@ -182,7 +182,7 @@ func (s *SocialGenericOAuth) UserInfo(client *http.Client, token *oauth2.Token)
 	var data UserInfoJson
 	var data UserInfoJson
 	var err error
 	var err error
 
 
-	if s.extractToken(&data, token) != true {
+	if !s.extractToken(&data, token) {
 		response, err := HttpGet(client, s.apiUrl)
 		response, err := HttpGet(client, s.apiUrl)
 		if err != nil {
 		if err != nil {
 			return nil, fmt.Errorf("Error getting user info: %s", err)
 			return nil, fmt.Errorf("Error getting user info: %s", err)

+ 0 - 3
pkg/tsdb/cloudwatch/cloudwatch.go

@@ -71,15 +71,12 @@ func (e *CloudWatchExecutor) Query(ctx context.Context, dsInfo *models.DataSourc
 	switch queryType {
 	switch queryType {
 	case "metricFindQuery":
 	case "metricFindQuery":
 		result, err = e.executeMetricFindQuery(ctx, queryContext)
 		result, err = e.executeMetricFindQuery(ctx, queryContext)
-		break
 	case "annotationQuery":
 	case "annotationQuery":
 		result, err = e.executeAnnotationQuery(ctx, queryContext)
 		result, err = e.executeAnnotationQuery(ctx, queryContext)
-		break
 	case "timeSeriesQuery":
 	case "timeSeriesQuery":
 		fallthrough
 		fallthrough
 	default:
 	default:
 		result, err = e.executeTimeSeriesQuery(ctx, queryContext)
 		result, err = e.executeTimeSeriesQuery(ctx, queryContext)
-		break
 	}
 	}
 
 
 	return result, err
 	return result, err

+ 4 - 15
pkg/tsdb/cloudwatch/metric_find_query.go

@@ -175,25 +175,18 @@ func (e *CloudWatchExecutor) executeMetricFindQuery(ctx context.Context, queryCo
 	switch subType {
 	switch subType {
 	case "regions":
 	case "regions":
 		data, err = e.handleGetRegions(ctx, parameters, queryContext)
 		data, err = e.handleGetRegions(ctx, parameters, queryContext)
-		break
 	case "namespaces":
 	case "namespaces":
 		data, err = e.handleGetNamespaces(ctx, parameters, queryContext)
 		data, err = e.handleGetNamespaces(ctx, parameters, queryContext)
-		break
 	case "metrics":
 	case "metrics":
 		data, err = e.handleGetMetrics(ctx, parameters, queryContext)
 		data, err = e.handleGetMetrics(ctx, parameters, queryContext)
-		break
 	case "dimension_keys":
 	case "dimension_keys":
 		data, err = e.handleGetDimensions(ctx, parameters, queryContext)
 		data, err = e.handleGetDimensions(ctx, parameters, queryContext)
-		break
 	case "dimension_values":
 	case "dimension_values":
 		data, err = e.handleGetDimensionValues(ctx, parameters, queryContext)
 		data, err = e.handleGetDimensionValues(ctx, parameters, queryContext)
-		break
 	case "ebs_volume_ids":
 	case "ebs_volume_ids":
 		data, err = e.handleGetEbsVolumeIds(ctx, parameters, queryContext)
 		data, err = e.handleGetEbsVolumeIds(ctx, parameters, queryContext)
-		break
 	case "ec2_instance_attribute":
 	case "ec2_instance_attribute":
 		data, err = e.handleGetEc2InstanceAttribute(ctx, parameters, queryContext)
 		data, err = e.handleGetEc2InstanceAttribute(ctx, parameters, queryContext)
-		break
 	}
 	}
 
 
 	transformToTable(data, queryResult)
 	transformToTable(data, queryResult)
@@ -261,7 +254,7 @@ func (e *CloudWatchExecutor) handleGetNamespaces(ctx context.Context, parameters
 		keys = append(keys, strings.Split(customNamespaces, ",")...)
 		keys = append(keys, strings.Split(customNamespaces, ",")...)
 	}
 	}
 
 
-	sort.Sort(sort.StringSlice(keys))
+	sort.Strings(keys)
 
 
 	result := make([]suggestData, 0)
 	result := make([]suggestData, 0)
 	for _, key := range keys {
 	for _, key := range keys {
@@ -290,7 +283,7 @@ func (e *CloudWatchExecutor) handleGetMetrics(ctx context.Context, parameters *s
 			return nil, errors.New("Unable to call AWS API")
 			return nil, errors.New("Unable to call AWS API")
 		}
 		}
 	}
 	}
-	sort.Sort(sort.StringSlice(namespaceMetrics))
+	sort.Strings(namespaceMetrics)
 
 
 	result := make([]suggestData, 0)
 	result := make([]suggestData, 0)
 	for _, name := range namespaceMetrics {
 	for _, name := range namespaceMetrics {
@@ -319,7 +312,7 @@ func (e *CloudWatchExecutor) handleGetDimensions(ctx context.Context, parameters
 			return nil, errors.New("Unable to call AWS API")
 			return nil, errors.New("Unable to call AWS API")
 		}
 		}
 	}
 	}
-	sort.Sort(sort.StringSlice(dimensionValues))
+	sort.Strings(dimensionValues)
 
 
 	result := make([]suggestData, 0)
 	result := make([]suggestData, 0)
 	for _, name := range dimensionValues {
 	for _, name := range dimensionValues {
@@ -573,11 +566,7 @@ func getAllMetrics(cwData *DatasourceInfo) (cloudwatch.ListMetricsOutput, error)
 			}
 			}
 			return !lastPage
 			return !lastPage
 		})
 		})
-	if err != nil {
-		return resp, err
-	}
-
-	return resp, nil
+	return resp, err
 }
 }
 
 
 var metricsCacheLock sync.Mutex
 var metricsCacheLock sync.Mutex

+ 1 - 4
pkg/tsdb/cloudwatch/metric_find_query_test.go

@@ -181,10 +181,7 @@ func TestCloudWatchMetrics(t *testing.T) {
 }
 }
 
 
 func TestParseMultiSelectValue(t *testing.T) {
 func TestParseMultiSelectValue(t *testing.T) {
-
-	var values []string
-
-	values = parseMultiSelectValue(" i-someInstance ")
+	values := parseMultiSelectValue(" i-someInstance ")
 	assert.Equal(t, []string{"i-someInstance"}, values)
 	assert.Equal(t, []string{"i-someInstance"}, values)
 
 
 	values = parseMultiSelectValue("{i-05}")
 	values = parseMultiSelectValue("{i-05}")

+ 5 - 5
pkg/tsdb/mssql/mssql.go

@@ -145,7 +145,7 @@ func (e MssqlQueryEndpoint) getTypedRowData(types []*sql.ColumnType, rows *core.
 	// convert types not handled by denisenkom/go-mssqldb
 	// convert types not handled by denisenkom/go-mssqldb
 	// unhandled types are returned as []byte
 	// unhandled types are returned as []byte
 	for i := 0; i < len(types); i++ {
 	for i := 0; i < len(types); i++ {
-		if value, ok := values[i].([]byte); ok == true {
+		if value, ok := values[i].([]byte); ok {
 			switch types[i].DatabaseTypeName() {
 			switch types[i].DatabaseTypeName() {
 			case "MONEY", "SMALLMONEY", "DECIMAL":
 			case "MONEY", "SMALLMONEY", "DECIMAL":
 				if v, err := strconv.ParseFloat(string(value), 64); err == nil {
 				if v, err := strconv.ParseFloat(string(value), 64); err == nil {
@@ -209,7 +209,7 @@ func (e MssqlQueryEndpoint) transformToTimeSeries(query *tsdb.Query, rows *core.
 	fillValue := null.Float{}
 	fillValue := null.Float{}
 	if fillMissing {
 	if fillMissing {
 		fillInterval = query.Model.Get("fillInterval").MustFloat64() * 1000
 		fillInterval = query.Model.Get("fillInterval").MustFloat64() * 1000
-		if query.Model.Get("fillNull").MustBool(false) == false {
+		if !query.Model.Get("fillNull").MustBool(false) {
 			fillValue.Float64 = query.Model.Get("fillValue").MustFloat64()
 			fillValue.Float64 = query.Model.Get("fillValue").MustFloat64()
 			fillValue.Valid = true
 			fillValue.Valid = true
 		}
 		}
@@ -244,7 +244,7 @@ func (e MssqlQueryEndpoint) transformToTimeSeries(query *tsdb.Query, rows *core.
 		}
 		}
 
 
 		if metricIndex >= 0 {
 		if metricIndex >= 0 {
-			if columnValue, ok := values[metricIndex].(string); ok == true {
+			if columnValue, ok := values[metricIndex].(string); ok {
 				metric = columnValue
 				metric = columnValue
 			} else {
 			} else {
 				return fmt.Errorf("Column metric must be of type CHAR, VARCHAR, NCHAR or NVARCHAR. metric column name: %s type: %s but datatype is %T", columnNames[metricIndex], columnTypes[metricIndex].DatabaseTypeName(), values[metricIndex])
 				return fmt.Errorf("Column metric must be of type CHAR, VARCHAR, NCHAR or NVARCHAR. metric column name: %s type: %s but datatype is %T", columnNames[metricIndex], columnTypes[metricIndex].DatabaseTypeName(), values[metricIndex])
@@ -271,7 +271,7 @@ func (e MssqlQueryEndpoint) transformToTimeSeries(query *tsdb.Query, rows *core.
 			}
 			}
 
 
 			series, exist := pointsBySeries[metric]
 			series, exist := pointsBySeries[metric]
-			if exist == false {
+			if !exist {
 				series = &tsdb.TimeSeries{Name: metric}
 				series = &tsdb.TimeSeries{Name: metric}
 				pointsBySeries[metric] = series
 				pointsBySeries[metric] = series
 				seriesByQueryOrder.PushBack(metric)
 				seriesByQueryOrder.PushBack(metric)
@@ -279,7 +279,7 @@ func (e MssqlQueryEndpoint) transformToTimeSeries(query *tsdb.Query, rows *core.
 
 
 			if fillMissing {
 			if fillMissing {
 				var intervalStart float64
 				var intervalStart float64
-				if exist == false {
+				if !exist {
 					intervalStart = float64(tsdbQuery.TimeRange.MustGetFrom().UnixNano() / 1e6)
 					intervalStart = float64(tsdbQuery.TimeRange.MustGetFrom().UnixNano() / 1e6)
 				} else {
 				} else {
 					intervalStart = series.Points[len(series.Points)-1][1].Float64 + fillInterval
 					intervalStart = series.Points[len(series.Points)-1][1].Float64 + fillInterval

+ 4 - 4
pkg/tsdb/mysql/mysql.go

@@ -218,7 +218,7 @@ func (e MysqlQueryEndpoint) transformToTimeSeries(query *tsdb.Query, rows *core.
 	fillValue := null.Float{}
 	fillValue := null.Float{}
 	if fillMissing {
 	if fillMissing {
 		fillInterval = query.Model.Get("fillInterval").MustFloat64() * 1000
 		fillInterval = query.Model.Get("fillInterval").MustFloat64() * 1000
-		if query.Model.Get("fillNull").MustBool(false) == false {
+		if !query.Model.Get("fillNull").MustBool(false) {
 			fillValue.Float64 = query.Model.Get("fillValue").MustFloat64()
 			fillValue.Float64 = query.Model.Get("fillValue").MustFloat64()
 			fillValue.Valid = true
 			fillValue.Valid = true
 		}
 		}
@@ -253,7 +253,7 @@ func (e MysqlQueryEndpoint) transformToTimeSeries(query *tsdb.Query, rows *core.
 		}
 		}
 
 
 		if metricIndex >= 0 {
 		if metricIndex >= 0 {
-			if columnValue, ok := values[metricIndex].(string); ok == true {
+			if columnValue, ok := values[metricIndex].(string); ok {
 				metric = columnValue
 				metric = columnValue
 			} else {
 			} else {
 				return fmt.Errorf("Column metric must be of type char,varchar or text, got: %T %v", values[metricIndex], values[metricIndex])
 				return fmt.Errorf("Column metric must be of type char,varchar or text, got: %T %v", values[metricIndex], values[metricIndex])
@@ -280,7 +280,7 @@ func (e MysqlQueryEndpoint) transformToTimeSeries(query *tsdb.Query, rows *core.
 			}
 			}
 
 
 			series, exist := pointsBySeries[metric]
 			series, exist := pointsBySeries[metric]
-			if exist == false {
+			if !exist {
 				series = &tsdb.TimeSeries{Name: metric}
 				series = &tsdb.TimeSeries{Name: metric}
 				pointsBySeries[metric] = series
 				pointsBySeries[metric] = series
 				seriesByQueryOrder.PushBack(metric)
 				seriesByQueryOrder.PushBack(metric)
@@ -288,7 +288,7 @@ func (e MysqlQueryEndpoint) transformToTimeSeries(query *tsdb.Query, rows *core.
 
 
 			if fillMissing {
 			if fillMissing {
 				var intervalStart float64
 				var intervalStart float64
-				if exist == false {
+				if !exist {
 					intervalStart = float64(tsdbQuery.TimeRange.MustGetFrom().UnixNano() / 1e6)
 					intervalStart = float64(tsdbQuery.TimeRange.MustGetFrom().UnixNano() / 1e6)
 				} else {
 				} else {
 					intervalStart = series.Points[len(series.Points)-1][1].Float64 + fillInterval
 					intervalStart = series.Points[len(series.Points)-1][1].Float64 + fillInterval

+ 5 - 5
pkg/tsdb/postgres/postgres.go

@@ -131,7 +131,7 @@ func (e PostgresQueryEndpoint) getTypedRowData(rows *core.Rows) (tsdb.RowValues,
 	// convert types not handled by lib/pq
 	// convert types not handled by lib/pq
 	// unhandled types are returned as []byte
 	// unhandled types are returned as []byte
 	for i := 0; i < len(types); i++ {
 	for i := 0; i < len(types); i++ {
-		if value, ok := values[i].([]byte); ok == true {
+		if value, ok := values[i].([]byte); ok {
 			switch types[i].DatabaseTypeName() {
 			switch types[i].DatabaseTypeName() {
 			case "NUMERIC":
 			case "NUMERIC":
 				if v, err := strconv.ParseFloat(string(value), 64); err == nil {
 				if v, err := strconv.ParseFloat(string(value), 64); err == nil {
@@ -198,7 +198,7 @@ func (e PostgresQueryEndpoint) transformToTimeSeries(query *tsdb.Query, rows *co
 	fillValue := null.Float{}
 	fillValue := null.Float{}
 	if fillMissing {
 	if fillMissing {
 		fillInterval = query.Model.Get("fillInterval").MustFloat64() * 1000
 		fillInterval = query.Model.Get("fillInterval").MustFloat64() * 1000
-		if query.Model.Get("fillNull").MustBool(false) == false {
+		if !query.Model.Get("fillNull").MustBool(false) {
 			fillValue.Float64 = query.Model.Get("fillValue").MustFloat64()
 			fillValue.Float64 = query.Model.Get("fillValue").MustFloat64()
 			fillValue.Valid = true
 			fillValue.Valid = true
 		}
 		}
@@ -233,7 +233,7 @@ func (e PostgresQueryEndpoint) transformToTimeSeries(query *tsdb.Query, rows *co
 		}
 		}
 
 
 		if metricIndex >= 0 {
 		if metricIndex >= 0 {
-			if columnValue, ok := values[metricIndex].(string); ok == true {
+			if columnValue, ok := values[metricIndex].(string); ok {
 				metric = columnValue
 				metric = columnValue
 			} else {
 			} else {
 				return fmt.Errorf("Column metric must be of type char,varchar or text, got: %T %v", values[metricIndex], values[metricIndex])
 				return fmt.Errorf("Column metric must be of type char,varchar or text, got: %T %v", values[metricIndex], values[metricIndex])
@@ -260,7 +260,7 @@ func (e PostgresQueryEndpoint) transformToTimeSeries(query *tsdb.Query, rows *co
 			}
 			}
 
 
 			series, exist := pointsBySeries[metric]
 			series, exist := pointsBySeries[metric]
-			if exist == false {
+			if !exist {
 				series = &tsdb.TimeSeries{Name: metric}
 				series = &tsdb.TimeSeries{Name: metric}
 				pointsBySeries[metric] = series
 				pointsBySeries[metric] = series
 				seriesByQueryOrder.PushBack(metric)
 				seriesByQueryOrder.PushBack(metric)
@@ -268,7 +268,7 @@ func (e PostgresQueryEndpoint) transformToTimeSeries(query *tsdb.Query, rows *co
 
 
 			if fillMissing {
 			if fillMissing {
 				var intervalStart float64
 				var intervalStart float64
-				if exist == false {
+				if !exist {
 					intervalStart = float64(tsdbQuery.TimeRange.MustGetFrom().UnixNano() / 1e6)
 					intervalStart = float64(tsdbQuery.TimeRange.MustGetFrom().UnixNano() / 1e6)
 				} else {
 				} else {
 					intervalStart = series.Points[len(series.Points)-1][1].Float64 + fillInterval
 					intervalStart = series.Points[len(series.Points)-1][1].Float64 + fillInterval

+ 1 - 1
pkg/tsdb/sql_engine.go

@@ -51,7 +51,7 @@ func (e *DefaultSqlEngine) InitEngine(driverName string, dsInfo *models.DataSour
 	defer engineCache.Unlock()
 	defer engineCache.Unlock()
 
 
 	if engine, present := engineCache.cache[dsInfo.Id]; present {
 	if engine, present := engineCache.cache[dsInfo.Id]; present {
-		if version, _ := engineCache.versions[dsInfo.Id]; version == dsInfo.Version {
+		if version := engineCache.versions[dsInfo.Id]; version == dsInfo.Version {
 			e.XormEngine = engine
 			e.XormEngine = engine
 			return nil
 			return nil
 		}
 		}

+ 1 - 5
pkg/util/shortid_generator.go

@@ -17,11 +17,7 @@ func init() {
 
 
 // IsValidShortUid checks if short unique identifier contains valid characters
 // IsValidShortUid checks if short unique identifier contains valid characters
 func IsValidShortUid(uid string) bool {
 func IsValidShortUid(uid string) bool {
-	if !validUidPattern(uid) {
-		return false
-	}
-
-	return true
+	return validUidPattern(uid)
 }
 }
 
 
 // GenerateShortUid generates a short unique identifier.
 // GenerateShortUid generates a short unique identifier.