Commit b7adf285 by Karsten Weiss

Remove redundancy in variable declarations (golint)

This commit fixes the following golint warnings:
pkg/api/avatar/avatar.go:229:12: should omit type *http.Client from declaration of var client; it will be inferred from the right-hand side
pkg/login/brute_force_login_protection.go:13:26: should omit type time.Duration from declaration of var loginAttemptsWindow; it will be inferred from the right-hand side
pkg/metrics/graphitebridge/graphite.go:58:26: should omit type []string from declaration of var metricCategoryPrefix; it will be inferred from the right-hand side
pkg/metrics/graphitebridge/graphite.go:69:22: should omit type []string from declaration of var trimMetricPrefix; it will be inferred from the right-hand side
pkg/models/alert.go:37:36: should omit type error from declaration of var ErrCannotChangeStateOnPausedAlert; it will be inferred from the right-hand side
pkg/models/alert.go:38:36: should omit type error from declaration of var ErrRequiresNewState; it will be inferred from the right-hand side
pkg/models/datasource.go:61:28: should omit type map[string]bool from declaration of var knownDatasourcePlugins; it will be inferred from the right-hand side
pkg/plugins/update_checker.go:16:13: should omit type http.Client from declaration of var httpClient; it will be inferred from the right-hand side
pkg/services/alerting/engine.go:103:24: should omit type time.Duration from declaration of var unfinishedWorkTimeout; it will be inferred from the right-hand side
pkg/services/alerting/engine.go:105:19: should omit type time.Duration from declaration of var alertTimeout; it will be inferred from the right-hand side
pkg/services/alerting/engine.go:106:19: should omit type int from declaration of var alertMaxAttempts; it will be inferred from the right-hand side
pkg/services/alerting/notifier.go:143:23: should omit type map[string]*NotifierPlugin from declaration of var notifierFactories; it will be inferred from the right-hand side
pkg/services/alerting/rule.go:136:24: should omit type map[string]ConditionFactory from declaration of var conditionFactories; it will be inferred from the right-hand side
pkg/services/alerting/conditions/evaluator.go:12:15: should omit type []string from declaration of var defaultTypes; it will be inferred from the right-hand side
pkg/services/alerting/conditions/evaluator.go:13:15: should omit type []string from declaration of var rangedTypes; it will be inferred from the right-hand side
pkg/services/alerting/notifiers/opsgenie.go:44:19: should omit type string from declaration of var opsgenieAlertURL; it will be inferred from the right-hand side
pkg/services/alerting/notifiers/pagerduty.go:43:23: should omit type string from declaration of var pagerdutyEventApiUrl; it will be inferred from the right-hand side
pkg/services/alerting/notifiers/telegram.go:21:17: should omit type string from declaration of var telegramApiUrl; it will be inferred from the right-hand side
pkg/services/provisioning/dashboards/config_reader_test.go:11:24: should omit type string from declaration of var simpleDashboardConfig; it will be inferred from the right-hand side
pkg/services/provisioning/dashboards/config_reader_test.go:12:24: should omit type string from declaration of var oldVersion; it will be inferred from the right-hand side
pkg/services/provisioning/dashboards/config_reader_test.go:13:24: should omit type string from declaration of var brokenConfigs; it will be inferred from the right-hand side
pkg/services/provisioning/dashboards/file_reader.go:22:30: should omit type time.Duration from declaration of var checkDiskForChangesInterval; it will be inferred from the right-hand side
pkg/services/provisioning/dashboards/file_reader.go:24:23: should omit type error from declaration of var ErrFolderNameMissing; it will be inferred from the right-hand side
pkg/services/provisioning/datasources/config_reader_test.go:15:34: should omit type string from declaration of var twoDatasourcesConfig; it will be inferred from the right-hand side
pkg/services/provisioning/datasources/config_reader_test.go:16:34: should omit type string from declaration of var twoDatasourcesConfigPurgeOthers; it will be inferred from the right-hand side
pkg/services/provisioning/datasources/config_reader_test.go:17:34: should omit type string from declaration of var doubleDatasourcesConfig; it will be inferred from the right-hand side
pkg/services/provisioning/datasources/config_reader_test.go:18:34: should omit type string from declaration of var allProperties; it will be inferred from the right-hand side
pkg/services/provisioning/datasources/config_reader_test.go:19:34: should omit type string from declaration of var versionZero; it will be inferred from the right-hand side
pkg/services/provisioning/datasources/config_reader_test.go:20:34: should omit type string from declaration of var brokenYaml; it will be inferred from the right-hand side
pkg/services/sqlstore/stats.go:16:25: should omit type time.Duration from declaration of var activeUserTimeLimit; it will be inferred from the right-hand side
pkg/services/sqlstore/migrator/mysql_dialect.go:69:14: should omit type bool from declaration of var hasLen1; it will be inferred from the right-hand side
pkg/services/sqlstore/migrator/mysql_dialect.go:70:14: should omit type bool from declaration of var hasLen2; it will be inferred from the right-hand side
pkg/services/sqlstore/migrator/postgres_dialect.go:95:14: should omit type bool from declaration of var hasLen1; it will be inferred from the right-hand side
pkg/services/sqlstore/migrator/postgres_dialect.go:96:14: should omit type bool from declaration of var hasLen2; it will be inferred from the right-hand side
pkg/setting/setting.go:42:15: should omit type string from declaration of var Env; it will be inferred from the right-hand side
pkg/setting/setting.go:161:18: should omit type bool from declaration of var LdapAllowSignup; it will be inferred from the right-hand side
pkg/setting/setting.go:473:30: should omit type bool from declaration of var skipStaticRootValidation; it will be inferred from the right-hand side
pkg/tsdb/interval.go:14:21: should omit type time.Duration from declaration of var defaultMinInterval; it will be inferred from the right-hand side
pkg/tsdb/interval.go:15:21: should omit type time.Duration from declaration of var year; it will be inferred from the right-hand side
pkg/tsdb/interval.go:16:21: should omit type time.Duration from declaration of var day; it will be inferred from the right-hand side
pkg/tsdb/cloudwatch/credentials.go:26:24: should omit type map[string]cache from declaration of var awsCredentialCache; it will be inferred from the right-hand side
pkg/tsdb/influxdb/query.go:15:27: should omit type *regexp.Regexp from declaration of var regexpOperatorPattern; it will be inferred from the right-hand side
pkg/tsdb/influxdb/query.go:16:27: should omit type *regexp.Regexp from declaration of var regexpMeasurementPattern; it will be inferred from the right-hand side
pkg/tsdb/mssql/mssql_test.go:25:14: should omit type string from declaration of var serverIP; it will be inferred from the right-hand side
parent b3531362
......@@ -226,7 +226,7 @@ func (this *thunderTask) Fetch() {
this.Done()
}
var client *http.Client = &http.Client{
var client = &http.Client{
Timeout: time.Second * 2,
Transport: &http.Transport{Proxy: http.ProxyFromEnvironment},
}
......
......@@ -9,8 +9,8 @@ import (
)
var (
maxInvalidLoginAttempts int64 = 5
loginAttemptsWindow time.Duration = time.Minute * 5
maxInvalidLoginAttempts int64 = 5
loginAttemptsWindow = time.Minute * 5
)
var validateLoginAttempts = func(username string) error {
......
......@@ -55,7 +55,7 @@ const (
AbortOnError
)
var metricCategoryPrefix []string = []string{
var metricCategoryPrefix = []string{
"proxy_",
"api_",
"page_",
......@@ -66,7 +66,7 @@ var metricCategoryPrefix []string = []string{
"go_",
"process_"}
var trimMetricPrefix []string = []string{"grafana_"}
var trimMetricPrefix = []string{"grafana_"}
// Config defines the Graphite bridge config.
type Config struct {
......
......@@ -34,8 +34,8 @@ const (
)
var (
ErrCannotChangeStateOnPausedAlert error = fmt.Errorf("Cannot change state on pause alert")
ErrRequiresNewState error = fmt.Errorf("update alert state requires a new state.")
ErrCannotChangeStateOnPausedAlert = fmt.Errorf("Cannot change state on pause alert")
ErrRequiresNewState = fmt.Errorf("update alert state requires a new state.")
)
func (s AlertStateType) IsValid() bool {
......
......@@ -58,7 +58,7 @@ type DataSource struct {
Updated time.Time
}
var knownDatasourcePlugins map[string]bool = map[string]bool{
var knownDatasourcePlugins = map[string]bool{
DS_ES: true,
DS_GRAPHITE: true,
DS_INFLUXDB: true,
......
......@@ -13,7 +13,7 @@ import (
)
var (
httpClient http.Client = http.Client{Timeout: 10 * time.Second}
httpClient = http.Client{Timeout: 10 * time.Second}
)
type GrafanaNetPlugin struct {
......
......@@ -9,8 +9,8 @@ import (
)
var (
defaultTypes []string = []string{"gt", "lt"}
rangedTypes []string = []string{"within_range", "outside_range"}
defaultTypes = []string{"gt", "lt"}
rangedTypes = []string{"within_range", "outside_range"}
)
type AlertEvaluator interface {
......
......@@ -100,10 +100,10 @@ func (e *Engine) runJobDispatcher(grafanaCtx context.Context) error {
}
var (
unfinishedWorkTimeout time.Duration = time.Second * 5
unfinishedWorkTimeout = time.Second * 5
// TODO: Make alertTimeout and alertMaxAttempts configurable in the config file.
alertTimeout time.Duration = time.Second * 30
alertMaxAttempts int = 3
alertTimeout = time.Second * 30
alertMaxAttempts = 3
)
func (e *Engine) processJobWithRetry(grafanaCtx context.Context, job *Job) error {
......
......@@ -140,7 +140,7 @@ func (n *notificationService) createNotifierFor(model *m.AlertNotification) (Not
type NotifierFactory func(notification *m.AlertNotification) (Notifier, error)
var notifierFactories map[string]*NotifierPlugin = make(map[string]*NotifierPlugin)
var notifierFactories = make(map[string]*NotifierPlugin)
func RegisterNotifier(plugin *NotifierPlugin) {
notifierFactories[plugin.Type] = plugin
......
......@@ -41,7 +41,7 @@ func init() {
}
var (
opsgenieAlertURL string = "https://api.opsgenie.com/v2/alerts"
opsgenieAlertURL = "https://api.opsgenie.com/v2/alerts"
)
func NewOpsGenieNotifier(model *m.AlertNotification) (alerting.Notifier, error) {
......
......@@ -40,7 +40,7 @@ func init() {
}
var (
pagerdutyEventApiUrl string = "https://events.pagerduty.com/v2/enqueue"
pagerdutyEventApiUrl = "https://events.pagerduty.com/v2/enqueue"
)
func NewPagerdutyNotifier(model *m.AlertNotification) (alerting.Notifier, error) {
......
......@@ -18,7 +18,7 @@ const (
)
var (
telegramApiUrl string = "https://api.telegram.org/bot%s/%s"
telegramApiUrl = "https://api.telegram.org/bot%s/%s"
)
func init() {
......
......@@ -133,7 +133,7 @@ func NewRuleFromDBAlert(ruleDef *m.Alert) (*Rule, error) {
type ConditionFactory func(model *simplejson.Json, index int) (Condition, error)
var conditionFactories map[string]ConditionFactory = make(map[string]ConditionFactory)
var conditionFactories = make(map[string]ConditionFactory)
func RegisterCondition(typeName string, factory ConditionFactory) {
conditionFactories[typeName] = factory
......
......@@ -8,9 +8,9 @@ import (
)
var (
simpleDashboardConfig string = "./test-configs/dashboards-from-disk"
oldVersion string = "./test-configs/version-0"
brokenConfigs string = "./test-configs/broken-configs"
simpleDashboardConfig = "./test-configs/dashboards-from-disk"
oldVersion = "./test-configs/version-0"
brokenConfigs = "./test-configs/broken-configs"
)
func TestDashboardsAsConfig(t *testing.T) {
......
......@@ -19,9 +19,9 @@ import (
)
var (
checkDiskForChangesInterval time.Duration = time.Second * 3
checkDiskForChangesInterval = time.Second * 3
ErrFolderNameMissing error = errors.New("Folder name missing")
ErrFolderNameMissing = errors.New("Folder name missing")
)
type fileReader struct {
......
......@@ -11,13 +11,14 @@ import (
)
var (
logger log.Logger = log.New("fake.log")
twoDatasourcesConfig string = "./test-configs/two-datasources"
twoDatasourcesConfigPurgeOthers string = "./test-configs/insert-two-delete-two"
doubleDatasourcesConfig string = "./test-configs/double-default"
allProperties string = "./test-configs/all-properties"
versionZero string = "./test-configs/version-0"
brokenYaml string = "./test-configs/broken-yaml"
logger log.Logger = log.New("fake.log")
twoDatasourcesConfig = "./test-configs/two-datasources"
twoDatasourcesConfigPurgeOthers = "./test-configs/insert-two-delete-two"
doubleDatasourcesConfig = "./test-configs/double-default"
allProperties = "./test-configs/all-properties"
versionZero = "./test-configs/version-0"
brokenYaml = "./test-configs/broken-yaml"
fakeRepo *fakeRepository
)
......
......@@ -66,8 +66,8 @@ func (db *Mysql) SqlType(c *Column) string {
res = c.Type
}
var hasLen1 bool = (c.Length > 0)
var hasLen2 bool = (c.Length2 > 0)
var hasLen1 = (c.Length > 0)
var hasLen2 = (c.Length2 > 0)
if res == DB_BigInt && !hasLen1 && !hasLen2 {
c.Length = 20
......
......@@ -92,8 +92,8 @@ func (db *Postgres) SqlType(c *Column) string {
res = t
}
var hasLen1 bool = (c.Length > 0)
var hasLen2 bool = (c.Length2 > 0)
var hasLen1 = (c.Length > 0)
var hasLen2 = (c.Length2 > 0)
if hasLen2 {
res += "(" + strconv.Itoa(c.Length) + "," + strconv.Itoa(c.Length2) + ")"
} else if hasLen1 {
......
......@@ -13,7 +13,7 @@ func init() {
bus.AddHandler("sql", GetAdminStats)
}
var activeUserTimeLimit time.Duration = time.Hour * 24 * 30
var activeUserTimeLimit = time.Hour * 24 * 30
func GetDataSourceStats(query *m.GetDataSourceStatsQuery) error {
var rawSql = `SELECT COUNT(*) as count, type FROM data_source GROUP BY type`
......
......@@ -39,7 +39,7 @@ const (
var (
// App settings.
Env string = DEV
Env = DEV
AppUrl string
AppSubUrl string
InstanceName string
......@@ -158,7 +158,7 @@ var (
// LDAP
LdapEnabled bool
LdapConfigFile string
LdapAllowSignup bool = true
LdapAllowSignup = true
// SMTP email settings
Smtp SmtpSettings
......@@ -470,7 +470,7 @@ func setHomePath(args *CommandLineArgs) {
}
}
var skipStaticRootValidation bool = false
var skipStaticRootValidation = false
func validateStaticRootPath() error {
if skipStaticRootValidation {
......
......@@ -23,7 +23,7 @@ type cache struct {
expiration *time.Time
}
var awsCredentialCache map[string]cache = make(map[string]cache)
var awsCredentialCache = make(map[string]cache)
var credentialCacheLock sync.RWMutex
func GetCredentials(dsInfo *DatasourceInfo) (*credentials.Credentials, error) {
......
......@@ -12,8 +12,8 @@ import (
)
var (
regexpOperatorPattern *regexp.Regexp = regexp.MustCompile(`^\/.*\/$`)
regexpMeasurementPattern *regexp.Regexp = regexp.MustCompile(`^\/.*\/$`)
regexpOperatorPattern = regexp.MustCompile(`^\/.*\/$`)
regexpMeasurementPattern = regexp.MustCompile(`^\/.*\/$`)
)
func (query *Query) Build(queryContext *tsdb.TsdbQuery) (string, error) {
......
......@@ -10,10 +10,10 @@ import (
)
var (
defaultRes int64 = 1500
defaultMinInterval time.Duration = 1 * time.Millisecond
year time.Duration = time.Hour * 24 * 365
day time.Duration = time.Hour * 24
defaultRes int64 = 1500
defaultMinInterval = time.Millisecond * 1
year = time.Hour * 24 * 365
day = time.Hour * 24
)
type Interval struct {
......
......@@ -22,7 +22,7 @@ import (
// There is also a dashboard.json in same directory that you can import to Grafana
// once you've created a datasource for the test server/database.
// If needed, change the variable below to the IP address of the database.
var serverIP string = "localhost"
var serverIP = "localhost"
func TestMSSQL(t *testing.T) {
SkipConvey("MSSQL", t, func() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment