]> source.dussan.org Git - gitea.git/commitdiff
Code Formats, Nits & Unused Func/Var deletions (#15286)
author6543 <6543@obermui.de>
Fri, 9 Apr 2021 07:40:34 +0000 (09:40 +0200)
committerGitHub <noreply@github.com>
Fri, 9 Apr 2021 07:40:34 +0000 (09:40 +0200)
* _ to unused func options

* rm useless brakets

* rm trifial non used models functions

* rm dead code

* rm dead global vars

* fix routers/api/v1/repo/issue.go

* dont overload import module

33 files changed:
cmd/admin.go
cmd/hook.go
models/branches.go
models/issue_label.go
models/lfs.go
models/repo_test.go
models/user.go
models/user_heatmap.go
models/user_openid.go
modules/markup/common/linkify.go
modules/process/manager.go
modules/queue/bytefifo.go
modules/queue/helper.go
modules/queue/queue_bytefifo.go
modules/queue/queue_disk.go
modules/queue/queue_redis.go
modules/queue/unique_queue_disk.go
modules/queue/unique_queue_redis.go
modules/references/references.go
modules/repofiles/action.go
modules/setting/setting.go
modules/storage/helper.go
modules/storage/storage.go
routers/api/v1/org/team.go
routers/api/v1/repo/issue.go
routers/api/v1/repo/pull.go
routers/events/events.go
routers/org/teams.go
routers/repo/http.go
routers/repo/issue.go
routers/repo/setting_protected_branch.go
routers/user/home.go
services/pull/merge.go

index 3ddf8eddf9e6c9e96122cae69a6f5f788c8fa44a..31ba77877b26cfd7baff73ca2ef2f557268db1a1 100644 (file)
@@ -512,7 +512,7 @@ func runDeleteUser(c *cli.Context) error {
        return models.DeleteUser(user)
 }
 
-func runRepoSyncReleases(c *cli.Context) error {
+func runRepoSyncReleases(_ *cli.Context) error {
        if err := initDB(); err != nil {
                return err
        }
@@ -578,14 +578,14 @@ func getReleaseCount(id int64) (int64, error) {
        )
 }
 
-func runRegenerateHooks(c *cli.Context) error {
+func runRegenerateHooks(_ *cli.Context) error {
        if err := initDB(); err != nil {
                return err
        }
        return repo_module.SyncRepositoryHooks(graceful.GetManager().ShutdownContext())
 }
 
-func runRegenerateKeys(c *cli.Context) error {
+func runRegenerateKeys(_ *cli.Context) error {
        if err := initDB(); err != nil {
                return err
        }
index 1fcc0a18c3167e6b34a896c1ca0bfe10c56a2572..def3b636eb674545d8be8119960ee86db27f99ce 100644 (file)
@@ -166,7 +166,7 @@ Gitea or set your environment appropriately.`, "")
        }
 
        // the environment setted on serv command
-       isWiki := (os.Getenv(models.EnvRepoIsWiki) == "true")
+       isWiki := os.Getenv(models.EnvRepoIsWiki) == "true"
        username := os.Getenv(models.EnvRepoUsername)
        reponame := os.Getenv(models.EnvRepoName)
        userID, _ := strconv.ParseInt(os.Getenv(models.EnvPusherID), 10, 64)
@@ -322,7 +322,7 @@ Gitea or set your environment appropriately.`, "")
 
        // the environment setted on serv command
        repoUser := os.Getenv(models.EnvRepoUsername)
-       isWiki := (os.Getenv(models.EnvRepoIsWiki) == "true")
+       isWiki := os.Getenv(models.EnvRepoIsWiki) == "true"
        repoName := os.Getenv(models.EnvRepoName)
        pusherID, _ := strconv.ParseInt(os.Getenv(models.EnvPusherID), 10, 64)
        pusherName := os.Getenv(models.EnvPusherName)
index 440c09309536d5ba58e79a40ad138d89a6881621..1ac1fa49e580938f89ca89fe1c0f8c80fee1c12e 100644 (file)
@@ -260,12 +260,6 @@ func (protectBranch *ProtectedBranch) IsProtectedFile(patterns []glob.Glob, path
        return r
 }
 
-// GetProtectedBranchByRepoID getting protected branch by repo ID
-func GetProtectedBranchByRepoID(repoID int64) ([]*ProtectedBranch, error) {
-       protectedBranches := make([]*ProtectedBranch, 0)
-       return protectedBranches, x.Where("repo_id = ?", repoID).Desc("updated_unix").Find(&protectedBranches)
-}
-
 // GetProtectedBranchBy getting protected branch by ID/Name
 func GetProtectedBranchBy(repoID int64, branchName string) (*ProtectedBranch, error) {
        return getProtectedBranchBy(x, repoID, branchName)
@@ -283,19 +277,6 @@ func getProtectedBranchBy(e Engine, repoID int64, branchName string) (*Protected
        return rel, nil
 }
 
-// GetProtectedBranchByID getting protected branch by ID
-func GetProtectedBranchByID(id int64) (*ProtectedBranch, error) {
-       rel := &ProtectedBranch{}
-       has, err := x.ID(id).Get(rel)
-       if err != nil {
-               return nil, err
-       }
-       if !has {
-               return nil, nil
-       }
-       return rel, nil
-}
-
 // WhitelistOptions represent all sorts of whitelists used for protected branches
 type WhitelistOptions struct {
        UserIDs []int64
index 4f082b8a6e7ebf1563e5f657c3f8e75cc7c2b9a4..d1ff4692366d06ca202b04ded0e4bbfdd71d8480 100644 (file)
@@ -510,19 +510,6 @@ func GetLabelIDsInOrgByNames(orgID int64, labelNames []string) ([]int64, error)
                Find(&labelIDs)
 }
 
-// GetLabelIDsInOrgsByNames returns a list of labelIDs by names in one of the given
-// organization.
-// it silently ignores label names that do not belong to the organization.
-func GetLabelIDsInOrgsByNames(orgIDs []int64, labelNames []string) ([]int64, error) {
-       labelIDs := make([]int64, 0, len(labelNames))
-       return labelIDs, x.Table("label").
-               In("org_id", orgIDs).
-               In("name", labelNames).
-               Asc("name").
-               Cols("id").
-               Find(&labelIDs)
-}
-
 // GetLabelInOrgByID returns a label by ID in given organization.
 func GetLabelInOrgByID(orgID, labelID int64) (*Label, error) {
        return getLabelInOrgByID(x, orgID, labelID)
index 90f6523d4aff10431e0f7c24c452da1c2c267df9..c8abb1cd49ce5febfac530f9a8357e33c89b7e23 100644 (file)
@@ -131,11 +131,11 @@ func (repo *Repository) CountLFSMetaObjects() (int64, error) {
 func LFSObjectAccessible(user *User, oid string) (bool, error) {
        if user.IsAdmin {
                count, err := x.Count(&LFSMetaObject{Pointer: lfs.Pointer{Oid: oid}})
-               return (count > 0), err
+               return count > 0, err
        }
        cond := accessibleRepositoryCondition(user)
        count, err := x.Where(cond).Join("INNER", "repository", "`lfs_meta_object`.repository_id = `repository`.id").Count(&LFSMetaObject{Pointer: lfs.Pointer{Oid: oid}})
-       return (count > 0), err
+       return count > 0, err
 }
 
 // LFSAutoAssociate auto associates accessible LFSMetaObjects
index cd4bbcccfa231ae097f3f8a6dc542a8714fc01bd..10ba2c99f897346625dfca427a57e9fbe04689f9 100644 (file)
@@ -75,7 +75,7 @@ func TestGetRepositoryCount(t *testing.T) {
        assert.NoError(t, err2)
        assert.NoError(t, err3)
        assert.Equal(t, int64(3), count)
-       assert.Equal(t, (privateCount + publicCount), count)
+       assert.Equal(t, privateCount+publicCount, count)
 }
 
 func TestGetPublicRepositoryCount(t *testing.T) {
index aacf2957e3d4baee221ba7e5428eb81e4a91fea6..cdb82603cdf1ee1a26376da7b60b6eeb2c638bd6 100644 (file)
@@ -76,9 +76,6 @@ const (
 )
 
 var (
-       // ErrUserNotKeyOwner user does not own this key error
-       ErrUserNotKeyOwner = errors.New("User does not own this public key")
-
        // ErrEmailNotExist e-mail does not exist error
        ErrEmailNotExist = errors.New("E-mail does not exist")
 
index 74678459cfe44857b0961d100326917bc0ed5fa3..0e2767212e9d448a7df20665404af3e5da5d0c3b 100644 (file)
@@ -65,7 +65,7 @@ func getUserHeatmapData(user *User, team *Team, doer *User) ([]*UserHeatmapData,
                Select(groupBy+" AS timestamp, count(user_id) as contributions").
                Table("action").
                Where(cond).
-               And("created_unix > ?", (timeutil.TimeStampNow() - 31536000)).
+               And("created_unix > ?", timeutil.TimeStampNow()-31536000).
                GroupBy(groupByName).
                OrderBy("timestamp").
                Find(&hdata)
index 18cf51c6b68eb26ca443502a86187b8bf43e3eaf..597f19d77d6eebada789b250dfd73b1cf55a685f 100644 (file)
@@ -35,6 +35,7 @@ func GetUserOpenIDs(uid int64) ([]*UserOpenID, error) {
        return openids, nil
 }
 
+// isOpenIDUsed returns true if the openid has been used.
 func isOpenIDUsed(e Engine, uri string) (bool, error) {
        if len(uri) == 0 {
                return true, nil
@@ -43,11 +44,6 @@ func isOpenIDUsed(e Engine, uri string) (bool, error) {
        return e.Get(&UserOpenID{URI: uri})
 }
 
-// IsOpenIDUsed returns true if the openid has been used.
-func IsOpenIDUsed(openid string) (bool, error) {
-       return isOpenIDUsed(x, openid)
-}
-
 // NOTE: make sure openid.URI is normalized already
 func addUserOpenID(e Engine, openid *UserOpenID) error {
        used, err := isOpenIDUsed(e, openid.URI)
index 25621bf8019e01452ae519070d766db0383ab981..8a4b2a898575604567d1daa5f3e0e0f02ddb2a94 100644 (file)
@@ -122,9 +122,7 @@ func (s *linkifyParser) Parse(parent ast.Node, block text.Reader, pc parser.Cont
                        }
                }
        }
-       if m == nil {
-               return nil
-       }
+
        if consumes != 0 {
                s := segment.WithStop(segment.Start + 1)
                ast.MergeOrAppendTextSegment(parent, s)
index 9d57f4eb7b903880656ec7dbd6438fac8b854f0c..e42e38a0f02a4ce26c043d7133a4770b5659df13 100644 (file)
@@ -8,7 +8,6 @@ package process
 import (
        "bytes"
        "context"
-       "errors"
        "fmt"
        "io"
        "os/exec"
@@ -22,10 +21,8 @@ import (
 // then we delete the singleton.
 
 var (
-       // ErrExecTimeout represent a timeout error
-       ErrExecTimeout = errors.New("Process execution timeout")
-       manager        *Manager
-       managerInit    sync.Once
+       manager     *Manager
+       managerInit sync.Once
 
        // DefaultContext is the default context to run processing commands in
        DefaultContext = context.Background()
index 2cd0ba0b953c243df71419a43506b77a21891a16..94478e6f05c4bb2d8451603a5ecda409db047ca5 100644 (file)
@@ -23,7 +23,7 @@ type UniqueByteFIFO interface {
        Has(data []byte) (bool, error)
 }
 
-var _ (ByteFIFO) = &DummyByteFIFO{}
+var _ ByteFIFO = &DummyByteFIFO{}
 
 // DummyByteFIFO represents a dummy fifo
 type DummyByteFIFO struct{}
@@ -48,7 +48,7 @@ func (*DummyByteFIFO) Len() int64 {
        return 0
 }
 
-var _ (UniqueByteFIFO) = &DummyUniqueByteFIFO{}
+var _ UniqueByteFIFO = &DummyUniqueByteFIFO{}
 
 // DummyUniqueByteFIFO represents a dummy unique fifo
 type DummyUniqueByteFIFO struct {
index 161c2fe8e70ead76df52214c4ab6e0f1f1b6c31a..e0368bce3a506a13c12363aaba15576f98dc13b7 100644 (file)
@@ -50,7 +50,7 @@ func toConfig(exemplar, cfg interface{}) (interface{}, error) {
                var err error
 
                configBytes, err = json.Marshal(cfg)
-               ok = (err == nil)
+               ok = err == nil
        }
        if !ok {
                // no ... we've tried hard enough at this point - throw an error!
index fe5178ff2d286d243f137cd32b5925839f14ff5a..bc86078493307982059541a66f884c57b59981ce 100644 (file)
@@ -21,7 +21,7 @@ type ByteFIFOQueueConfiguration struct {
        Name    string
 }
 
-var _ (Queue) = &ByteFIFOQueue{}
+var _ Queue = &ByteFIFOQueue{}
 
 // ByteFIFOQueue is a Queue formed from a ByteFIFO and WorkerPool
 type ByteFIFOQueue struct {
@@ -196,7 +196,7 @@ func (q *ByteFIFOQueue) IsTerminated() <-chan struct{} {
        return q.terminated
 }
 
-var _ (UniqueQueue) = &ByteFIFOUniqueQueue{}
+var _ UniqueQueue = &ByteFIFOUniqueQueue{}
 
 // ByteFIFOUniqueQueue represents a UniqueQueue formed from a UniqueByteFifo
 type ByteFIFOUniqueQueue struct {
index 88b8c414c0b17eebc5c2cbc9d4e7c1d87504525f..6c15a8e63be2901dc36e424126e6bf1bc24eace0 100644 (file)
@@ -55,7 +55,7 @@ func NewLevelQueue(handle HandlerFunc, cfg, exemplar interface{}) (Queue, error)
        return queue, nil
 }
 
-var _ (ByteFIFO) = &LevelQueueByteFIFO{}
+var _ ByteFIFO = &LevelQueueByteFIFO{}
 
 // LevelQueueByteFIFO represents a ByteFIFO formed from a LevelQueue
 type LevelQueueByteFIFO struct {
index 2b1d36f0ad1f44cc736daf2c6bca297282253739..af2cc30335b78785e0dd19e428329abc26093514 100644 (file)
@@ -69,7 +69,7 @@ type redisClient interface {
        Close() error
 }
 
-var _ (ByteFIFO) = &RedisByteFIFO{}
+var _ ByteFIFO = &RedisByteFIFO{}
 
 // RedisByteFIFO represents a ByteFIFO formed from a redisClient
 type RedisByteFIFO struct {
index dd6ac1a538506665b950fb49a2ae73122d6eea93..8ec8848bc498b48cbc6bffaecb5f96e6f28c562d 100644 (file)
@@ -59,7 +59,7 @@ func NewLevelUniqueQueue(handle HandlerFunc, cfg, exemplar interface{}) (Queue,
        return queue, nil
 }
 
-var _ (UniqueByteFIFO) = &LevelUniqueQueueByteFIFO{}
+var _ UniqueByteFIFO = &LevelUniqueQueueByteFIFO{}
 
 // LevelUniqueQueueByteFIFO represents a ByteFIFO formed from a LevelUniqueQueue
 type LevelUniqueQueueByteFIFO struct {
index 96fcad1a830a541c8264285465d655f31691b49a..20a50cc1f235f50b4ae7ddb042f7cab594878bfc 100644 (file)
@@ -62,7 +62,7 @@ func NewRedisUniqueQueue(handle HandlerFunc, cfg, exemplar interface{}) (Queue,
        return queue, nil
 }
 
-var _ (UniqueByteFIFO) = &RedisUniqueByteFIFO{}
+var _ UniqueByteFIFO = &RedisUniqueByteFIFO{}
 
 // RedisUniqueByteFIFO represents a UniqueByteFIFO formed from a redisClient
 type RedisUniqueByteFIFO struct {
index c243f25f5d44a768ec29ec7d57b9d4d5b5306867..6c0db0cf4761a459f5b985c7de10d9a89c44d7b9 100644 (file)
@@ -296,7 +296,7 @@ func convertFullHTMLReferencesToShortRefs(re *regexp.Regexp, contentBytes *[]byt
 
                // our new section has length endPos - match[3]
                // our old section has length match[9] - match[3]
-               (*contentBytes) = (*contentBytes)[:len((*contentBytes))-match[9]+endPos]
+               *contentBytes = (*contentBytes)[:len(*contentBytes)-match[9]+endPos]
                pos = endPos
        }
 }
index 52cc89dbae1b573def06851565f6f6f0f10023a6..d7e3ff452588c3c81202137081accbe47649d3be 100644 (file)
@@ -201,7 +201,7 @@ func UpdateIssuesCommit(doer *models.User, repo *models.Repository, commits []*r
                                        continue
                                }
                        }
-                       close := (ref.Action == references.XRefActionCloses)
+                       close := ref.Action == references.XRefActionCloses
                        if close && len(ref.TimeLog) > 0 {
                                if err := issueAddTime(refIssue, doer, c.Timestamp, ref.TimeLog); err != nil {
                                        return err
index 280987ed66e4016f2464ff396676aefc9bd8efda..f609edba179b120a8e50b8c5506ea3372050d776 100644 (file)
@@ -318,7 +318,6 @@ var (
        LogRootPath        string
        DisableRouterLog   bool
        RouterLogLevel     log.Level
-       RouterLogMode      string
        EnableAccessLog    bool
        AccessLogTemplate  string
        EnableXORMLog      bool
@@ -408,10 +407,6 @@ var (
        IsWindows     bool
        HasRobotsTxt  bool
        InternalToken string // internal access token
-
-       // UILocation is the location on the UI, so that we can display the time on UI.
-       // Currently only show the default time.Local, it could be added to app.ini after UI is ready
-       UILocation = time.Local
 )
 
 // IsProd if it's a production mode
index 46ab82aed61423853a2f95a57000ecbb688da691..4d8ba8e6d9dd981be913ba3efb380cb49dbfd5fa 100644 (file)
@@ -50,7 +50,7 @@ func toConfig(exemplar, cfg interface{}) (interface{}, error) {
                var err error
 
                configBytes, err = json.Marshal(cfg)
-               ok = (err == nil)
+               ok = err == nil
        }
        if !ok {
                // no ... we've tried hard enough at this point - throw an error!
index 65f8978e5a1b5c2b229bda24c0f80a31358c9f12..984f154db48be41f99f0749cacda84158fbb9e1f 100644 (file)
@@ -19,8 +19,6 @@ import (
 var (
        // ErrURLNotSupported represents url is not supported
        ErrURLNotSupported = errors.New("url method not supported")
-       // ErrIterateObjectsNotSupported represents IterateObjects not supported
-       ErrIterateObjectsNotSupported = errors.New("iterateObjects method not supported")
 )
 
 // ErrInvalidConfiguration is called when there is invalid configuration for a storage
index 99bbd9eefeee070a21920250bbb7073aedd5ef8f..bc86bbcbe3d9da3e5897bbf148593da676621d5b 100644 (file)
@@ -660,7 +660,7 @@ func SearchTeam(ctx *context.APIContext) {
                UserID:      ctx.User.ID,
                Keyword:     strings.TrimSpace(ctx.Query("q")),
                OrgID:       ctx.Org.Organization.ID,
-               IncludeDesc: (ctx.Query("include_desc") == "" || ctx.QueryBool("include_desc")),
+               IncludeDesc: ctx.Query("include_desc") == "" || ctx.QueryBool("include_desc"),
                ListOptions: listOptions,
        }
 
index 683a2a43b7db0398446a01ac8aedfe728c9fee34..6b46dc0fef531a2ae92f5f9d43a0c4fe2d9713ac 100644 (file)
@@ -141,7 +141,6 @@ func SearchIssues(ctx *context.APIContext) {
                keyword = ""
        }
        var issueIDs []int64
-       var labelIDs []int64
        if len(keyword) > 0 && len(repoIDs) > 0 {
                if issueIDs, err = issue_indexer.SearchIssuesByKeyword(repoIDs, keyword); err != nil {
                        ctx.Error(http.StatusInternalServerError, "SearchIssuesByKeyword", err)
@@ -176,7 +175,7 @@ func SearchIssues(ctx *context.APIContext) {
 
        // Only fetch the issues if we either don't have a keyword or the search returned issues
        // This would otherwise return all issues if no issues were found by the search.
-       if len(keyword) == 0 || len(issueIDs) > 0 || len(labelIDs) > 0 {
+       if len(keyword) == 0 || len(issueIDs) > 0 || len(includedLabelNames) > 0 {
                issuesOpt := &models.IssuesOptions{
                        ListOptions: models.ListOptions{
                                Page:     ctx.QueryInt("page"),
@@ -675,7 +674,7 @@ func EditIssue(ctx *context.APIContext) {
                }
        }
        if form.State != nil {
-               issue.IsClosed = (api.StateClosed == api.StateType(*form.State))
+               issue.IsClosed = api.StateClosed == api.StateType(*form.State)
        }
        statusChangeComment, titleChanged, err := models.UpdateIssueByAPI(issue, ctx.User)
        if err != nil {
index 2d16e801db8e0d01757483301e663f484a57b861..eff998ee996a18a8ec7e2d107f6085cbdf840c2d 100644 (file)
@@ -580,7 +580,7 @@ func EditPullRequest(ctx *context.APIContext) {
        }
 
        if form.State != nil {
-               issue.IsClosed = (api.StateClosed == api.StateType(*form.State))
+               issue.IsClosed = api.StateClosed == api.StateType(*form.State)
        }
        statusChangeComment, titleChanged, err := models.UpdateIssueByAPI(issue, ctx.User)
        if err != nil {
index 7542f5681ae04ea885b324c2fa50ae821393e900..2c1034038fbb2e0526547f0fa6f74ada3269cc0d 100644 (file)
@@ -32,10 +32,10 @@ func Events(ctx *context.Context) {
 
        if !ctx.IsSigned {
                // Return unauthorized status event
-               event := (&eventsource.Event{
+               event := &eventsource.Event{
                        Name: "close",
                        Data: "unauthorized",
-               })
+               }
                _, _ = event.WriteTo(ctx)
                ctx.Resp.Flush()
                return
@@ -137,10 +137,10 @@ loop:
                                        break loop
                                }
                                // Replace the event - we don't want to expose the session ID to the user
-                               event = (&eventsource.Event{
+                               event = &eventsource.Event{
                                        Name: "logout",
                                        Data: "elsewhere",
-                               })
+                               }
                        }
 
                        _, err := event.WriteTo(ctx.Resp)
index 520ded33b41775e309bc2b37aacecb81e62f3c45..e612cd767cf3104eb4671d498897f9889e70ab63 100644 (file)
@@ -193,7 +193,7 @@ func NewTeamPost(ctx *context.Context) {
        ctx.Data["PageIsOrgTeams"] = true
        ctx.Data["PageIsOrgTeamsNew"] = true
        ctx.Data["Units"] = models.Units
-       var includesAllRepositories = (form.RepoAccess == "all")
+       var includesAllRepositories = form.RepoAccess == "all"
 
        t := &models.Team{
                OrgID:                   ctx.Org.Organization.ID,
@@ -286,7 +286,7 @@ func EditTeamPost(ctx *context.Context) {
 
        isAuthChanged := false
        isIncludeAllChanged := false
-       var includesAllRepositories = (form.RepoAccess == "all")
+       var includesAllRepositories = form.RepoAccess == "all"
        if !t.IsOwnerTeam() {
                // Validate permission level.
                auth := models.ParseAccessMode(form.Permission)
index 0377979e8bb5c024defc3d1f27ae9d3fdae4d1c3..2b79dddbbd69a813f675a119233f397b359f7662 100644 (file)
@@ -91,7 +91,7 @@ func httpBase(ctx *context.Context) (h *serviceHandler) {
                strings.HasSuffix(ctx.Req.URL.Path, "git-upload-archive") {
                isPull = true
        } else {
-               isPull = (ctx.Req.Method == "GET")
+               isPull = ctx.Req.Method == "GET"
        }
 
        var accessMode models.AccessMode
index 4475e35f630c1e559b606caad22ce521588c8398..da3772ef5a693c7a6fd2a1996749641e674aaffc 100644 (file)
@@ -52,8 +52,6 @@ const (
 )
 
 var (
-       // ErrTooManyFiles upload too many files
-       ErrTooManyFiles = errors.New("Maximum number of files to upload exceeded")
        // IssueTemplateCandidates issue templates
        IssueTemplateCandidates = []string{
                "ISSUE_TEMPLATE.md",
index c395a394c298505e93353e18bec1afad0d8ec24c..fba2c095cf936fdb7209650fc6981e23208b4c2b 100644 (file)
@@ -130,16 +130,16 @@ func SettingsProtectedBranch(c *context.Context) {
        c.Data["merge_whitelist_users"] = strings.Join(base.Int64sToStrings(protectBranch.MergeWhitelistUserIDs), ",")
        c.Data["approvals_whitelist_users"] = strings.Join(base.Int64sToStrings(protectBranch.ApprovalsWhitelistUserIDs), ",")
        contexts, _ := models.FindRepoRecentCommitStatusContexts(c.Repo.Repository.ID, 7*24*time.Hour) // Find last week status check contexts
-       for _, context := range protectBranch.StatusCheckContexts {
+       for _, ctx := range protectBranch.StatusCheckContexts {
                var found bool
-               for _, ctx := range contexts {
-                       if ctx == context {
+               for i := range contexts {
+                       if contexts[i] == ctx {
                                found = true
                                break
                        }
                }
                if !found {
-                       contexts = append(contexts, context)
+                       contexts = append(contexts, ctx)
                }
        }
 
index 3436a44baedc32b37a3e4ce45927715eda8afc6f..431ffdde8e5276525016ddd077306b190774425d 100644 (file)
@@ -770,9 +770,6 @@ func getActiveTeamOrOrgRepoIds(ctxUser *models.User, team *models.Team, unitType
 
        if team != nil {
                env = ctxUser.AccessibleTeamReposEnv(team)
-               if err != nil {
-                       return nil, fmt.Errorf("AccessibleTeamReposEnv: %v", err)
-               }
        } else {
                env, err = ctxUser.AccessibleReposEnv(ctxUser.ID)
                if err != nil {
index bbe631f68c9979632523ef9dd577f0c27bf0ba51..518ffa48492a7af4c84d8a2e96f081a26b331582 100644 (file)
@@ -98,7 +98,7 @@ func Merge(pr *models.PullRequest, doer *models.User, baseGitRepo *git.Repositor
                if err = ref.Issue.LoadRepo(); err != nil {
                        return err
                }
-               close := (ref.RefAction == references.XRefActionCloses)
+               close := ref.RefAction == references.XRefActionCloses
                if close != ref.Issue.IsClosed {
                        if err = issue_service.ChangeStatus(ref.Issue, doer, close); err != nil {
                                return err