Skip to content

Commit 5a4648c

Browse files
cristalolegtechknowlogick
authored andcommitted
Remove check for negative length (#5120)
1 parent 583b1b8 commit 5a4648c

File tree

7 files changed

+8
-8
lines changed

7 files changed

+8
-8
lines changed

models/issue_label.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ func NewLabels(labels ...*Label) error {
134134
// If pass repoID as 0, then ORM will ignore limitation of repository
135135
// and can return arbitrary label with any valid ID.
136136
func getLabelInRepoByName(e Engine, repoID int64, labelName string) (*Label, error) {
137-
if len(labelName) <= 0 {
137+
if len(labelName) == 0 {
138138
return nil, ErrLabelNotExist{0, repoID}
139139
}
140140

models/org.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ func (env *accessibleReposEnv) Repos(page, pageSize int) ([]*Repository, error)
677677
}
678678

679679
repos := make([]*Repository, 0, len(repoIDs))
680-
if len(repoIDs) <= 0 {
680+
if len(repoIDs) == 0 {
681681
return repos, nil
682682
}
683683

@@ -705,7 +705,7 @@ func (env *accessibleReposEnv) MirrorRepos() ([]*Repository, error) {
705705
}
706706

707707
repos := make([]*Repository, 0, len(repoIDs))
708-
if len(repoIDs) <= 0 {
708+
if len(repoIDs) == 0 {
709709
return repos, nil
710710
}
711711

models/ssh_key.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ func calcFingerprint(publicKeyContent string) (string, error) {
376376
}
377377

378378
func addKey(e Engine, key *PublicKey) (err error) {
379-
if len(key.Fingerprint) <= 0 {
379+
if len(key.Fingerprint) == 0 {
380380
key.Fingerprint, err = calcFingerprint(key.Content)
381381
if err != nil {
382382
return err

modules/auth/auth.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func SignedInID(ctx *macaron.Context, sess session.Store) int64 {
3636
// Check access token.
3737
if IsAPIPath(ctx.Req.URL.Path) {
3838
tokenSHA := ctx.Query("token")
39-
if len(tokenSHA) <= 0 {
39+
if len(tokenSHA) == 0 {
4040
tokenSHA = ctx.Query("access_token")
4141
}
4242
if len(tokenSHA) == 0 {

modules/user/user_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func getWhoamiOutput() (string, error) {
1818

1919
func TestCurrentUsername(t *testing.T) {
2020
user := CurrentUsername()
21-
if len(user) <= 0 {
21+
if len(user) == 0 {
2222
t.Errorf("expected non-empty user, got: %s", user)
2323
}
2424
// Windows whoami is weird, so just skip remaining tests

routers/api/v1/api.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ import (
8080
func sudo() macaron.Handler {
8181
return func(ctx *context.APIContext) {
8282
sudo := ctx.Query("sudo")
83-
if len(sudo) <= 0 {
83+
if len(sudo) == 0 {
8484
sudo = ctx.Req.Header.Get("Sudo")
8585
}
8686

routers/user/home.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ func Issues(ctx *context.Context) {
213213
return
214214
}
215215
}
216-
if len(userRepoIDs) <= 0 {
216+
if len(userRepoIDs) == 0 {
217217
userRepoIDs = []int64{-1}
218218
}
219219

0 commit comments

Comments
 (0)