diff --git a/.bra.toml b/.bra.toml index d867f3fdc80..dcf316466d6 100644 --- a/.bra.toml +++ b/.bra.toml @@ -12,6 +12,6 @@ watch_dirs = [ watch_exts = [".go", ".ini", ".toml"] build_delay = 1500 cmds = [ - ["go", "run", "build.go", "-dev", "build"], + ["go", "run", "build.go", "-dev", "build-server"], ["./bin/grafana-server", "cfg:app_mode=development"] ] diff --git a/.circleci/config.yml b/.circleci/config.yml index 2399d0c19bf..8b6d8506800 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -17,6 +17,22 @@ jobs: name: check documentation spelling errors command: 'codespell -I ./words_to_ignore.txt docs/' + gometalinter: + docker: + - image: circleci/golang:1.10 + working_directory: /go/src/github.com/grafana/grafana + steps: + - checkout + - run: + name: install gometalinter tool + command: 'go get -u github.com/alecthomas/gometalinter' + - run: + name: install linters + command: 'gometalinter --install' + - run: + name: run some linters + command: 'gometalinter --vendor --deadline 6m --disable-all --enable=structcheck --enable=unconvert --enable=varcheck ./...' + test-frontend: docker: - image: circleci/node:6.11.4 @@ -123,6 +139,10 @@ workflows: filters: tags: only: /.*/ + - gometalinter: + filters: + tags: + only: /.*/ - build: filters: tags: diff --git a/pkg/cmd/grafana-cli/commands/remove_command.go b/pkg/cmd/grafana-cli/commands/remove_command.go index d5ed73def05..e51929dc95c 100644 --- a/pkg/cmd/grafana-cli/commands/remove_command.go +++ b/pkg/cmd/grafana-cli/commands/remove_command.go @@ -3,12 +3,11 @@ package commands import ( "errors" "fmt" - m "github.com/grafana/grafana/pkg/cmd/grafana-cli/models" - services "github.com/grafana/grafana/pkg/cmd/grafana-cli/services" "strings" + + services "github.com/grafana/grafana/pkg/cmd/grafana-cli/services" ) -var getPluginss func(path string) []m.InstalledPlugin = services.GetLocalPlugins var removePlugin func(pluginPath, id string) error = services.RemoveInstalledPlugin func removeCommand(c CommandLine) error { diff --git a/pkg/cmd/grafana-server/main.go b/pkg/cmd/grafana-server/main.go index ab0e12f2d9f..777176f27da 100644 --- a/pkg/cmd/grafana-server/main.go +++ b/pkg/cmd/grafana-server/main.go @@ -33,7 +33,6 @@ import ( var version = "5.0.0" var commit = "NA" var buildstamp string -var build_date string var configFile = flag.String("config", "", "path to config file") var homePath = flag.String("homepath", "", "path to grafana install/home path, defaults to working directory") diff --git a/pkg/components/dashdiffs/compare.go b/pkg/components/dashdiffs/compare.go index f5f2104cb92..d51011fbead 100644 --- a/pkg/components/dashdiffs/compare.go +++ b/pkg/components/dashdiffs/compare.go @@ -6,7 +6,6 @@ import ( "github.com/grafana/grafana/pkg/bus" "github.com/grafana/grafana/pkg/components/simplejson" - "github.com/grafana/grafana/pkg/log" "github.com/grafana/grafana/pkg/models" diff "github.com/yudai/gojsondiff" deltaFormatter "github.com/yudai/gojsondiff/formatter" @@ -15,11 +14,8 @@ import ( var ( // ErrUnsupportedDiffType occurs when an invalid diff type is used. ErrUnsupportedDiffType = errors.New("dashdiff: unsupported diff type") - // ErrNilDiff occurs when two compared interfaces are identical. ErrNilDiff = errors.New("dashdiff: diff is nil") - - diffLogger = log.New("dashdiffs") ) type DiffType int diff --git a/pkg/services/alerting/engine.go b/pkg/services/alerting/engine.go index a6f97333d1b..0945a2a5330 100644 --- a/pkg/services/alerting/engine.go +++ b/pkg/services/alerting/engine.go @@ -15,8 +15,8 @@ import ( ) type Engine struct { - execQueue chan *Job - clock clock.Clock + execQueue chan *Job + //clock clock.Clock ticker *Ticker scheduler Scheduler evalHandler EvalHandler diff --git a/pkg/services/alerting/reader.go b/pkg/services/alerting/reader.go index 45f0c65d4fb..627159c286b 100644 --- a/pkg/services/alerting/reader.go +++ b/pkg/services/alerting/reader.go @@ -16,7 +16,7 @@ type RuleReader interface { type DefaultRuleReader struct { sync.RWMutex - serverID string + //serverID string serverPosition int clusterSize int log log.Logger diff --git a/pkg/services/notifications/webhook.go b/pkg/services/notifications/webhook.go index dff5aa4924a..0636a6adadc 100644 --- a/pkg/services/notifications/webhook.go +++ b/pkg/services/notifications/webhook.go @@ -101,7 +101,3 @@ func sendWebRequestSync(ctx context.Context, webhook *Webhook) error { webhookLog.Debug("Webhook failed", "statuscode", resp.Status, "body", string(body)) return fmt.Errorf("Webhook response status %v", resp.Status) } - -var addToWebhookQueue = func(msg *Webhook) { - webhookQueue <- msg -} diff --git a/pkg/services/provisioning/datasources/config_reader_test.go b/pkg/services/provisioning/datasources/config_reader_test.go index 3198329e0ae..7d621ffe70f 100644 --- a/pkg/services/provisioning/datasources/config_reader_test.go +++ b/pkg/services/provisioning/datasources/config_reader_test.go @@ -12,7 +12,6 @@ import ( var ( logger log.Logger = log.New("fake.log") - oneDatasourcesConfig string = "" twoDatasourcesConfig string = "./test-configs/two-datasources" twoDatasourcesConfigPurgeOthers string = "./test-configs/insert-two-delete-two" doubleDatasourcesConfig string = "./test-configs/double-default" diff --git a/pkg/services/sqlstore/migrations/migrations_test.go b/pkg/services/sqlstore/migrations/migrations_test.go index 51aea0bbdef..8e8e4af824f 100644 --- a/pkg/services/sqlstore/migrations/migrations_test.go +++ b/pkg/services/sqlstore/migrations/migrations_test.go @@ -8,11 +8,8 @@ import ( "github.com/grafana/grafana/pkg/services/sqlstore/sqlutil" . "github.com/smartystreets/goconvey/convey" - //"github.com/grafana/grafana/pkg/log" ) -var indexTypes = []string{"Unknown", "INDEX", "UNIQUE INDEX"} - func TestMigrations(t *testing.T) { testDBs := []sqlutil.TestDB{ sqlutil.TestDB_Sqlite3, diff --git a/pkg/services/sqlstore/migrator/migrations.go b/pkg/services/sqlstore/migrator/migrations.go index 5232e65d62b..4e6402a14e5 100644 --- a/pkg/services/sqlstore/migrator/migrations.go +++ b/pkg/services/sqlstore/migrator/migrations.go @@ -179,7 +179,7 @@ type CopyTableDataMigration struct { targetTable string sourceCols []string targetCols []string - colMap map[string]string + //colMap map[string]string } func NewCopyTableDataMigration(targetTable string, sourceTable string, colMap map[string]string) *CopyTableDataMigration {