Bladeren bron

Fix megacheck issue unused code.

I removed some code, and commented out other one.

See,
$ gometalinter --vendor --disable-all --disable=gotype --enable=megacheck --deadline 6m ./... | grep unused
pkg/api/avatar/avatar.go:100:26:warning: func (*CacheServer).mustInt is unused (U1000) (megacheck)
pkg/api/folder_test.go:136:6:warning: func callGetFolderByUID is unused (U1000) (megacheck)
pkg/api/folder_test.go:141:6:warning: func callDeleteFolder is unused (U1000) (megacheck)
pkg/api/live/hub.go:40:15:warning: func (*hub).removeConnection is unused (U1000) (megacheck)
pkg/components/imguploader/azureblobuploader.go:130:5:warning: var client is unused (U1000) (megacheck)
pkg/middleware/middleware_test.go:438:28:warning: func (*scenarioContext).withInvalidApiKey is unused (U1000) (megacheck)
pkg/services/alerting/ticker.go:40:18:warning: func (*Ticker).updateOffset is unused (U1000) (megacheck)
pkg/services/notifications/notifications_test.go:12:6:warning: type testTriggeredAlert is unused (U1000) (megacheck)
pkg/services/sqlstore/dashboard_service_integration_test.go:935:6:warning: type scenarioContext is unused (U1000) (megacheck)
pkg/services/sqlstore/dashboard_service_integration_test.go:939:6:warning: type scenarioFunc is unused (U1000) (megacheck)
pkg/services/sqlstore/dashboard_service_integration_test.go:941:6:warning: func dashboardGuardianScenario is unused (U1000) (megacheck)
pkg/services/sqlstore/transactions_test.go:13:6:warning: type testQuery is unused (U1000) (megacheck)
Mario Trangoni 7 jaren geleden
bovenliggende
commit
dde650905d

+ 0 - 9
pkg/api/avatar/avatar.go

@@ -97,15 +97,6 @@ type CacheServer struct {
 	cache    *gocache.Cache
 }
 
-func (this *CacheServer) mustInt(r *http.Request, defaultValue int, keys ...string) (v int) {
-	for _, k := range keys {
-		if _, err := fmt.Sscanf(r.FormValue(k), "%d", &v); err == nil {
-			defaultValue = v
-		}
-	}
-	return defaultValue
-}
-
 func (this *CacheServer) Handler(ctx *macaron.Context) {
 	urlPath := ctx.Req.URL.Path
 	hash := urlPath[strings.LastIndex(urlPath, "/")+1:]

+ 0 - 10
pkg/api/folder_test.go

@@ -133,16 +133,6 @@ func TestFoldersApiEndpoint(t *testing.T) {
 	})
 }
 
-func callGetFolderByUID(sc *scenarioContext) {
-	sc.handlerFunc = GetFolderByUID
-	sc.fakeReqWithParams("GET", sc.url, map[string]string{}).exec()
-}
-
-func callDeleteFolder(sc *scenarioContext) {
-	sc.handlerFunc = DeleteFolder
-	sc.fakeReqWithParams("DELETE", sc.url, map[string]string{}).exec()
-}
-
 func callCreateFolder(sc *scenarioContext) {
 	sc.fakeReqWithParams("POST", sc.url, map[string]string{}).exec()
 }

+ 0 - 3
pkg/api/live/hub.go

@@ -37,9 +37,6 @@ func newHub() *hub {
 	}
 }
 
-func (h *hub) removeConnection() {
-}
-
 func (h *hub) run(ctx context.Context) {
 	for {
 		select {

+ 0 - 2
pkg/components/imguploader/azureblobuploader.go

@@ -127,8 +127,6 @@ type xmlError struct {
 const ms_date_layout = "Mon, 02 Jan 2006 15:04:05 GMT"
 const version = "2017-04-17"
 
-var client = &http.Client{}
-
 type StorageClient struct {
 	Auth      *Auth
 	Transport http.RoundTripper

+ 0 - 5
pkg/middleware/middleware_test.go

@@ -435,11 +435,6 @@ func (sc *scenarioContext) withValidApiKey() *scenarioContext {
 	return sc
 }
 
-func (sc *scenarioContext) withInvalidApiKey() *scenarioContext {
-	sc.apiKey = "nvalidhhhhds"
-	return sc
-}
-
 func (sc *scenarioContext) withAuthorizationHeader(authHeader string) *scenarioContext {
 	sc.authHeader = authHeader
 	return sc

+ 0 - 4
pkg/services/alerting/ticker.go

@@ -37,10 +37,6 @@ func NewTicker(last time.Time, initialOffset time.Duration, c clock.Clock) *Tick
 	return t
 }
 
-func (t *Ticker) updateOffset(offset time.Duration) {
-	t.newOffset <- offset
-}
-
 func (t *Ticker) run() {
 	for {
 		next := t.last.Add(time.Duration(1) * time.Second)

+ 0 - 6
pkg/services/notifications/notifications_test.go

@@ -9,12 +9,6 @@ import (
 	. "github.com/smartystreets/goconvey/convey"
 )
 
-type testTriggeredAlert struct {
-	ActualValue float64
-	Name        string
-	State       string
-}
-
 func TestNotifications(t *testing.T) {
 
 	Convey("Given the notifications service", t, func() {

+ 0 - 23
pkg/services/sqlstore/dashboard_service_integration_test.go

@@ -932,29 +932,6 @@ func TestIntegratedDashboardService(t *testing.T) {
 	})
 }
 
-type scenarioContext struct {
-	dashboardGuardianMock *guardian.FakeDashboardGuardian
-}
-
-type scenarioFunc func(c *scenarioContext)
-
-func dashboardGuardianScenario(desc string, mock *guardian.FakeDashboardGuardian, fn scenarioFunc) {
-	Convey(desc, func() {
-		origNewDashboardGuardian := guardian.New
-		guardian.MockDashboardGuardian(mock)
-
-		sc := &scenarioContext{
-			dashboardGuardianMock: mock,
-		}
-
-		defer func() {
-			guardian.New = origNewDashboardGuardian
-		}()
-
-		fn(sc)
-	})
-}
-
 type dashboardPermissionScenarioContext struct {
 	dashboardGuardianMock *guardian.FakeDashboardGuardian
 }

+ 0 - 4
pkg/services/sqlstore/transactions_test.go

@@ -10,10 +10,6 @@ import (
 	. "github.com/smartystreets/goconvey/convey"
 )
 
-type testQuery struct {
-	result bool
-}
-
 var ProvokedError = errors.New("testing error.")
 
 func TestTransaction(t *testing.T) {