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:
|
steps:
|
||||||
- checkout
|
- checkout
|
||||||
- run: 'go get -u gopkg.in/alecthomas/gometalinter.v2'
|
- 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/gordonklaus/ineffassign'
|
||||||
- run: 'go get -u github.com/opennota/check/cmd/structcheck'
|
- run: 'go get -u github.com/opennota/check/cmd/structcheck'
|
||||||
- run: 'go get -u github.com/mdempsky/unconvert'
|
- run: 'go get -u github.com/mdempsky/unconvert'
|
||||||
- run: 'go get -u github.com/opennota/check/cmd/varcheck'
|
- run: 'go get -u github.com/opennota/check/cmd/varcheck'
|
||||||
- run:
|
- run:
|
||||||
name: run linters
|
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:
|
test-frontend:
|
||||||
docker:
|
docker:
|
||||||
|
29
build.go
29
build.go
@ -16,7 +16,6 @@ import (
|
|||||||
"os/exec"
|
"os/exec"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
|
||||||
"runtime"
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@ -24,7 +23,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
versionRe = regexp.MustCompile(`-[0-9]{1,3}-g[0-9a-f]{5,10}`)
|
//versionRe = regexp.MustCompile(`-[0-9]{1,3}-g[0-9a-f]{5,10}`)
|
||||||
goarch string
|
goarch string
|
||||||
goos string
|
goos string
|
||||||
gocc string
|
gocc string
|
||||||
@ -44,14 +43,14 @@ var (
|
|||||||
isDev bool = false
|
isDev bool = false
|
||||||
)
|
)
|
||||||
|
|
||||||
const minGoVersion = 1.8
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
log.SetOutput(os.Stdout)
|
log.SetOutput(os.Stdout)
|
||||||
log.SetFlags(0)
|
log.SetFlags(0)
|
||||||
|
|
||||||
ensureGoPath()
|
ensureGoPath()
|
||||||
|
|
||||||
|
verifyGitRepoIsClean()
|
||||||
|
|
||||||
flag.StringVar(&goarch, "goarch", runtime.GOARCH, "GOARCH")
|
flag.StringVar(&goarch, "goarch", runtime.GOARCH, "GOARCH")
|
||||||
flag.StringVar(&goos, "goos", runtime.GOOS, "GOOS")
|
flag.StringVar(&goos, "goos", runtime.GOOS, "GOOS")
|
||||||
flag.StringVar(&gocc, "cc", "", "CC")
|
flag.StringVar(&gocc, "cc", "", "CC")
|
||||||
@ -352,10 +351,6 @@ func ensureGoPath() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func ChangeWorkingDir(dir string) {
|
|
||||||
os.Chdir(dir)
|
|
||||||
}
|
|
||||||
|
|
||||||
func grunt(params ...string) {
|
func grunt(params ...string) {
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" {
|
||||||
runPrint(`.\node_modules\.bin\grunt`, params...)
|
runPrint(`.\node_modules\.bin\grunt`, params...)
|
||||||
@ -492,24 +487,6 @@ func buildStamp() int64 {
|
|||||||
return s
|
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) {
|
func runError(cmd string, args ...string) ([]byte, error) {
|
||||||
ecmd := exec.Command(cmd, args...)
|
ecmd := exec.Command(cmd, args...)
|
||||||
bs, err := ecmd.CombinedOutput()
|
bs, err := ecmd.CombinedOutput()
|
||||||
|
@ -294,19 +294,3 @@ func canSave(c *m.ReqContext, repo annotations.Repository, annotationID int64) R
|
|||||||
|
|
||||||
return nil
|
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
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
type renderContextFunc func(key string) (string, error)
|
|
||||||
|
|
||||||
func AddRenderAuthKey(orgId int64, userId int64, orgRole m.RoleType) string {
|
func AddRenderAuthKey(orgId int64, userId int64, orgRole m.RoleType) string {
|
||||||
renderKeysLock.Lock()
|
renderKeysLock.Lock()
|
||||||
|
|
||||||
|
@ -2,37 +2,38 @@ package migrations
|
|||||||
|
|
||||||
import . "github.com/grafana/grafana/pkg/services/sqlstore/migrator"
|
import . "github.com/grafana/grafana/pkg/services/sqlstore/migrator"
|
||||||
|
|
||||||
func addStatsMigrations(mg *Migrator) {
|
// commented out because of the deadcode CI check
|
||||||
statTable := Table{
|
//func addStatsMigrations(mg *Migrator) {
|
||||||
Name: "stat",
|
// statTable := Table{
|
||||||
Columns: []*Column{
|
// Name: "stat",
|
||||||
{Name: "id", Type: DB_Int, IsPrimaryKey: true, IsAutoIncrement: true},
|
// Columns: []*Column{
|
||||||
{Name: "metric", Type: DB_Varchar, Length: 20, Nullable: false},
|
// {Name: "id", Type: DB_Int, IsPrimaryKey: true, IsAutoIncrement: true},
|
||||||
{Name: "type", Type: DB_Int, Nullable: false},
|
// {Name: "metric", Type: DB_Varchar, Length: 20, Nullable: false},
|
||||||
},
|
// {Name: "type", Type: DB_Int, Nullable: false},
|
||||||
Indices: []*Index{
|
// },
|
||||||
{Cols: []string{"metric"}, Type: UniqueIndex},
|
// Indices: []*Index{
|
||||||
},
|
// {Cols: []string{"metric"}, Type: UniqueIndex},
|
||||||
}
|
// },
|
||||||
|
// }
|
||||||
// create table
|
//
|
||||||
mg.AddMigration("create stat table", NewAddTableMigration(statTable))
|
// // create table
|
||||||
|
// mg.AddMigration("create stat table", NewAddTableMigration(statTable))
|
||||||
// create indices
|
//
|
||||||
mg.AddMigration("add index stat.metric", NewAddIndexMigration(statTable, statTable.Indices[0]))
|
// // create indices
|
||||||
|
// mg.AddMigration("add index stat.metric", NewAddIndexMigration(statTable, statTable.Indices[0]))
|
||||||
statValue := Table{
|
//
|
||||||
Name: "stat_value",
|
// statValue := Table{
|
||||||
Columns: []*Column{
|
// Name: "stat_value",
|
||||||
{Name: "id", Type: DB_Int, IsPrimaryKey: true, IsAutoIncrement: true},
|
// Columns: []*Column{
|
||||||
{Name: "value", Type: DB_Double, Nullable: false},
|
// {Name: "id", Type: DB_Int, IsPrimaryKey: true, IsAutoIncrement: true},
|
||||||
{Name: "time", Type: DB_DateTime, Nullable: false},
|
// {Name: "value", Type: DB_Double, Nullable: false},
|
||||||
},
|
// {Name: "time", Type: DB_DateTime, Nullable: false},
|
||||||
}
|
// },
|
||||||
|
// }
|
||||||
// create table
|
//
|
||||||
mg.AddMigration("create stat_value table", NewAddTableMigration(statValue))
|
// // create table
|
||||||
}
|
// mg.AddMigration("create stat_value table", NewAddTableMigration(statValue))
|
||||||
|
//}
|
||||||
|
|
||||||
func addTestDataMigrations(mg *Migrator) {
|
func addTestDataMigrations(mg *Migrator) {
|
||||||
testData := Table{
|
testData := Table{
|
||||||
|
Loading…
Reference in New Issue
Block a user