Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run unused against codebase #12968

Merged
merged 3 commits into from
Nov 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion api4/job_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func TestGetJobs(t *testing.T) {
received, resp = th.SystemAdminClient.GetJobs(1, 2)
require.Nil(t, resp.Error)

require.Equal(t,jobs[1].Id, received[0].Id, "should've received oldest job last")
require.Equal(t, jobs[1].Id, received[0].Id, "should've received oldest job last")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a gofmt fix I missed in a different PR


_, resp = th.Client.GetJobs(0, 60)
CheckForbiddenStatus(t, resp)
Expand Down
5 changes: 0 additions & 5 deletions config/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,3 @@ func UnmarshalConfig(r io.Reader, allowEnvironmentOverrides bool) (*model.Config
func InitializeConfigurationsTable(db *sqlx.DB) error {
return initializeConfigurationsTable(db)
}

// ResolveConfigFilePath exposes the internal resolveConfigFilePath to test only.
func ResolveConfigFilePath(path string) (string, error) {
return resolveConfigFilePath(path)
}
2 changes: 1 addition & 1 deletion plugin/stringifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

func stringify(objects []interface{}) []string {
stringified := make([]string, len(objects), len(objects))
stringified := make([]string, len(objects))
for i, object := range objects {
stringified[i] = fmt.Sprintf("%+v", object)
}
Expand Down
4 changes: 2 additions & 2 deletions plugin/stringifier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func TestStringify(t *testing.T) {
assert.Empty(t, strings)
})
t.Run("EmptyShouldReturnEmpty", func(t *testing.T) {
strings := stringify(make([]interface{}, 0, 0))
strings := stringify(make([]interface{}, 0))
assert.Empty(t, strings)
})
t.Run("PrimitivesAndCompositesShouldReturnCorrectValues", func(t *testing.T) {
Expand Down Expand Up @@ -83,7 +83,7 @@ func TestToObjects(t *testing.T) {
assert.Nil(t, objects)
})
t.Run("EmptyShouldReturnEmpty", func(t *testing.T) {
objects := toObjects(make([]string, 0, 0))
objects := toObjects(make([]string, 0))
assert.Empty(t, objects)
})
t.Run("ShouldReturnSliceOfObjects", func(t *testing.T) {
Expand Down
9 changes: 0 additions & 9 deletions store/layered_store_hints.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,3 @@ const (
LSH_NO_CACHE LayeredStoreHint = iota
LSH_MASTER_ONLY
)

func hintsContains(hints []LayeredStoreHint, contains LayeredStoreHint) bool {
for _, hint := range hints {
if hint == contains {
return true
}
}
return false
}
24 changes: 0 additions & 24 deletions store/local_cache_supplier.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,30 +49,6 @@ func (s *LocalCacheSupplier) Next() LayeredStoreSupplier {
return s.next
}

func (s *LocalCacheSupplier) doStandardReadCache(ctx context.Context, cache ObjectCache, key string, hints ...LayeredStoreHint) *LayeredStoreSupplierResult {
if hintsContains(hints, LSH_NO_CACHE) {
if s.metrics != nil {
s.metrics.IncrementMemCacheMissCounter(cache.Name())
}
return nil
}

if cacheItem, ok := cache.Get(key); ok {
if s.metrics != nil {
s.metrics.IncrementMemCacheHitCounter(cache.Name())
}
result := NewSupplierResult()
result.Data = cacheItem
return result
}

if s.metrics != nil {
s.metrics.IncrementMemCacheMissCounter(cache.Name())
}

return nil
}

func (s *LocalCacheSupplier) doStandardAddToCache(ctx context.Context, cache ObjectCache, key string, result *LayeredStoreSupplierResult, hints ...LayeredStoreHint) {
if result.Err == nil && result.Data != nil {
cache.AddWithDefaultExpires(key, result.Data)
Expand Down
13 changes: 0 additions & 13 deletions store/localcachelayer/layer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,6 @@ func StoreTest(t *testing.T, f func(*testing.T, store.Store)) {
}
}

func StoreTestWithSqlSupplier(t *testing.T, f func(*testing.T, store.Store, storetest.SqlSupplier)) {
defer func() {
if err := recover(); err != nil {
tearDownStores()
panic(err)
}
}()
for _, st := range storeTypes {
st := st
t.Run(st.Name, func(t *testing.T) { f(t, st.Store, st.SqlSupplier) })
}
}

func initStores() {
storeTypes = append(storeTypes, &storeType{
Name: "LocalCache+MySQL",
Expand Down
19 changes: 0 additions & 19 deletions web/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,22 +315,3 @@ func (w *Web) ApiSessionRequired(h func(*Context, http.ResponseWriter, *http.Req
}
return handler
}

// apiHandlerTrustRequester provides a handler for API endpoints which do not require the user to be logged in and are
// allowed to be requested directly rather than via javascript/XMLHttpRequest, such as site branding images or the
// websocket.
func (w *Web) apiHandlerTrustRequester(h func(*Context, http.ResponseWriter, *http.Request)) http.Handler {
handler := &Handler{
GetGlobalAppOptions: w.GetGlobalAppOptions,
HandleFunc: h,
HandlerName: GetHandlerName(h),
RequireSession: false,
TrustRequester: true,
RequireMfa: false,
IsStatic: false,
}
if *w.ConfigService.Config().ServiceSettings.WebserverMode == "gzip" {
return gziphandler.GzipHandler(handler)
}
return handler
}