Commit afce0feb by bergquist

Merge branch 'mjtrangoni-fix-deadcode-issues'

* mjtrangoni-fix-deadcode-issues:
  tech: removes unused code
  add deadcode linter to circleci
  pkg: fix deadcode issues
  build.go: fix deadcode issues
parents b53a5761 8e9b3507
......@@ -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:
......
......@@ -16,7 +16,6 @@ import (
"os/exec"
"path"
"path/filepath"
"regexp"
"runtime"
"strconv"
"strings"
......@@ -24,7 +23,7 @@ import (
)
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
goos string
gocc string
......@@ -44,8 +43,6 @@ var (
isDev bool = false
)
const minGoVersion = 1.8
func main() {
log.SetOutput(os.Stdout)
log.SetFlags(0)
......@@ -326,20 +323,6 @@ func createPackage(options linuxPackageOptions) {
runPrint("fpm", append([]string{"-t", options.packageType}, args...)...)
}
func verifyGitRepoIsClean() {
rs, err := runError("git", "ls-files", "--modified")
if err != nil {
log.Fatalf("Failed to check if git tree was clean, %v, %v\n", string(rs), err)
return
}
count := len(string(rs))
if count > 0 {
log.Fatalf("Git repository has modified files, aborting")
}
log.Println("Git repository is clean")
}
func ensureGoPath() {
if os.Getenv("GOPATH") == "" {
cwd, err := os.Getwd()
......@@ -352,10 +335,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 +471,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{
......
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