Commit 4c56eb39 by Arve Knudsen Committed by GitHub

Chore: Enable goprintffuncname and nakedret linters (#26376)

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

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
parent 9b17fe43
...@@ -814,8 +814,9 @@ jobs: ...@@ -814,8 +814,9 @@ jobs:
command: | command: |
# To save memory, run in two batches # To save memory, run in two batches
golangci-lint run -v -j 4 --config scripts/go/configs/ci/.golangci.toml -E deadcode -E depguard -E dogsled \ golangci-lint run -v -j 4 --config scripts/go/configs/ci/.golangci.toml -E deadcode -E depguard -E dogsled \
-E errcheck -E goconst -E golint -E gosec -E gosimple -E govet -E exportloopref -E whitespace ./pkg/... -E errcheck -E goconst -E golint -E gosec -E gosimple -E govet -E exportloopref -E whitespace \
golangci-lint run -v -j 4 --config scripts/go/configs/ci/.golangci.toml -E ineffassign -E gocritic \ -E goprintffuncname ./pkg/...
golangci-lint run -v -j 4 --config scripts/go/configs/ci/.golangci.toml -E ineffassign -E gocritic -E nakedret \
-E rowserrcheck -E staticcheck -E structcheck -E typecheck -E unconvert -E unused -E varcheck ./pkg/... -E rowserrcheck -E staticcheck -E structcheck -E typecheck -E unconvert -E unused -E varcheck ./pkg/...
./scripts/go/bin/revive -formatter stylish -config ./scripts/go/configs/revive.toml ./pkg/... ./scripts/go/bin/revive -formatter stylish -config ./scripts/go/configs/revive.toml ./pkg/...
./scripts/go/bin/revive -formatter stylish -config ./scripts/go/configs/revive-strict.toml \ ./scripts/go/bin/revive -formatter stylish -config ./scripts/go/configs/revive-strict.toml \
......
...@@ -48,7 +48,7 @@ func (hs *HTTPServer) initAppPluginRoutes(r *macaron.Macaron) { ...@@ -48,7 +48,7 @@ func (hs *HTTPServer) initAppPluginRoutes(r *macaron.Macaron) {
} }
handlers = append(handlers, AppPluginRoute(route, plugin.Id, hs)) handlers = append(handlers, AppPluginRoute(route, plugin.Id, hs))
r.Route(url, route.Method, handlers...) r.Route(url, route.Method, handlers...)
log.Debug("Plugins: Adding proxy route %s", url) log.Debugf("Plugins: Adding proxy route %s", url)
} }
} }
} }
......
...@@ -94,7 +94,7 @@ func (this *CacheServer) Handler(ctx *models.ReqContext) { ...@@ -94,7 +94,7 @@ func (this *CacheServer) Handler(ctx *models.ReqContext) {
if avatar.Expired() { if avatar.Expired() {
// The cache item is either expired or newly created, update it from the server // The cache item is either expired or newly created, update it from the server
if err := avatar.Update(); err != nil { if err := avatar.Update(); err != nil {
log.Trace("avatar update error: %v", err) log.Tracef("avatar update error: %v", err)
avatar = this.notFound avatar = this.notFound
} }
} }
...@@ -103,7 +103,7 @@ func (this *CacheServer) Handler(ctx *models.ReqContext) { ...@@ -103,7 +103,7 @@ func (this *CacheServer) Handler(ctx *models.ReqContext) {
avatar = this.notFound avatar = this.notFound
} else if !exists { } else if !exists {
if err := this.cache.Add(hash, avatar, gocache.DefaultExpiration); err != nil { 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) { ...@@ -116,7 +116,7 @@ func (this *CacheServer) Handler(ctx *models.ReqContext) {
ctx.Resp.Header().Add("Cache-Control", "private, max-age=3600") ctx.Resp.Header().Add("Cache-Control", "private, max-age=3600")
if err := avatar.Encode(ctx.Resp); err != nil { 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) ctx.WriteHeader(500)
} }
} }
...@@ -135,7 +135,7 @@ func newNotFound() *Avatar { ...@@ -135,7 +135,7 @@ func newNotFound() *Avatar {
path := filepath.Join(setting.StaticRootPath, "img", "user_profile.png") path := filepath.Join(setting.StaticRootPath, "img", "user_profile.png")
if data, err := ioutil.ReadFile(path); err != nil { 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 { } else {
avatar.data = bytes.NewBuffer(data) avatar.data = bytes.NewBuffer(data)
} }
...@@ -208,7 +208,7 @@ var client = &http.Client{ ...@@ -208,7 +208,7 @@ var client = &http.Client{
func (this *thunderTask) fetch() error { func (this *thunderTask) fetch() error {
this.Avatar.timestamp = time.Now() 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, _ := 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", "text/html,application/xhtml+xml,application/xml;q=0.9,image/jpeg,image/png,*/*;q=0.8")
req.Header.Set("Accept-Encoding", "deflate,sdch") req.Header.Set("Accept-Encoding", "deflate,sdch")
......
...@@ -321,7 +321,7 @@ func (hs *HTTPServer) GetHomeDashboard(c *models.ReqContext) Response { ...@@ -321,7 +321,7 @@ func (hs *HTTPServer) GetHomeDashboard(c *models.ReqContext) Response {
dashRedirect := dtos.DashboardRedirect{RedirectUri: url} dashRedirect := dtos.DashboardRedirect{RedirectUri: url}
return JSON(200, &dashRedirect) 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 filePath := hs.Cfg.DefaultHomeDashboardPath
......
...@@ -65,7 +65,7 @@ func GetGravatarUrl(text string) string { ...@@ -65,7 +65,7 @@ func GetGravatarUrl(text string) string {
hasher := md5.New() hasher := md5.New()
if _, err := hasher.Write([]byte(strings.ToLower(text))); err != nil { 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)) return fmt.Sprintf(setting.AppSubUrl+"/avatar/%x", hasher.Sum(nil))
} }
......
...@@ -75,7 +75,7 @@ func (hs *HTTPServer) getFrontendSettingsMap(c *models.ReqContext) (map[string]i ...@@ -75,7 +75,7 @@ func (hs *HTTPServer) getFrontendSettingsMap(c *models.ReqContext) (map[string]i
meta, exists := enabledPlugins.DataSources[ds.Type] meta, exists := enabledPlugins.DataSources[ds.Type]
if !exists { 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 continue
} }
......
...@@ -76,14 +76,14 @@ func (c *connection) readPump() { ...@@ -76,14 +76,14 @@ func (c *connection) readPump() {
func (c *connection) handleMessage(message []byte) { func (c *connection) handleMessage(message []byte) {
json, err := simplejson.NewJson(message) json, err := simplejson.NewJson(message)
if err != nil { 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() msgType := json.Get("action").MustString()
streamName := json.Get("stream").MustString() streamName := json.Get("stream").MustString()
if len(streamName) == 0 { 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 return
} }
......
...@@ -27,11 +27,11 @@ func NewStreamManager() *StreamManager { ...@@ -27,11 +27,11 @@ func NewStreamManager() *StreamManager {
} }
func (sm *StreamManager) Run(context context.Context) { func (sm *StreamManager) Run(context context.Context) {
log.Debug("Initializing Stream Manager") log.Debugf("Initializing Stream Manager")
go func() { go func() {
sm.hub.run(context) sm.hub.run(context)
log.Info("Stopped Stream Manager") log.Infof("Stopped Stream Manager")
}() }()
} }
......
...@@ -117,7 +117,7 @@ func (hs *HTTPServer) LoginView(c *models.ReqContext) { ...@@ -117,7 +117,7 @@ func (hs *HTTPServer) LoginView(c *models.ReqContext) {
if err := hs.ValidateRedirectTo(redirectTo); err != nil { if err := hs.ValidateRedirectTo(redirectTo); err != nil {
// the user is already logged so instead of rendering the login page with error // the user is already logged so instead of rendering the login page with error
// it should be redirected to the home page. // 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 + "/" redirectTo = hs.Cfg.AppSubUrl + "/"
} }
middleware.DeleteCookie(c.Resp, "redirect_to", hs.CookieOptionsFromCfg) middleware.DeleteCookie(c.Resp, "redirect_to", hs.CookieOptionsFromCfg)
...@@ -138,12 +138,12 @@ func tryOAuthAutoLogin(c *models.ReqContext) bool { ...@@ -138,12 +138,12 @@ func tryOAuthAutoLogin(c *models.ReqContext) bool {
} }
oauthInfos := setting.OAuthService.OAuthInfos oauthInfos := setting.OAuthService.OAuthInfos
if len(oauthInfos) != 1 { 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 return false
} }
for key := range setting.OAuthService.OAuthInfos { for key := range setting.OAuthService.OAuthInfos {
redirectUrl := setting.AppSubUrl + "/login/" + key 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) c.Redirect(redirectUrl, 307)
return true return true
} }
...@@ -201,7 +201,7 @@ func (hs *HTTPServer) LoginPost(c *models.ReqContext, cmd dtos.LoginCommand) Res ...@@ -201,7 +201,7 @@ func (hs *HTTPServer) LoginPost(c *models.ReqContext, cmd dtos.LoginCommand) Res
if err := hs.ValidateRedirectTo(redirectTo); err == nil { if err := hs.ValidateRedirectTo(redirectTo); err == nil {
result["redirectUrl"] = redirectTo result["redirectUrl"] = redirectTo
} else { } 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) middleware.DeleteCookie(c.Resp, "redirect_to", hs.CookieOptionsFromCfg)
} }
......
...@@ -232,7 +232,7 @@ func (hs *HTTPServer) OAuthLogin(ctx *models.ReqContext) { ...@@ -232,7 +232,7 @@ func (hs *HTTPServer) OAuthLogin(ctx *models.ReqContext) {
ctx.Redirect(redirectTo) ctx.Redirect(redirectTo)
return 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 + "/") ctx.Redirect(setting.AppSubUrl + "/")
......
...@@ -90,7 +90,7 @@ func NewApiPluginProxy(ctx *models.ReqContext, proxyPath string, route *plugins. ...@@ -90,7 +90,7 @@ func NewApiPluginProxy(ctx *models.ReqContext, proxyPath string, route *plugins.
} }
for key, value := range headers { 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]) req.Header.Set(key, value[0])
} }
} }
...@@ -112,7 +112,7 @@ func NewApiPluginProxy(ctx *models.ReqContext, proxyPath string, route *plugins. ...@@ -112,7 +112,7 @@ func NewApiPluginProxy(ctx *models.ReqContext, proxyPath string, route *plugins.
} }
// reqBytes, _ := httputil.DumpRequestOut(req, true); // 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} return &httputil.ReverseProxy{Director: director}
......
...@@ -73,7 +73,7 @@ func (u *S3Uploader) Upload(ctx context.Context, imageDiskPath string) (string, ...@@ -73,7 +73,7 @@ func (u *S3Uploader) Upload(ctx context.Context, imageDiskPath string) (string,
return "", err return "", err
} }
key := u.path + rand + pngExt key := u.path + rand + pngExt
log.Debug("Uploading image to s3. bucket = %s, path = %s", u.bucket, key) log.Debugf("Uploading image to s3. bucket = %s, path = %s", u.bucket, key)
file, err := os.Open(imageDiskPath) file, err := os.Open(imageDiskPath)
if err != nil { if err != nil {
......
...@@ -16,7 +16,7 @@ func (s SecureJsonData) DecryptedValue(key string) (string, bool) { ...@@ -16,7 +16,7 @@ func (s SecureJsonData) DecryptedValue(key string) (string, bool) {
if value, ok := s[key]; ok { if value, ok := s[key]; ok {
decryptedData, err := util.Decrypt(value, setting.SecretKey) decryptedData, err := util.Decrypt(value, setting.SecretKey)
if err != nil { if err != nil {
log.Fatal(4, err.Error()) log.Fatalf(4, err.Error())
} }
return string(decryptedData), true return string(decryptedData), true
} }
...@@ -30,7 +30,7 @@ func (s SecureJsonData) Decrypt() map[string]string { ...@@ -30,7 +30,7 @@ func (s SecureJsonData) Decrypt() map[string]string {
for key, data := range s { for key, data := range s {
decryptedData, err := util.Decrypt(data, setting.SecretKey) decryptedData, err := util.Decrypt(data, setting.SecretKey)
if err != nil { if err != nil {
log.Fatal(4, err.Error()) log.Fatalf(4, err.Error())
} }
decrypted[key] = string(decryptedData) decrypted[key] = string(decryptedData)
...@@ -44,7 +44,7 @@ func GetEncryptedJsonData(sjd map[string]string) SecureJsonData { ...@@ -44,7 +44,7 @@ func GetEncryptedJsonData(sjd map[string]string) SecureJsonData {
for key, data := range sjd { for key, data := range sjd {
encryptedData, err := util.Encrypt([]byte(data), setting.SecretKey) encryptedData, err := util.Encrypt([]byte(data), setting.SecretKey)
if err != nil { if err != nil {
log.Fatal(4, err.Error()) log.Fatalf(4, err.Error())
} }
encrypted[key] = encryptedData encrypted[key] = encryptedData
......
...@@ -36,7 +36,7 @@ func New(logger string, ctx ...interface{}) Logger { ...@@ -36,7 +36,7 @@ func New(logger string, ctx ...interface{}) Logger {
return Root.New(params...) return Root.New(params...)
} }
func Trace(format string, v ...interface{}) { func Tracef(format string, v ...interface{}) {
var message string var message string
if len(v) > 0 { if len(v) > 0 {
message = fmt.Sprintf(format, v...) message = fmt.Sprintf(format, v...)
...@@ -47,7 +47,7 @@ func Trace(format string, v ...interface{}) { ...@@ -47,7 +47,7 @@ func Trace(format string, v ...interface{}) {
Root.Debug(message) Root.Debug(message)
} }
func Debug(format string, v ...interface{}) { func Debugf(format string, v ...interface{}) {
var message string var message string
if len(v) > 0 { if len(v) > 0 {
message = fmt.Sprintf(format, v...) message = fmt.Sprintf(format, v...)
...@@ -58,7 +58,7 @@ func Debug(format string, v ...interface{}) { ...@@ -58,7 +58,7 @@ func Debug(format string, v ...interface{}) {
Root.Debug(message) Root.Debug(message)
} }
func Info(format string, v ...interface{}) { func Infof(format string, v ...interface{}) {
var message string var message string
if len(v) > 0 { if len(v) > 0 {
message = fmt.Sprintf(format, v...) message = fmt.Sprintf(format, v...)
...@@ -69,7 +69,7 @@ func Info(format string, v ...interface{}) { ...@@ -69,7 +69,7 @@ func Info(format string, v ...interface{}) {
Root.Info(message) Root.Info(message)
} }
func Warn(format string, v ...interface{}) { func Warnf(format string, v ...interface{}) {
var message string var message string
if len(v) > 0 { if len(v) > 0 {
message = fmt.Sprintf(format, v...) message = fmt.Sprintf(format, v...)
...@@ -80,15 +80,15 @@ func Warn(format string, v ...interface{}) { ...@@ -80,15 +80,15 @@ func Warn(format string, v ...interface{}) {
Root.Warn(message) Root.Warn(message)
} }
func Error(skip int, format string, v ...interface{}) { func Errorf(skip int, format string, v ...interface{}) {
Root.Error(fmt.Sprintf(format, v...)) Root.Error(fmt.Sprintf(format, v...))
} }
func Critical(skip int, format string, v ...interface{}) { func Criticalf(skip int, format string, v ...interface{}) {
Root.Crit(fmt.Sprintf(format, v...)) Root.Crit(fmt.Sprintf(format, v...))
} }
func Fatal(skip int, format string, v ...interface{}) { func Fatalf(skip int, format string, v ...interface{}) {
Root.Crit(fmt.Sprintf(format, v...)) Root.Crit(fmt.Sprintf(format, v...))
Close() Close()
os.Exit(1) os.Exit(1)
......
...@@ -64,7 +64,7 @@ func HttpGet(client *http.Client, url string) (response HttpGetResponse, err err ...@@ -64,7 +64,7 @@ func HttpGet(client *http.Client, url string) (response HttpGetResponse, err err
return return
} }
log.Trace("HTTP GET %s: %s %s", url, r.Status, string(response.Body)) log.Tracef("HTTP GET %s: %s %s", url, r.Status, string(response.Body))
err = nil err = nil
return return
......
...@@ -94,7 +94,7 @@ func initContextWithAnonymousUser(ctx *models.ReqContext) bool { ...@@ -94,7 +94,7 @@ func initContextWithAnonymousUser(ctx *models.ReqContext) bool {
orgQuery := models.GetOrgByNameQuery{Name: setting.AnonymousOrgName} orgQuery := models.GetOrgByNameQuery{Name: setting.AnonymousOrgName}
if err := bus.Dispatch(&orgQuery); err != nil { if err := bus.Dispatch(&orgQuery); err != nil {
log.Error(3, "Anonymous access organization error: '%s': %s", setting.AnonymousOrgName, err) log.Errorf(3, "Anonymous access organization error: '%s': %s", setting.AnonymousOrgName, err)
return false return false
} }
......
...@@ -50,7 +50,7 @@ func (pm *PluginManager) checkForUpdates() { ...@@ -50,7 +50,7 @@ func (pm *PluginManager) checkForUpdates() {
resp, err := httpClient.Get("https://grafana.com/api/plugins/versioncheck?slugIn=" + pluginSlugs + "&grafanaVersion=" + setting.BuildVersion) resp, err := httpClient.Get("https://grafana.com/api/plugins/versioncheck?slugIn=" + pluginSlugs + "&grafanaVersion=" + setting.BuildVersion)
if err != nil { if err != nil {
log.Trace("Failed to get plugins repo from grafana.com, %v", err.Error()) log.Tracef("Failed to get plugins repo from grafana.com, %v", err.Error())
return return
} }
...@@ -58,14 +58,14 @@ func (pm *PluginManager) checkForUpdates() { ...@@ -58,14 +58,14 @@ func (pm *PluginManager) checkForUpdates() {
body, err := ioutil.ReadAll(resp.Body) body, err := ioutil.ReadAll(resp.Body)
if err != nil { if err != nil {
log.Trace("Update check failed, reading response from grafana.com, %v", err.Error()) log.Tracef("Update check failed, reading response from grafana.com, %v", err.Error())
return return
} }
gNetPlugins := []GrafanaNetPlugin{} gNetPlugins := []GrafanaNetPlugin{}
err = json.Unmarshal(body, &gNetPlugins) err = json.Unmarshal(body, &gNetPlugins)
if err != nil { if err != nil {
log.Trace("Failed to unmarshal plugin repo, reading response from grafana.com, %v", err.Error()) log.Tracef("Failed to unmarshal plugin repo, reading response from grafana.com, %v", err.Error())
return return
} }
...@@ -88,21 +88,21 @@ func (pm *PluginManager) checkForUpdates() { ...@@ -88,21 +88,21 @@ func (pm *PluginManager) checkForUpdates() {
resp2, err := httpClient.Get("https://raw.githubusercontent.com/grafana/grafana/master/latest.json") resp2, err := httpClient.Get("https://raw.githubusercontent.com/grafana/grafana/master/latest.json")
if err != nil { if err != nil {
log.Trace("Failed to get latest.json repo from github.com: %v", err.Error()) log.Tracef("Failed to get latest.json repo from github.com: %v", err.Error())
return return
} }
defer resp2.Body.Close() defer resp2.Body.Close()
body, err = ioutil.ReadAll(resp2.Body) body, err = ioutil.ReadAll(resp2.Body)
if err != nil { if err != nil {
log.Trace("Update check failed, reading response from github.com, %v", err.Error()) log.Tracef("Update check failed, reading response from github.com, %v", err.Error())
return return
} }
var githubLatest GithubLatest var githubLatest GithubLatest
err = json.Unmarshal(body, &githubLatest) err = json.Unmarshal(body, &githubLatest)
if err != nil { if err != nil {
log.Trace("Failed to unmarshal github.com latest, reading response from github.com: %v", err.Error()) log.Tracef("Failed to unmarshal github.com latest, reading response from github.com: %v", err.Error())
return return
} }
......
...@@ -265,7 +265,7 @@ func appendIfPossible(message string, extra string, sizeLimit int) string { ...@@ -265,7 +265,7 @@ func appendIfPossible(message string, extra string, sizeLimit int) string {
if len(extra)+len(message) <= sizeLimit { if len(extra)+len(message) <= sizeLimit {
return message + extra return message + extra
} }
log.Debug("Line too long for image caption. value: %s", extra) log.Debugf("Line too long for image caption. value: %s", extra)
return message return message
} }
......
...@@ -44,13 +44,13 @@ func (ls *LoginService) UpsertUser(cmd *models.UpsertUserCommand) error { ...@@ -44,13 +44,13 @@ func (ls *LoginService) UpsertUser(cmd *models.UpsertUserCommand) error {
return err return err
} }
if !cmd.SignupAllowed { if !cmd.SignupAllowed {
log.Warn("Not allowing %s login, user not found in internal user database and allow signup = false", extUser.AuthModule) log.Warnf("Not allowing %s login, user not found in internal user database and allow signup = false", extUser.AuthModule)
return ErrInvalidCredentials return ErrInvalidCredentials
} }
limitReached, err := ls.QuotaService.QuotaReached(cmd.ReqContext, "user") limitReached, err := ls.QuotaService.QuotaReached(cmd.ReqContext, "user")
if err != nil { if err != nil {
log.Warn("Error getting user quota. error: %v", err) log.Warnf("Error getting user quota. error: %v", err)
return ErrGettingUserQuota return ErrGettingUserQuota
} }
if limitReached { if limitReached {
......
...@@ -66,7 +66,7 @@ func inTransactionWithRetryCtx(ctx context.Context, engine *xorm.Engine, callbac ...@@ -66,7 +66,7 @@ func inTransactionWithRetryCtx(ctx context.Context, engine *xorm.Engine, callbac
if len(sess.events) > 0 { if len(sess.events) > 0 {
for _, e := range sess.events { for _, e := range sess.events {
if err = bus.Publish(e); err != nil { if err = bus.Publish(e); err != nil {
log.Error(3, "Failed to publish event after commit. error: %v", err) log.Errorf(3, "Failed to publish event after commit. error: %v", err)
} }
} }
} }
......
...@@ -336,7 +336,7 @@ func parseAppUrlAndSubUrl(section *ini.Section) (string, string, error) { ...@@ -336,7 +336,7 @@ func parseAppUrlAndSubUrl(section *ini.Section) (string, string, error) {
// Check if has app suburl. // Check if has app suburl.
url, err := url.Parse(appUrl) url, err := url.Parse(appUrl)
if err != nil { if err != nil {
log.Fatal(4, "Invalid root_url(%s): %s", appUrl, err) log.Fatalf(4, "Invalid root_url(%s): %s", appUrl, err)
} }
appSubUrl := strings.TrimSuffix(url.Path, "/") appSubUrl := strings.TrimSuffix(url.Path, "/")
...@@ -444,7 +444,7 @@ func getCommandLineProperties(args []string) map[string]string { ...@@ -444,7 +444,7 @@ func getCommandLineProperties(args []string) map[string]string {
trimmed := strings.TrimPrefix(arg, "cfg:") trimmed := strings.TrimPrefix(arg, "cfg:")
parts := strings.Split(trimmed, "=") parts := strings.Split(trimmed, "=")
if len(parts) != 2 { if len(parts) != 2 {
log.Fatal(3, "Invalid command line argument. argument: %v", arg) log.Fatalf(3, "Invalid command line argument. argument: %v", arg)
return nil return nil
} }
...@@ -533,7 +533,7 @@ func (cfg *Cfg) loadConfiguration(args *CommandLineArgs) (*ini.File, error) { ...@@ -533,7 +533,7 @@ func (cfg *Cfg) loadConfiguration(args *CommandLineArgs) (*ini.File, error) {
if err2 != nil { if err2 != nil {
return nil, err2 return nil, err2
} }
log.Fatal(3, err.Error()) log.Fatalf(3, err.Error())
} }
// apply environment overrides // apply environment overrides
...@@ -953,7 +953,7 @@ func (cfg *Cfg) Load(args *CommandLineArgs) error { ...@@ -953,7 +953,7 @@ func (cfg *Cfg) Load(args *CommandLineArgs) error {
} }
_, err := url.Parse(cfg.RendererCallbackUrl) _, err := url.Parse(cfg.RendererCallbackUrl)
if err != nil { if err != nil {
log.Fatal(4, "Invalid callback_url(%s): %s", cfg.RendererCallbackUrl, err) log.Fatalf(4, "Invalid callback_url(%s): %s", cfg.RendererCallbackUrl, err)
} }
} }
cfg.RendererConcurrentRequestLimit = renderSec.Key("concurrent_render_request_limit").MustInt(30) cfg.RendererConcurrentRequestLimit = renderSec.Key("concurrent_render_request_limit").MustInt(30)
...@@ -1036,7 +1036,7 @@ func (cfg *Cfg) Load(args *CommandLineArgs) error { ...@@ -1036,7 +1036,7 @@ func (cfg *Cfg) Load(args *CommandLineArgs) error {
cfg.readQuotaSettings() cfg.readQuotaSettings()
if VerifyEmailEnabled && !cfg.Smtp.Enabled { if VerifyEmailEnabled && !cfg.Smtp.Enabled {
log.Warn("require_email_validation is enabled but smtp is disabled") log.Warnf("require_email_validation is enabled but smtp is disabled")
} }
// check old key name // check old key name
......
...@@ -21,13 +21,14 @@ enable = [ ...@@ -21,13 +21,14 @@ enable = [
"gocritic", "gocritic",
"goimports", "goimports",
"golint", "golint",
# "goprintffuncname", "goprintffuncname",
"gosec", "gosec",
"gosimple", "gosimple",
"govet", "govet",
"ineffassign", "ineffassign",
# "interfacer", # "interfacer",
"misspell", "misspell",
"nakedret",
"rowserrcheck", "rowserrcheck",
"exportloopref", "exportloopref",
"staticcheck", "staticcheck",
......
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