You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Eng Zer Jun 13d5d2e711
Remove redundant `len` check around loop (#27464)
This pull request is a minor code cleanup.

From the Go specification (https://go.dev/ref/spec#For_range):

> "1. For a nil slice, the number of iterations is 0."
> "3. If the map is nil, the number of iterations is 0."

`len` returns 0 if the slice or map is nil
(https://pkg.go.dev/builtin#len). Therefore, checking `len(v) > 0`
before a loop is unnecessary.

---

At the time of writing this pull request, there wasn't a lint rule that
catches these issues. The closest I could find is
https://staticcheck.dev/docs/checks/#S103

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
9 months ago
..
actions Even more `db.DefaultContext` refactor (#27352) 9 months ago
setting Even more `db.DefaultContext` refactor (#27352) 9 months ago
activity.go Implement FSFE REUSE for golang files (#21840) 2 years ago
attachment.go Even more `db.DefaultContext` refactor (#27352) 9 months ago
blame.go Improve tree not found page (#26570) 9 months ago
branch.go Search branches (#27055) 10 months ago
cherry_pick.go Sync branches into databases (#22743) 1 year ago
commit.go Even more `db.DefaultContext` refactor (#27352) 9 months ago
compare.go When comparing with an non-exist repository, return 404 but 500 (#27437) 9 months ago
download.go Less naked returns (#25713) 1 year ago
editor.go Improve tree not found page (#26570) 9 months ago
editor_test.go Move web/api context related testing function into a separate package (#26859) 10 months ago
find.go Implement FSFE REUSE for golang files (#21840) 2 years ago
helper.go Improve tree not found page (#26570) 9 months ago
helper_test.go Make web context initialize correctly for different cases (#26726) 10 months ago
http.go More refactoring of `db.DefaultContext` (#27083) 10 months ago
http_test.go Implement FSFE REUSE for golang files (#21840) 2 years ago
issue.go Remove redundant `len` check around loop (#27464) 9 months ago
issue_content_history.go Improve issue history dialog and make poster can delete their own history (#27323) 9 months ago
issue_dependency.go Add context parameter to some database functions (#26055) 12 months ago
issue_label.go Even more `db.DefaultContext` refactor (#27352) 9 months ago
issue_label_test.go Move web/api context related testing function into a separate package (#26859) 10 months ago
issue_lock.go Use fetch form action for lock/unlock/pin/unpin on sidebar (#25380) 1 year ago
issue_pin.go Add context parameter to some database functions (#26055) 12 months ago
issue_stopwatch.go Next round of `db.DefaultContext` refactor (#27089) 10 months ago
issue_test.go Implement FSFE REUSE for golang files (#21840) 2 years ago
issue_timetrack.go Even more `db.DefaultContext` refactor (#27352) 9 months ago
issue_watch.go Next round of `db.DefaultContext` refactor (#27089) 10 months ago
main_test.go make writing main test easier (#27270) 9 months ago
middlewares.go More refactoring of `db.DefaultContext` (#27083) 10 months ago
migrate.go Next round of `db.DefaultContext` refactor (#27089) 10 months ago
milestone.go Next round of `db.DefaultContext` refactor (#27089) 10 months ago
packages.go Fix the display of org level badges (#26504) 10 months ago
patch.go Sync branches into databases (#22743) 1 year ago
projects.go More `db.DefaultContext` refactor (#27265) 9 months ago
projects_test.go Move web/api context related testing function into a separate package (#26859) 10 months ago
pull.go Even more `db.DefaultContext` refactor (#27352) 9 months ago
pull_review.go More `db.DefaultContext` refactor (#27265) 9 months ago
release.go Improvements of releases list and tags list (#25859) 9 months ago
release_test.go Improvements of releases list and tags list (#25859) 9 months ago
render.go Implement FSFE REUSE for golang files (#21840) 2 years ago
repo.go Even more `db.DefaultContext` refactor (#27352) 9 months ago
search.go Refactor indexer (#25174) 1 year ago
topic.go Next round of `db.DefaultContext` refactor (#27089) 10 months ago
treelist.go Implement FSFE REUSE for golang files (#21840) 2 years ago
view.go Document the line-number counting behavior (#27386) 9 months ago
view_test.go Implement FSFE REUSE for golang files (#21840) 2 years ago
wiki.go Move notification interface to services layer (#26915) 10 months ago
wiki_test.go Move web/api context related testing function into a separate package (#26859) 10 months ago