diff options
author | ᴜɴᴋɴᴡᴏɴ <u@gogs.io> | 2020-03-21 13:39:32 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-21 13:39:32 +0800 |
commit | 5843038a0812cc133c1895b7410aeda7153e8708 (patch) | |
tree | 3515998242443e1a82217ee4702603819c5315c8 /internal/route | |
parent | 958d8b6bb4c2da66859325695b91d871e567a4fa (diff) |
workflows: enable golangci-lint (#5998)
* Create golint.yml
* Update golint.yml
* Update golint.yml
* Fix errcheck
* Fix gosimple
* Fix staticcheck
Diffstat (limited to 'internal/route')
-rw-r--r-- | internal/route/admin/admin.go | 1 | ||||
-rw-r--r-- | internal/route/install.go | 11 | ||||
-rw-r--r-- | internal/route/repo/http.go | 6 | ||||
-rw-r--r-- | internal/route/user/auth.go | 24 | ||||
-rw-r--r-- | internal/route/user/setting.go | 12 |
5 files changed, 26 insertions, 28 deletions
diff --git a/internal/route/admin/admin.go b/internal/route/admin/admin.go index 9345de07..6b0e8c2c 100644 --- a/internal/route/admin/admin.go +++ b/internal/route/admin/admin.go @@ -172,7 +172,6 @@ func Operation(c *context.Context) { c.Flash.Success(success) } c.RedirectSubpath("/admin") - return } func SendTestMail(c *context.Context) { diff --git a/internal/route/install.go b/internal/route/install.go index 187a65a6..899393b4 100644 --- a/internal/route/install.go +++ b/internal/route/install.go @@ -11,14 +11,12 @@ import ( "path/filepath" "strings" + "github.com/gogs/git-module" "github.com/pkg/errors" "github.com/unknwon/com" "gopkg.in/ini.v1" "gopkg.in/macaron.v1" log "unknwon.dev/clog/v2" - "xorm.io/xorm" - - "github.com/gogs/git-module" "gogs.io/gogs/internal/conf" "gogs.io/gogs/internal/context" @@ -240,8 +238,7 @@ func InstallPost(c *context.Context, f form.Install) { } // Set test engine. - var x *xorm.Engine - if err := db.NewTestEngine(x); err != nil { + if err := db.NewTestEngine(); err != nil { if strings.Contains(err.Error(), `Unknown database type: sqlite3`) { c.FormErr("DbType") c.RenderWithErr(c.Tr("install.sqlite3_not_available", "https://gogs.io/docs/installation/install_from_binary.html"), INSTALL, &f) @@ -419,8 +416,8 @@ func InstallPost(c *context.Context, f form.Install) { } // Auto-login for admin - c.Session.Set("uid", u.ID) - c.Session.Set("uname", u.Name) + _ = c.Session.Set("uid", u.ID) + _ = c.Session.Set("uname", u.Name) } log.Info("First-time run install finished!") diff --git a/internal/route/repo/http.go b/internal/route/repo/http.go index e63bc872..413b660f 100644 --- a/internal/route/repo/http.go +++ b/internal/route/repo/http.go @@ -314,9 +314,9 @@ func getInfoRefs(h serviceHandler) { refs := gitCommand(h.dir, service, "--stateless-rpc", "--advertise-refs", ".") h.w.Header().Set("Content-Type", fmt.Sprintf("application/x-git-%s-advertisement", service)) h.w.WriteHeader(http.StatusOK) - h.w.Write(packetWrite("# service=git-" + service + "\n")) - h.w.Write([]byte("0000")) - h.w.Write(refs) + _, _ = h.w.Write(packetWrite("# service=git-" + service + "\n")) + _, _ = h.w.Write([]byte("0000")) + _, _ = h.w.Write(refs) } func getTextFile(h serviceHandler) { diff --git a/internal/route/user/auth.go b/internal/route/user/auth.go index 5fef81c3..a29b6311 100644 --- a/internal/route/user/auth.go +++ b/internal/route/user/auth.go @@ -64,8 +64,8 @@ func AutoLogin(c *context.Context) (bool, error) { } isSucceed = true - c.Session.Set("uid", u.ID) - c.Session.Set("uname", u.Name) + _ = c.Session.Set("uid", u.ID) + _ = c.Session.Set("uname", u.Name) c.SetCookie(conf.Session.CSRFCookieName, "", -1, conf.Server.Subpath) if conf.Security.EnableLoginStatusCookie { c.SetCookie(conf.Security.LoginStatusCookieName, "true", 0, conf.Server.Subpath) @@ -124,10 +124,10 @@ func afterLogin(c *context.Context, u *db.User, remember bool) { c.SetSuperSecureCookie(u.Rands+u.Passwd, conf.Security.CookieRememberName, u.Name, days, conf.Server.Subpath, "", conf.Security.CookieSecure, true) } - c.Session.Set("uid", u.ID) - c.Session.Set("uname", u.Name) - c.Session.Delete("twoFactorRemember") - c.Session.Delete("twoFactorUserID") + _ = c.Session.Set("uid", u.ID) + _ = c.Session.Set("uname", u.Name) + _ = c.Session.Delete("twoFactorRemember") + _ = c.Session.Delete("twoFactorUserID") // Clear whatever CSRF has right now, force to generate a new one c.SetCookie(conf.Session.CSRFCookieName, "", -1, conf.Server.Subpath) @@ -187,8 +187,8 @@ func LoginPost(c *context.Context, f form.SignIn) { return } - c.Session.Set("twoFactorRemember", f.Remember) - c.Session.Set("twoFactorUserID", u.ID) + _ = c.Session.Set("twoFactorRemember", f.Remember) + _ = c.Session.Set("twoFactorUserID", u.ID) c.RedirectSubpath("/user/login/two_factor") } @@ -281,8 +281,8 @@ func LoginTwoFactorRecoveryCodePost(c *context.Context) { } func SignOut(c *context.Context) { - c.Session.Flush() - c.Session.Destory(c.Context) + _ = c.Session.Flush() + _ = c.Session.Destory(c.Context) c.SetCookie(conf.Security.CookieUsername, "", -1, conf.Server.Subpath) c.SetCookie(conf.Security.CookieRememberName, "", -1, conf.Server.Subpath) c.SetCookie(conf.Session.CSRFCookieName, "", -1, conf.Server.Subpath) @@ -426,8 +426,8 @@ func Activate(c *context.Context) { log.Trace("User activated: %s", user.Name) - c.Session.Set("uid", user.ID) - c.Session.Set("uname", user.Name) + _ = c.Session.Set("uid", user.ID) + _ = c.Session.Set("uname", user.Name) c.RedirectSubpath("/") return } diff --git a/internal/route/user/setting.go b/internal/route/user/setting.go index d8ae9e70..c9ccdc8f 100644 --- a/internal/route/user/setting.go +++ b/internal/route/user/setting.go @@ -127,7 +127,9 @@ func UpdateAvatarSetting(c *context.Context, f form.Avatar, ctxUser *db.User) er if err != nil { return fmt.Errorf("open avatar reader: %v", err) } - defer r.Close() + defer func() { + _ = r.Close() + }() data, err := ioutil.ReadAll(r) if err != nil { @@ -429,8 +431,8 @@ func SettingsTwoFactorEnable(c *context.Context) { } c.Data["QRCode"] = template.URL("data:image/png;base64," + base64.StdEncoding.EncodeToString(buf.Bytes())) - c.Session.Set("twoFactorSecret", c.Data["TwoFactorSecret"]) - c.Session.Set("twoFactorURL", key.String()) + _ = c.Session.Set("twoFactorSecret", c.Data["TwoFactorSecret"]) + _ = c.Session.Set("twoFactorURL", key.String()) c.Success(SETTINGS_TWO_FACTOR_ENABLE) } @@ -453,8 +455,8 @@ func SettingsTwoFactorEnablePost(c *context.Context) { return } - c.Session.Delete("twoFactorSecret") - c.Session.Delete("twoFactorURL") + _ = c.Session.Delete("twoFactorSecret") + _ = c.Session.Delete("twoFactorURL") c.Flash.Success(c.Tr("settings.two_factor_enable_success")) c.RedirectSubpath("/user/settings/security/two_factor_recovery_codes") } |