]> source.dussan.org Git - gitea.git/commitdiff
refactor: err != nil check, just return error instead (#5093)
authorBo-Yi Wu <appleboy.tw@gmail.com>
Thu, 18 Oct 2018 04:51:07 +0000 (12:51 +0800)
committertechknowlogick <hello@techknowlogick.com>
Thu, 18 Oct 2018 04:51:07 +0000 (00:51 -0400)
cmd/admin.go
models/migrations/v68.go

index 047f3befccf28e98e12805bab4aa7c9a8b178a14..893b6f5be9fab62aa2363aa6bd8adbb404153756 100644 (file)
@@ -412,16 +412,12 @@ func runAddOauth(c *cli.Context) error {
                return err
        }
 
-       if err := models.CreateLoginSource(&models.LoginSource{
+       return models.CreateLoginSource(&models.LoginSource{
                Type:      models.LoginOAuth2,
                Name:      c.String("name"),
                IsActived: true,
                Cfg:       parseOAuth2Config(c),
-       }); err != nil {
-               return err
-       }
-
-       return nil
+       })
 }
 
 func runUpdateOauth(c *cli.Context) error {
@@ -492,11 +488,7 @@ func runUpdateOauth(c *cli.Context) error {
        oAuth2Config.CustomURLMapping = customURLMapping
        source.Cfg = oAuth2Config
 
-       if err := models.UpdateSource(source); err != nil {
-               return err
-       }
-
-       return nil
+       return models.UpdateSource(source)
 }
 
 func runListAuth(c *cli.Context) error {
@@ -543,8 +535,5 @@ func runDeleteAuth(c *cli.Context) error {
                return err
        }
 
-       if err = models.DeleteSource(source); err != nil {
-               return err
-       }
-       return nil
+       return models.DeleteSource(source)
 }
index e27b896c82df0edac73cbe2a975b1902e7877145..68c8d237fd760be721966a22686325512b0bc7fe 100644 (file)
@@ -205,9 +205,6 @@ func reformatAndRemoveIncorrectTopics(x *xorm.Engine) (err error) {
                        return err
                }
        }
-       if err := sess.Commit(); err != nil {
-               return err
-       }
 
-       return nil
+       return sess.Commit()
 }