Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove check for negative length #5120

Merged
merged 4 commits into from
Oct 20, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion models/issue_label.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func NewLabels(labels ...*Label) error {
// If pass repoID as 0, then ORM will ignore limitation of repository
// and can return arbitrary label with any valid ID.
func getLabelInRepoByName(e Engine, repoID int64, labelName string) (*Label, error) {
if len(labelName) <= 0 {
if len(labelName) == 0 {
return nil, ErrLabelNotExist{0, repoID}
}

Expand Down
4 changes: 2 additions & 2 deletions models/org.go
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ func (env *accessibleReposEnv) Repos(page, pageSize int) ([]*Repository, error)
}

repos := make([]*Repository, 0, len(repoIDs))
if len(repoIDs) <= 0 {
if len(repoIDs) == 0 {
return repos, nil
}

Expand Down Expand Up @@ -705,7 +705,7 @@ func (env *accessibleReposEnv) MirrorRepos() ([]*Repository, error) {
}

repos := make([]*Repository, 0, len(repoIDs))
if len(repoIDs) <= 0 {
if len(repoIDs) == 0 {
return repos, nil
}

Expand Down
2 changes: 1 addition & 1 deletion models/ssh_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ func calcFingerprint(publicKeyContent string) (string, error) {
}

func addKey(e Engine, key *PublicKey) (err error) {
if len(key.Fingerprint) <= 0 {
if len(key.Fingerprint) == 0 {
key.Fingerprint, err = calcFingerprint(key.Content)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion modules/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func SignedInID(ctx *macaron.Context, sess session.Store) int64 {
// Check access token.
if IsAPIPath(ctx.Req.URL.Path) {
tokenSHA := ctx.Query("token")
if len(tokenSHA) <= 0 {
if len(tokenSHA) == 0 {
tokenSHA = ctx.Query("access_token")
}
if len(tokenSHA) == 0 {
Expand Down
2 changes: 1 addition & 1 deletion modules/user/user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func getWhoamiOutput() (string, error) {

func TestCurrentUsername(t *testing.T) {
user := CurrentUsername()
if len(user) <= 0 {
if len(user) == 0 {
t.Errorf("expected non-empty user, got: %s", user)
}
// Windows whoami is weird, so just skip remaining tests
Expand Down
2 changes: 1 addition & 1 deletion routers/api/v1/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ import (
func sudo() macaron.Handler {
return func(ctx *context.APIContext) {
sudo := ctx.Query("sudo")
if len(sudo) <= 0 {
if len(sudo) == 0 {
sudo = ctx.Req.Header.Get("Sudo")
}

Expand Down
2 changes: 1 addition & 1 deletion routers/user/home.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ func Issues(ctx *context.Context) {
return
}
}
if len(userRepoIDs) <= 0 {
if len(userRepoIDs) == 0 {
userRepoIDs = []int64{-1}
}

Expand Down