mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Merge branch 'fix-deadcode-issues' of https://github.com/mjtrangoni/grafana into mjtrangoni-fix-deadcode-issues
* 'fix-deadcode-issues' of https://github.com/mjtrangoni/grafana: add deadcode linter to circleci pkg: fix deadcode issues build.go: fix deadcode issues
This commit is contained in:
commit
034f5921cc
@ -27,13 +27,14 @@ jobs:
|
||||
steps:
|
||||
- checkout
|
||||
- run: 'go get -u gopkg.in/alecthomas/gometalinter.v2'
|
||||
- run: 'go get -u github.com/tsenart/deadcode'
|
||||
- run: 'go get -u github.com/gordonklaus/ineffassign'
|
||||
- run: 'go get -u github.com/opennota/check/cmd/structcheck'
|
||||
- run: 'go get -u github.com/mdempsky/unconvert'
|
||||
- run: 'go get -u github.com/opennota/check/cmd/varcheck'
|
||||
- run:
|
||||
name: run linters
|
||||
command: 'gometalinter.v2 --enable-gc --vendor --deadline 10m --disable-all --enable=ineffassign --enable=structcheck --enable=unconvert --enable=varcheck ./...'
|
||||
command: 'gometalinter.v2 --enable-gc --vendor --deadline 10m --disable-all --enable=deadcode --enable=ineffassign --enable=structcheck --enable=unconvert --enable=varcheck ./...'
|
||||
|
||||
test-frontend:
|
||||
docker:
|
||||
|
43
build.go
43
build.go
@ -16,7 +16,6 @@ import (
|
||||
"os/exec"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
@ -24,14 +23,14 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
versionRe = regexp.MustCompile(`-[0-9]{1,3}-g[0-9a-f]{5,10}`)
|
||||
goarch string
|
||||
goos string
|
||||
gocc string
|
||||
gocxx string
|
||||
cgo string
|
||||
pkgArch string
|
||||
version string = "v1"
|
||||
//versionRe = regexp.MustCompile(`-[0-9]{1,3}-g[0-9a-f]{5,10}`)
|
||||
goarch string
|
||||
goos string
|
||||
gocc string
|
||||
gocxx string
|
||||
cgo string
|
||||
pkgArch string
|
||||
version string = "v1"
|
||||
// deb & rpm does not support semver so have to handle their version a little differently
|
||||
linuxPackageVersion string = "v1"
|
||||
linuxPackageIteration string = ""
|
||||
@ -44,14 +43,14 @@ var (
|
||||
isDev bool = false
|
||||
)
|
||||
|
||||
const minGoVersion = 1.8
|
||||
|
||||
func main() {
|
||||
log.SetOutput(os.Stdout)
|
||||
log.SetFlags(0)
|
||||
|
||||
ensureGoPath()
|
||||
|
||||
verifyGitRepoIsClean()
|
||||
|
||||
flag.StringVar(&goarch, "goarch", runtime.GOARCH, "GOARCH")
|
||||
flag.StringVar(&goos, "goos", runtime.GOOS, "GOOS")
|
||||
flag.StringVar(&gocc, "cc", "", "CC")
|
||||
@ -352,10 +351,6 @@ func ensureGoPath() {
|
||||
}
|
||||
}
|
||||
|
||||
func ChangeWorkingDir(dir string) {
|
||||
os.Chdir(dir)
|
||||
}
|
||||
|
||||
func grunt(params ...string) {
|
||||
if runtime.GOOS == "windows" {
|
||||
runPrint(`.\node_modules\.bin\grunt`, params...)
|
||||
@ -492,24 +487,6 @@ func buildStamp() int64 {
|
||||
return s
|
||||
}
|
||||
|
||||
func buildArch() string {
|
||||
os := goos
|
||||
if os == "darwin" {
|
||||
os = "macosx"
|
||||
}
|
||||
return fmt.Sprintf("%s-%s", os, goarch)
|
||||
}
|
||||
|
||||
func run(cmd string, args ...string) []byte {
|
||||
bs, err := runError(cmd, args...)
|
||||
if err != nil {
|
||||
log.Println(cmd, strings.Join(args, " "))
|
||||
log.Println(string(bs))
|
||||
log.Fatal(err)
|
||||
}
|
||||
return bytes.TrimSpace(bs)
|
||||
}
|
||||
|
||||
func runError(cmd string, args ...string) ([]byte, error) {
|
||||
ecmd := exec.Command(cmd, args...)
|
||||
bs, err := ecmd.CombinedOutput()
|
||||
|
@ -294,19 +294,3 @@ func canSave(c *m.ReqContext, repo annotations.Repository, annotationID int64) R
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func canSaveByRegionID(c *m.ReqContext, repo annotations.Repository, regionID int64) Response {
|
||||
items, err := repo.Find(&annotations.ItemQuery{RegionId: regionID, OrgId: c.OrgId})
|
||||
|
||||
if err != nil || len(items) == 0 {
|
||||
return Error(500, "Could not find annotation to update", err)
|
||||
}
|
||||
|
||||
dashboardID := items[0].DashboardId
|
||||
|
||||
if canSave, err := canSaveByDashboardID(c, dashboardID); err != nil || !canSave {
|
||||
return dashboardGuardianResponse(err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -31,8 +31,6 @@ func initContextWithRenderAuth(ctx *m.ReqContext) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
type renderContextFunc func(key string) (string, error)
|
||||
|
||||
func AddRenderAuthKey(orgId int64, userId int64, orgRole m.RoleType) string {
|
||||
renderKeysLock.Lock()
|
||||
|
||||
|
@ -2,37 +2,38 @@ package migrations
|
||||
|
||||
import . "github.com/grafana/grafana/pkg/services/sqlstore/migrator"
|
||||
|
||||
func addStatsMigrations(mg *Migrator) {
|
||||
statTable := Table{
|
||||
Name: "stat",
|
||||
Columns: []*Column{
|
||||
{Name: "id", Type: DB_Int, IsPrimaryKey: true, IsAutoIncrement: true},
|
||||
{Name: "metric", Type: DB_Varchar, Length: 20, Nullable: false},
|
||||
{Name: "type", Type: DB_Int, Nullable: false},
|
||||
},
|
||||
Indices: []*Index{
|
||||
{Cols: []string{"metric"}, Type: UniqueIndex},
|
||||
},
|
||||
}
|
||||
|
||||
// create table
|
||||
mg.AddMigration("create stat table", NewAddTableMigration(statTable))
|
||||
|
||||
// create indices
|
||||
mg.AddMigration("add index stat.metric", NewAddIndexMigration(statTable, statTable.Indices[0]))
|
||||
|
||||
statValue := Table{
|
||||
Name: "stat_value",
|
||||
Columns: []*Column{
|
||||
{Name: "id", Type: DB_Int, IsPrimaryKey: true, IsAutoIncrement: true},
|
||||
{Name: "value", Type: DB_Double, Nullable: false},
|
||||
{Name: "time", Type: DB_DateTime, Nullable: false},
|
||||
},
|
||||
}
|
||||
|
||||
// create table
|
||||
mg.AddMigration("create stat_value table", NewAddTableMigration(statValue))
|
||||
}
|
||||
// commented out because of the deadcode CI check
|
||||
//func addStatsMigrations(mg *Migrator) {
|
||||
// statTable := Table{
|
||||
// Name: "stat",
|
||||
// Columns: []*Column{
|
||||
// {Name: "id", Type: DB_Int, IsPrimaryKey: true, IsAutoIncrement: true},
|
||||
// {Name: "metric", Type: DB_Varchar, Length: 20, Nullable: false},
|
||||
// {Name: "type", Type: DB_Int, Nullable: false},
|
||||
// },
|
||||
// Indices: []*Index{
|
||||
// {Cols: []string{"metric"}, Type: UniqueIndex},
|
||||
// },
|
||||
// }
|
||||
//
|
||||
// // create table
|
||||
// mg.AddMigration("create stat table", NewAddTableMigration(statTable))
|
||||
//
|
||||
// // create indices
|
||||
// mg.AddMigration("add index stat.metric", NewAddIndexMigration(statTable, statTable.Indices[0]))
|
||||
//
|
||||
// statValue := Table{
|
||||
// Name: "stat_value",
|
||||
// Columns: []*Column{
|
||||
// {Name: "id", Type: DB_Int, IsPrimaryKey: true, IsAutoIncrement: true},
|
||||
// {Name: "value", Type: DB_Double, Nullable: false},
|
||||
// {Name: "time", Type: DB_DateTime, Nullable: false},
|
||||
// },
|
||||
// }
|
||||
//
|
||||
// // create table
|
||||
// mg.AddMigration("create stat_value table", NewAddTableMigration(statValue))
|
||||
//}
|
||||
|
||||
func addTestDataMigrations(mg *Migrator) {
|
||||
testData := Table{
|
||||
|
Loading…
Reference in New Issue
Block a user