Chore: Enable goprintffuncname and nakedret linters (#26376)

* Chore: Enable goprintffuncname linter
* Chore: Enable nakedret linter

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
This commit is contained in:
Arve Knudsen
2020-07-23 08:14:39 +02:00
committed by GitHub
parent 9b17fe436c
commit 4c56eb3991
22 changed files with 53 additions and 51 deletions
+1 -1
View File
@@ -48,7 +48,7 @@ func (hs *HTTPServer) initAppPluginRoutes(r *macaron.Macaron) {
}
handlers = append(handlers, AppPluginRoute(route, plugin.Id, hs))
r.Route(url, route.Method, handlers...)
log.Debug("Plugins: Adding proxy route %s", url)
log.Debugf("Plugins: Adding proxy route %s", url)
}
}
}
+5 -5
View File
@@ -94,7 +94,7 @@ func (this *CacheServer) Handler(ctx *models.ReqContext) {
if avatar.Expired() {
// The cache item is either expired or newly created, update it from the server
if err := avatar.Update(); err != nil {
log.Trace("avatar update error: %v", err)
log.Tracef("avatar update error: %v", err)
avatar = this.notFound
}
}
@@ -103,7 +103,7 @@ func (this *CacheServer) Handler(ctx *models.ReqContext) {
avatar = this.notFound
} else if !exists {
if err := this.cache.Add(hash, avatar, gocache.DefaultExpiration); err != nil {
log.Trace("Error adding avatar to cache: %s", err)
log.Tracef("Error adding avatar to cache: %s", err)
}
}
@@ -116,7 +116,7 @@ func (this *CacheServer) Handler(ctx *models.ReqContext) {
ctx.Resp.Header().Add("Cache-Control", "private, max-age=3600")
if err := avatar.Encode(ctx.Resp); err != nil {
log.Warn("avatar encode error: %v", err)
log.Warnf("avatar encode error: %v", err)
ctx.WriteHeader(500)
}
}
@@ -135,7 +135,7 @@ func newNotFound() *Avatar {
path := filepath.Join(setting.StaticRootPath, "img", "user_profile.png")
if data, err := ioutil.ReadFile(path); err != nil {
log.Error(3, "Failed to read user_profile.png, %v", path)
log.Errorf(3, "Failed to read user_profile.png, %v", path)
} else {
avatar.data = bytes.NewBuffer(data)
}
@@ -208,7 +208,7 @@ var client = &http.Client{
func (this *thunderTask) fetch() error {
this.Avatar.timestamp = time.Now()
log.Debug("avatar.fetch(fetch new avatar): %s", this.Url)
log.Debugf("avatar.fetch(fetch new avatar): %s", this.Url)
req, _ := http.NewRequest("GET", this.Url, nil)
req.Header.Set("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/jpeg,image/png,*/*;q=0.8")
req.Header.Set("Accept-Encoding", "deflate,sdch")
+1 -1
View File
@@ -321,7 +321,7 @@ func (hs *HTTPServer) GetHomeDashboard(c *models.ReqContext) Response {
dashRedirect := dtos.DashboardRedirect{RedirectUri: url}
return JSON(200, &dashRedirect)
}
log.Warn("Failed to get slug from database, %s", err.Error())
log.Warnf("Failed to get slug from database, %s", err.Error())
}
filePath := hs.Cfg.DefaultHomeDashboardPath
+1 -1
View File
@@ -65,7 +65,7 @@ func GetGravatarUrl(text string) string {
hasher := md5.New()
if _, err := hasher.Write([]byte(strings.ToLower(text))); err != nil {
log.Warn("Failed to hash text: %s", err)
log.Warnf("Failed to hash text: %s", err)
}
return fmt.Sprintf(setting.AppSubUrl+"/avatar/%x", hasher.Sum(nil))
}
+1 -1
View File
@@ -75,7 +75,7 @@ func (hs *HTTPServer) getFrontendSettingsMap(c *models.ReqContext) (map[string]i
meta, exists := enabledPlugins.DataSources[ds.Type]
if !exists {
log.Error(3, "Could not find plugin definition for data source: %v", ds.Type)
log.Errorf(3, "Could not find plugin definition for data source: %v", ds.Type)
continue
}
+2 -2
View File
@@ -76,14 +76,14 @@ func (c *connection) readPump() {
func (c *connection) handleMessage(message []byte) {
json, err := simplejson.NewJson(message)
if err != nil {
log.Error(3, "Unreadable message on websocket channel. error: %v", err)
log.Errorf(3, "Unreadable message on websocket channel. error: %v", err)
}
msgType := json.Get("action").MustString()
streamName := json.Get("stream").MustString()
if len(streamName) == 0 {
log.Error(3, "Not allowed to subscribe to empty stream name")
log.Errorf(3, "Not allowed to subscribe to empty stream name")
return
}
+2 -2
View File
@@ -27,11 +27,11 @@ func NewStreamManager() *StreamManager {
}
func (sm *StreamManager) Run(context context.Context) {
log.Debug("Initializing Stream Manager")
log.Debugf("Initializing Stream Manager")
go func() {
sm.hub.run(context)
log.Info("Stopped Stream Manager")
log.Infof("Stopped Stream Manager")
}()
}
+4 -4
View File
@@ -117,7 +117,7 @@ func (hs *HTTPServer) LoginView(c *models.ReqContext) {
if err := hs.ValidateRedirectTo(redirectTo); err != nil {
// the user is already logged so instead of rendering the login page with error
// it should be redirected to the home page.
log.Debug("Ignored invalid redirect_to cookie value: %v", redirectTo)
log.Debugf("Ignored invalid redirect_to cookie value: %v", redirectTo)
redirectTo = hs.Cfg.AppSubUrl + "/"
}
middleware.DeleteCookie(c.Resp, "redirect_to", hs.CookieOptionsFromCfg)
@@ -138,12 +138,12 @@ func tryOAuthAutoLogin(c *models.ReqContext) bool {
}
oauthInfos := setting.OAuthService.OAuthInfos
if len(oauthInfos) != 1 {
log.Warn("Skipping OAuth auto login because multiple OAuth providers are configured")
log.Warnf("Skipping OAuth auto login because multiple OAuth providers are configured")
return false
}
for key := range setting.OAuthService.OAuthInfos {
redirectUrl := setting.AppSubUrl + "/login/" + key
log.Info("OAuth auto login enabled. Redirecting to " + redirectUrl)
log.Infof("OAuth auto login enabled. Redirecting to " + redirectUrl)
c.Redirect(redirectUrl, 307)
return true
}
@@ -201,7 +201,7 @@ func (hs *HTTPServer) LoginPost(c *models.ReqContext, cmd dtos.LoginCommand) Res
if err := hs.ValidateRedirectTo(redirectTo); err == nil {
result["redirectUrl"] = redirectTo
} else {
log.Info("Ignored invalid redirect_to cookie value: %v", redirectTo)
log.Infof("Ignored invalid redirect_to cookie value: %v", redirectTo)
}
middleware.DeleteCookie(c.Resp, "redirect_to", hs.CookieOptionsFromCfg)
}
+1 -1
View File
@@ -232,7 +232,7 @@ func (hs *HTTPServer) OAuthLogin(ctx *models.ReqContext) {
ctx.Redirect(redirectTo)
return
}
log.Debug("Ignored invalid redirect_to cookie value: %v", redirectTo)
log.Debugf("Ignored invalid redirect_to cookie value: %v", redirectTo)
}
ctx.Redirect(setting.AppSubUrl + "/")
+2 -2
View File
@@ -90,7 +90,7 @@ func NewApiPluginProxy(ctx *models.ReqContext, proxyPath string, route *plugins.
}
for key, value := range headers {
log.Trace("setting key %v value <redacted>", key)
log.Tracef("setting key %v value <redacted>", key)
req.Header.Set(key, value[0])
}
}
@@ -112,7 +112,7 @@ func NewApiPluginProxy(ctx *models.ReqContext, proxyPath string, route *plugins.
}
// reqBytes, _ := httputil.DumpRequestOut(req, true);
// log.Trace("Proxying plugin request: %s", string(reqBytes))
// log.Tracef("Proxying plugin request: %s", string(reqBytes))
}
return &httputil.ReverseProxy{Director: director}