diff --git a/.golangci.yml b/.golangci.yml index 62c1d005fa..ba4f81b521 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -18,6 +18,7 @@ linters: - mirror - modernize - nakedret + - nilnil - nolintlint - perfsprint - revive diff --git a/models/activities/action_list.go b/models/activities/action_list.go index b52cf7ee49..29ff2fdf7a 100644 --- a/models/activities/action_list.go +++ b/models/activities/action_list.go @@ -30,7 +30,7 @@ func (actions ActionList) getUserIDs() []int64 { func (actions ActionList) LoadActUsers(ctx context.Context) (map[int64]*user_model.User, error) { if len(actions) == 0 { - return nil, nil + return nil, nil //nolint:nilnil // returns nil when there are no actions } userIDs := actions.getUserIDs() diff --git a/models/asymkey/gpg_key_commit_verification.go b/models/asymkey/gpg_key_commit_verification.go index 375b703f7b..ae5192de9f 100644 --- a/models/asymkey/gpg_key_commit_verification.go +++ b/models/asymkey/gpg_key_commit_verification.go @@ -70,7 +70,7 @@ func hashAndVerify(sig *packet.Signature, payload string, k *GPGKey) (*GPGKey, e // We will ignore errors in verification as they don't need to be propagated up err = verifySign(sig, hash, k) if err != nil { - return nil, nil + return nil, nil //nolint:nilnil // verification failed, not an error } return k, nil } @@ -86,7 +86,7 @@ func hashAndVerifyWithSubKeys(sig *packet.Signature, payload string, k *GPGKey) return verified, err } } - return nil, nil + return nil, nil //nolint:nilnil // verification failed, not an error } func HashAndVerifyWithSubKeysCommitVerification(sig *packet.Signature, payload string, k *GPGKey, committer, signer *user_model.User, email string) *CommitVerification { diff --git a/models/auth/oauth2.go b/models/auth/oauth2.go index d664841306..2f5aff0933 100644 --- a/models/auth/oauth2.go +++ b/models/auth/oauth2.go @@ -209,7 +209,7 @@ func (app *OAuth2Application) GetGrantByUserID(ctx context.Context, userID int64 if has, err := db.GetEngine(ctx).Where("user_id = ? AND application_id = ?", userID, app.ID).Get(grant); err != nil { return nil, err } else if !has { - return nil, nil + return nil, nil //nolint:nilnil // return nil to indicate that the object does not exist } return grant, nil } @@ -431,13 +431,13 @@ func GetOAuth2AuthorizationByCode(ctx context.Context, code string) (auth *OAuth if has, err := db.GetEngine(ctx).Where("code = ?", code).Get(auth); err != nil { return nil, err } else if !has { - return nil, nil + return nil, nil //nolint:nilnil // return nil to indicate that the object does not exist } auth.Grant = new(OAuth2Grant) if has, err := db.GetEngine(ctx).ID(auth.GrantID).Get(auth.Grant); err != nil { return nil, err } else if !has { - return nil, nil + return nil, nil //nolint:nilnil // return nil to indicate that the object does not exist } return auth, nil } @@ -521,7 +521,7 @@ func GetOAuth2GrantByID(ctx context.Context, id int64) (grant *OAuth2Grant, err if has, err := db.GetEngine(ctx).ID(id).Get(grant); err != nil { return nil, err } else if !has { - return nil, nil + return nil, nil //nolint:nilnil // return nil to indicate that the object does not exist } return grant, err } diff --git a/models/db/collation.go b/models/db/collation.go index 79ade87380..203f7cbfe4 100644 --- a/models/db/collation.go +++ b/models/db/collation.go @@ -98,7 +98,7 @@ func CheckCollations(x *xorm.Engine) (*CheckCollationsResult, error) { return nil, err } } else { - return nil, nil + return nil, nil //nolint:nilnil // return nil for unsupported database types } if res.DatabaseCollation == "" { diff --git a/models/dbfs/dbfile.go b/models/dbfs/dbfile.go index eaf506fbe6..ccb13583e1 100644 --- a/models/dbfs/dbfile.go +++ b/models/dbfs/dbfile.go @@ -339,7 +339,7 @@ func findFileMetaByID(ctx context.Context, metaID int64) (*dbfsMeta, error) { } else if ok { return &fileMeta, nil } - return nil, nil + return nil, nil //nolint:nilnil // return nil to indicate that the object does not exist } func buildPath(path string) string { diff --git a/models/git/lfs_lock.go b/models/git/lfs_lock.go index aabed6b7fa..8e63598fb2 100644 --- a/models/git/lfs_lock.go +++ b/models/git/lfs_lock.go @@ -130,7 +130,7 @@ func GetLFSLockByRepoID(ctx context.Context, repoID int64, page, pageSize int) ( // GetTreePathLock returns LSF lock for the treePath func GetTreePathLock(ctx context.Context, repoID int64, treePath string) (*LFSLock, error) { if !setting.LFS.StartServer { - return nil, nil + return nil, nil //nolint:nilnil // return nil when LFS is not started } locks, err := GetLFSLockByRepoID(ctx, repoID, 0, 0) @@ -142,7 +142,7 @@ func GetTreePathLock(ctx context.Context, repoID int64, treePath string) (*LFSLo return lock, nil } } - return nil, nil + return nil, nil //nolint:nilnil // return nil to indicate that the object does not exist } // CountLFSLockByRepoID returns a count of all LFSLocks associated with a repository. diff --git a/models/git/protected_branch.go b/models/git/protected_branch.go index 1085c14cae..f4567a0aac 100644 --- a/models/git/protected_branch.go +++ b/models/git/protected_branch.go @@ -318,7 +318,7 @@ func GetProtectedBranchRuleByName(ctx context.Context, repoID int64, ruleName st if err != nil { return nil, err } else if !exist { - return nil, nil + return nil, nil //nolint:nilnil // return nil to indicate that the object does not exist } return rel, nil } @@ -329,7 +329,7 @@ func GetProtectedBranchRuleByID(ctx context.Context, repoID, ruleID int64) (*Pro if err != nil { return nil, err } else if !exist { - return nil, nil + return nil, nil //nolint:nilnil // return nil to indicate that the object does not exist } return rel, nil } diff --git a/models/git/protected_tag.go b/models/git/protected_tag.go index 95642df593..dc38daf981 100644 --- a/models/git/protected_tag.go +++ b/models/git/protected_tag.go @@ -104,7 +104,7 @@ func GetProtectedTagByID(ctx context.Context, id int64) (*ProtectedTag, error) { return nil, err } if !has { - return nil, nil + return nil, nil //nolint:nilnil // return nil to indicate that the object does not exist } return tag, nil } @@ -117,7 +117,7 @@ func GetProtectedTagByNamePattern(ctx context.Context, repoID int64, pattern str return nil, err } if !has { - return nil, nil + return nil, nil //nolint:nilnil // return nil to indicate that the object does not exist } return tag, nil } diff --git a/models/issues/issue.go b/models/issues/issue.go index f6f27588b3..655cdebdfc 100644 --- a/models/issues/issue.go +++ b/models/issues/issue.go @@ -498,7 +498,7 @@ func (issue *Issue) GetLastComment(ctx context.Context) (*Comment, error) { return nil, err } if !exist { - return nil, nil + return nil, nil //nolint:nilnil // return nil to indicate that the object does not exist } return &c, nil } diff --git a/models/issues/review.go b/models/issues/review.go index d8caa4d13a..10e3fcd664 100644 --- a/models/issues/review.go +++ b/models/issues/review.go @@ -384,7 +384,7 @@ func CreateReview(ctx context.Context, opts CreateReviewOptions) (*Review, error // GetCurrentReview returns the current pending review of reviewer for given issue func GetCurrentReview(ctx context.Context, reviewer *user_model.User, issue *Issue) (*Review, error) { if reviewer == nil { - return nil, nil + return nil, nil //nolint:nilnil // return nil when reviewer is nil } reviews, err := FindReviews(ctx, FindReviewOptions{ Types: []ReviewType{ReviewTypePending}, diff --git a/models/organization/org_user.go b/models/organization/org_user.go index 4d7527c15f..69cd960944 100644 --- a/models/organization/org_user.go +++ b/models/organization/org_user.go @@ -174,13 +174,13 @@ func GetOrgAssignees(ctx context.Context, orgID int64) (_ []*user_model.User, er func loadOrganizationOwners(ctx context.Context, users user_model.UserList, orgID int64) (map[int64]*TeamUser, error) { if len(users) == 0 { - return nil, nil + return nil, nil //nolint:nilnil // return nil when there are no users } ownerTeam, err := GetOwnerTeam(ctx, orgID) if err != nil { if IsErrTeamNotExist(err) { log.Error("Organization does not have owner team: %d", orgID) - return nil, nil + return nil, nil //nolint:nilnil // return nil when owner team does not exist } return nil, err } diff --git a/models/repo/archiver.go b/models/repo/archiver.go index 4f1b7238d7..ca981a178c 100644 --- a/models/repo/archiver.go +++ b/models/repo/archiver.go @@ -107,7 +107,7 @@ func GetRepoArchiver(ctx context.Context, repoID int64, tp ArchiveType, commitID if has { return &archiver, nil } - return nil, nil + return nil, nil //nolint:nilnil // return nil to indicate that the object does not exist } // ExistsRepoArchiverWithStoragePath checks if there is a RepoArchiver for a given storage path diff --git a/models/repo/fork.go b/models/repo/fork.go index 1c75e86458..80b3e5634e 100644 --- a/models/repo/fork.go +++ b/models/repo/fork.go @@ -49,7 +49,7 @@ func GetUserFork(ctx context.Context, repoID, userID int64) (*Repository, error) return nil, err } if !has { - return nil, nil + return nil, nil //nolint:nilnil // return nil to indicate that the object does not exist } return &forkedRepo, nil } diff --git a/models/repo/repo.go b/models/repo/repo.go index 0846dbcd05..07b9bf30cc 100644 --- a/models/repo/repo.go +++ b/models/repo/repo.go @@ -878,7 +878,7 @@ func IsRepositoryModelExist(ctx context.Context, u *user_model.User, repoName st // non-generated repositories, and TemplateRepo will be left untouched) func GetTemplateRepo(ctx context.Context, repo *Repository) (*Repository, error) { if !repo.IsGenerated() { - return nil, nil + return nil, nil //nolint:nilnil // return nil for non-generated repositories } return GetRepositoryByID(ctx, repo.TemplateID) diff --git a/models/repo/topic.go b/models/repo/topic.go index f8f706fc1a..6d5209d821 100644 --- a/models/repo/topic.go +++ b/models/repo/topic.go @@ -257,7 +257,7 @@ func DeleteTopic(ctx context.Context, repoID int64, topicName string) (*Topic, e } if topic == nil { // Repo doesn't have topic, can't be removed - return nil, nil + return nil, nil //nolint:nilnil // return nil to indicate that the topic does not exist } return db.WithTx2(ctx, func(ctx context.Context) (*Topic, error) { diff --git a/models/unittest/fixtures_loader.go b/models/unittest/fixtures_loader.go index d92b0cdb14..5b79cb5643 100644 --- a/models/unittest/fixtures_loader.go +++ b/models/unittest/fixtures_loader.go @@ -169,7 +169,7 @@ func (f *fixturesLoaderInternal) Load() error { func FixturesFileFullPaths(dir string, files []string) (map[string]*FixtureItem, error) { if files != nil && len(files) == 0 { - return nil, nil // load nothing + return nil, nil //nolint:nilnil // load nothing } files = slices.Clone(files) if len(files) == 0 { diff --git a/models/unittest/fixtures_test.go b/models/unittest/fixtures_test.go index ebf209f5f4..879277c9b1 100644 --- a/models/unittest/fixtures_test.go +++ b/models/unittest/fixtures_test.go @@ -16,7 +16,7 @@ import ( ) var NewFixturesLoaderVendor = func(e *xorm.Engine, opts unittest.FixturesOptions) (unittest.FixturesLoader, error) { - return nil, nil + return nil, nil //nolint:nilnil // no vendor fixtures loader configured } /* diff --git a/models/user/block.go b/models/user/block.go index 5f2b65a199..f4afd47d0f 100644 --- a/models/user/block.go +++ b/models/user/block.go @@ -90,7 +90,7 @@ func GetBlocking(ctx context.Context, blockerID, blockeeID int64) (*Blocking, er return nil, err } if len(blocks) == 0 { - return nil, nil + return nil, nil //nolint:nilnil // return nil to indicate that the object does not exist } return blocks[0], nil } diff --git a/models/user/email_address.go b/models/user/email_address.go index 2b58edaeb5..aa483d5f00 100644 --- a/models/user/email_address.go +++ b/models/user/email_address.go @@ -215,7 +215,7 @@ func GetEmailAddressByID(ctx context.Context, uid, id int64) (*EmailAddress, err if has, err := db.GetEngine(ctx).ID(id).Get(email); err != nil { return nil, err } else if !has { - return nil, nil + return nil, nil //nolint:nilnil // return nil to indicate that the object does not exist } return email, nil } diff --git a/models/user/list.go b/models/user/list.go index ca589d1e02..4337c34963 100644 --- a/models/user/list.go +++ b/models/user/list.go @@ -48,7 +48,7 @@ func (users UserList) GetTwoFaStatus(ctx context.Context) map[int64]bool { func (users UserList) loadTwoFactorStatus(ctx context.Context) (map[int64]*auth.TwoFactor, error) { if len(users) == 0 { - return nil, nil + return nil, nil //nolint:nilnil // returns nil when there are no users } userIDs := users.GetUserIDs() diff --git a/models/user/user.go b/models/user/user.go index efed73e99d..f8e8b5c64a 100644 --- a/models/user/user.go +++ b/models/user/user.go @@ -1193,7 +1193,7 @@ func (eum *EmailUserMap) GetByEmail(email string) *User { func GetUsersByEmails(ctx context.Context, emails []string) (*EmailUserMap, error) { if len(emails) == 0 { - return nil, nil + return nil, nil //nolint:nilnil // return nil when there are no emails to look up } needCheckEmails := make(container.Set[string]) diff --git a/modules/git/commit_submodule.go b/modules/git/commit_submodule.go index ff253b7eca..5e5f90c20e 100644 --- a/modules/git/commit_submodule.go +++ b/modules/git/commit_submodule.go @@ -16,7 +16,7 @@ func (c *Commit) GetSubModules() (*ObjectCache[*SubModule], error) { entry, err := c.GetTreeEntryByPath(".gitmodules") if err != nil { if _, ok := err.(ErrNotExist); ok { - return nil, nil + return nil, nil //nolint:nilnil // return nil to indicate that the submodule does not exist } return nil, err } @@ -48,5 +48,5 @@ func (c *Commit) GetSubModule(entryName string) (*SubModule, error) { return module, nil } } - return nil, nil + return nil, nil //nolint:nilnil // return nil to indicate that the submodule does not exist } diff --git a/modules/git/foreachref/parser.go b/modules/git/foreachref/parser.go index 913431795f..91868076b4 100644 --- a/modules/git/foreachref/parser.go +++ b/modules/git/foreachref/parser.go @@ -100,7 +100,7 @@ func (p *Parser) Err() error { func (p *Parser) parseRef(refBlock string) (map[string]string, error) { if refBlock == "" { // must be at EOF - return nil, nil + return nil, nil //nolint:nilnil // return nil to signal EOF } fieldValues := make(map[string]string) diff --git a/modules/git/last_commit_cache.go b/modules/git/last_commit_cache.go index cff2556083..a013773b47 100644 --- a/modules/git/last_commit_cache.go +++ b/modules/git/last_commit_cache.go @@ -55,12 +55,12 @@ func (c *LastCommitCache) Put(ref, entryPath, commitID string) error { // Get gets the last commit information by commit id and entry path func (c *LastCommitCache) Get(ref, entryPath string) (*Commit, error) { if c == nil || c.cache == nil { - return nil, nil + return nil, nil //nolint:nilnil // return nil when cache is not available } commitID, ok := c.cache.Get(getCacheKey(c.repoPath, ref, entryPath)) if !ok || commitID == "" { - return nil, nil + return nil, nil //nolint:nilnil // return nil when cache miss } log.Debug("LastCommitCache hit level 1: [%s:%s:%s]", ref, entryPath, commitID) diff --git a/modules/git/log_name_status.go b/modules/git/log_name_status.go index 8acfc96f26..6e6d9985ae 100644 --- a/modules/git/log_name_status.go +++ b/modules/git/log_name_status.go @@ -106,7 +106,7 @@ func (g *LogNameStatusRepoParser) Next(treepath string, paths2ids map[string]int case bufio.ErrBufferFull: g.buffull = true case io.EOF: - return nil, nil + return nil, nil //nolint:nilnil // return nil to signal EOF default: return nil, err } @@ -121,7 +121,7 @@ func (g *LogNameStatusRepoParser) Next(treepath string, paths2ids map[string]int case bufio.ErrBufferFull: g.buffull = true case io.EOF: - return nil, nil + return nil, nil //nolint:nilnil // return nil to signal EOF default: return nil, err } diff --git a/modules/graceful/net_unix.go b/modules/graceful/net_unix.go index 796e00507c..a06f78dafe 100644 --- a/modules/graceful/net_unix.go +++ b/modules/graceful/net_unix.go @@ -290,11 +290,11 @@ func getActiveListenersToUnlink() []bool { func getNotifySocket() (*net.UnixConn, error) { if err := getProvidedFDs(); err != nil { // This error will be logged elsewhere - return nil, nil + return nil, nil //nolint:nilnil // return nil when no provided FDs are available } if notifySocketAddr == "" { - return nil, nil + return nil, nil //nolint:nilnil // return nil when notify socket is not configured } socketAddr := &net.UnixAddr{ diff --git a/modules/optional/serialization.go b/modules/optional/serialization.go index b120a0edf6..345ce56268 100644 --- a/modules/optional/serialization.go +++ b/modules/optional/serialization.go @@ -37,7 +37,7 @@ func (o *Option[T]) UnmarshalYAML(value *yaml.Node) error { func (o Option[T]) MarshalYAML() (any, error) { if !o.Has() { - return nil, nil + return nil, nil //nolint:nilnil // return nil to indicate no value to marshal } value := new(yaml.Node) diff --git a/routers/api/packages/auth.go b/routers/api/packages/auth.go index b7bf381241..28e5be1e4d 100644 --- a/routers/api/packages/auth.go +++ b/routers/api/packages/auth.go @@ -32,14 +32,14 @@ func (a *Auth) Verify(req *http.Request, w http.ResponseWriter, store auth.DataS } if packageMeta == nil || packageMeta.UserID == 0 { - return nil, nil + return nil, nil //nolint:nilnil // the auth method is not applicable } var u *user_model.User switch packageMeta.UserID { case user_model.GhostUserID: if !a.AllowGhostUser { - return nil, nil + return nil, nil //nolint:nilnil // the auth method is not applicable } u = user_model.NewGhostUser() case user_model.ActionsUserID: diff --git a/routers/api/packages/chef/auth.go b/routers/api/packages/chef/auth.go index c6808300a2..5f7dad9d2d 100644 --- a/routers/api/packages/chef/auth.go +++ b/routers/api/packages/chef/auth.go @@ -61,7 +61,7 @@ func (a *Auth) Verify(req *http.Request, w http.ResponseWriter, store auth.DataS return nil, err } if u == nil { - return nil, nil + return nil, nil //nolint:nilnil // the auth method is not applicable } pub, err := getUserPublicKey(req.Context(), u) @@ -88,7 +88,7 @@ func (a *Auth) Verify(req *http.Request, w http.ResponseWriter, store auth.DataS func getUserFromRequest(req *http.Request) (*user_model.User, error) { username := req.Header.Get("X-Ops-Userid") if username == "" { - return nil, nil + return nil, nil //nolint:nilnil // the auth method is not applicable } return user_model.GetUserByName(req.Context(), username) diff --git a/routers/api/packages/swift/swift.go b/routers/api/packages/swift/swift.go index d84f79a0a8..66c28c9772 100644 --- a/routers/api/packages/swift/swift.go +++ b/routers/api/packages/swift/swift.go @@ -300,7 +300,7 @@ func formFileOptionalReadCloser(ctx *context.Context, formKey string) (io.ReadCl content := ctx.Req.FormValue(formKey) if content == "" { - return nil, nil + return nil, nil //nolint:nilnil // return nil to indicate that the content does not exist } return io.NopCloser(strings.NewReader(content)), nil } diff --git a/routers/common/compare.go b/routers/common/compare.go index 5b6fdba4e0..7e917c4df8 100644 --- a/routers/common/compare.go +++ b/routers/common/compare.go @@ -161,7 +161,7 @@ func GetHeadOwnerAndRepo(ctx context.Context, baseRepo *repo_model.Repository, c func findHeadRepoFromRootBase(ctx context.Context, baseRepo *repo_model.Repository, headUserID int64, traverseLevel int) (*repo_model.Repository, error) { if traverseLevel == 0 { - return nil, nil + return nil, nil //nolint:nilnil // return nil to indicate that the object does not exist } // test if we are lucky repo, err := repo_model.GetUserFork(ctx, baseRepo.ID, headUserID) @@ -185,5 +185,5 @@ func findHeadRepoFromRootBase(ctx context.Context, baseRepo *repo_model.Reposito return forked, nil } } - return nil, nil + return nil, nil //nolint:nilnil // return nil to indicate that the object does not exist } diff --git a/routers/web/repo/setting/secrets.go b/routers/web/repo/setting/secrets.go index c6e2d18249..cd32a7dbb7 100644 --- a/routers/web/repo/setting/secrets.go +++ b/routers/web/repo/setting/secrets.go @@ -46,7 +46,7 @@ func getSecretsCtx(ctx *context.Context) (*secretsCtx, error) { if ctx.Data["PageIsOrgSettings"] == true { if _, err := shared_user.RenderUserOrgHeader(ctx); err != nil { ctx.ServerError("RenderUserOrgHeader", err) - return nil, nil + return nil, nil //nolint:nilnil // error is already handled by ctx.ServerError } return &secretsCtx{ OwnerID: ctx.ContextUser.ID, diff --git a/routers/web/shared/actions/runners.go b/routers/web/shared/actions/runners.go index 648f8046a4..9dca366123 100644 --- a/routers/web/shared/actions/runners.go +++ b/routers/web/shared/actions/runners.go @@ -59,7 +59,7 @@ func getRunnersCtx(ctx *context.Context) (*runnersCtx, error) { if ctx.Data["PageIsOrgSettings"] == true { if _, err := shared_user.RenderUserOrgHeader(ctx); err != nil { ctx.ServerError("RenderUserOrgHeader", err) - return nil, nil + return nil, nil //nolint:nilnil // error is already handled by ctx.ServerError } return &runnersCtx{ RepoID: 0, diff --git a/routers/web/shared/actions/variables.go b/routers/web/shared/actions/variables.go index a43c2c2690..8a8c49f415 100644 --- a/routers/web/shared/actions/variables.go +++ b/routers/web/shared/actions/variables.go @@ -51,7 +51,7 @@ func getVariablesCtx(ctx *context.Context) (*variablesCtx, error) { if ctx.Data["PageIsOrgSettings"] == true { if _, err := shared_user.RenderUserOrgHeader(ctx); err != nil { ctx.ServerError("RenderUserOrgHeader", err) - return nil, nil + return nil, nil //nolint:nilnil // error is already handled by ctx.ServerError } return &variablesCtx{ OwnerID: ctx.ContextUser.ID, diff --git a/services/actions/context.go b/services/actions/context.go index b6de429ccf..626ae6ee6b 100644 --- a/services/actions/context.go +++ b/services/actions/context.go @@ -104,7 +104,7 @@ type TaskNeed struct { // FindTaskNeeds finds the `needs` for the task by the task's job func FindTaskNeeds(ctx context.Context, job *actions_model.ActionRunJob) (map[string]*TaskNeed, error) { if len(job.Needs) == 0 { - return nil, nil + return nil, nil //nolint:nilnil // return nil when the job has no needs } needs := container.SetOf(job.Needs...) diff --git a/services/actions/job_emitter.go b/services/actions/job_emitter.go index 27e540f5cc..0e14c3cb17 100644 --- a/services/actions/job_emitter.go +++ b/services/actions/job_emitter.go @@ -123,7 +123,7 @@ func checkJobsByRunID(ctx context.Context, runID int64) error { // findBlockedRunByConcurrency finds the blocked concurrent run in a repo and returns `nil, nil` when there is no blocked run. func findBlockedRunByConcurrency(ctx context.Context, repoID int64, concurrencyGroup string) (*actions_model.ActionRun, error) { if concurrencyGroup == "" { - return nil, nil + return nil, nil //nolint:nilnil // return nil to indicate that no blocked run exists } cRuns, cJobs, err := actions_model.GetConcurrentRunsAndJobs(ctx, repoID, concurrencyGroup, []actions_model.Status{actions_model.StatusBlocked}) if err != nil { diff --git a/services/auth/auth_token.go b/services/auth/auth_token.go index 6b59238c98..8897bbd19c 100644 --- a/services/auth/auth_token.go +++ b/services/auth/auth_token.go @@ -32,7 +32,7 @@ var ( func CheckAuthToken(ctx context.Context, value string) (*auth_model.AuthToken, error) { if len(value) == 0 { - return nil, nil + return nil, nil //nolint:nilnil // the auth method is not applicable } parts := strings.SplitN(value, ":", 2) diff --git a/services/auth/basic.go b/services/auth/basic.go index de5c7730cc..3161d7f33d 100644 --- a/services/auth/basic.go +++ b/services/auth/basic.go @@ -121,7 +121,7 @@ func (b *Basic) VerifyAuthToken(req *http.Request, w http.ResponseWriter, store store.GetData()["LoginMethod"] = ActionTokenMethodName return user_model.NewActionsUserWithTaskID(task.ID), nil } - return nil, nil + return nil, nil //nolint:nilnil // the auth method is not applicable } // Verify extracts and validates Basic data (username and password/token) from the @@ -132,7 +132,7 @@ func (b *Basic) Verify(req *http.Request, w http.ResponseWriter, store DataStore parseBasicRet := b.parseAuthBasic(req) authToken, uname, passwd := parseBasicRet.authToken, parseBasicRet.uname, parseBasicRet.passwd if authToken == "" && uname == "" { - return nil, nil + return nil, nil //nolint:nilnil // the auth method is not applicable } u, err := b.VerifyAuthToken(req, w, store, sess, authToken) if u != nil || err != nil { @@ -140,7 +140,7 @@ func (b *Basic) Verify(req *http.Request, w http.ResponseWriter, store DataStore } if !setting.Service.EnableBasicAuth { - return nil, nil + return nil, nil //nolint:nilnil // the auth method is not applicable } log.Trace("Basic Authorization: Attempting SignIn for %s", uname) diff --git a/services/auth/httpsign.go b/services/auth/httpsign.go index 25e96ff32d..130207c0ea 100644 --- a/services/auth/httpsign.go +++ b/services/auth/httpsign.go @@ -42,7 +42,7 @@ func (h *HTTPSign) Name() string { func (h *HTTPSign) Verify(req *http.Request, w http.ResponseWriter, store DataStore, sess SessionStore) (*user_model.User, error) { sigHead := req.Header.Get("Signature") if len(sigHead) == 0 { - return nil, nil + return nil, nil //nolint:nilnil // the auth method is not applicable } var ( @@ -53,14 +53,14 @@ func (h *HTTPSign) Verify(req *http.Request, w http.ResponseWriter, store DataSt if len(req.Header.Get("X-Ssh-Certificate")) != 0 { // Handle Signature signed by SSH certificates if len(setting.SSH.TrustedUserCAKeys) == 0 { - return nil, nil + return nil, nil //nolint:nilnil // the auth method is not applicable } publicKey, err = VerifyCert(req) if err != nil { log.Debug("VerifyCert on request from %s: failed: %v", req.RemoteAddr, err) log.Warn("Failed authentication attempt from %s", req.RemoteAddr) - return nil, nil + return nil, nil //nolint:nilnil // the auth method is not applicable } } else { // Handle Signature signed by Public Key @@ -68,7 +68,7 @@ func (h *HTTPSign) Verify(req *http.Request, w http.ResponseWriter, store DataSt if err != nil { log.Debug("VerifyPubKey on request from %s: failed: %v", req.RemoteAddr, err) log.Warn("Failed authentication attempt from %s", req.RemoteAddr) - return nil, nil + return nil, nil //nolint:nilnil // the auth method is not applicable } } diff --git a/services/auth/oauth2.go b/services/auth/oauth2.go index 13cbc77f7a..86903b0ce1 100644 --- a/services/auth/oauth2.go +++ b/services/auth/oauth2.go @@ -156,12 +156,12 @@ func (o *OAuth2) Verify(req *http.Request, w http.ResponseWriter, store DataStor detector := newAuthPathDetector(req) if !detector.isAPIPath() && !detector.isAttachmentDownload() && !detector.isAuthenticatedTokenRequest() && !detector.isGitRawOrAttachPath() && !detector.isArchivePath() { - return nil, nil + return nil, nil //nolint:nilnil // the auth method is not applicable } token, ok := parseToken(req) if !ok { - return nil, nil + return nil, nil //nolint:nilnil // the auth method is not applicable } user, err := o.userFromToken(req.Context(), token, store) diff --git a/services/auth/reverseproxy.go b/services/auth/reverseproxy.go index d6664d738d..064b263a67 100644 --- a/services/auth/reverseproxy.go +++ b/services/auth/reverseproxy.go @@ -51,7 +51,7 @@ func (r *ReverseProxy) Name() string { func (r *ReverseProxy) getUserFromAuthUser(req *http.Request) (*user_model.User, error) { username := r.getUserName(req) if len(username) == 0 { - return nil, nil + return nil, nil //nolint:nilnil // the auth method is not applicable } log.Trace("ReverseProxy Authorization: Found username: %s", username) @@ -111,7 +111,7 @@ func (r *ReverseProxy) Verify(req *http.Request, w http.ResponseWriter, store Da if user == nil { user = r.getUserFromAuthEmail(req) if user == nil { - return nil, nil + return nil, nil //nolint:nilnil // the auth method is not applicable } } diff --git a/services/auth/session.go b/services/auth/session.go index 35d97e42da..5b6e4599b8 100644 --- a/services/auth/session.go +++ b/services/auth/session.go @@ -29,19 +29,19 @@ func (s *Session) Name() string { // Returns nil if there is no user uid stored in the session. func (s *Session) Verify(req *http.Request, w http.ResponseWriter, store DataStore, sess SessionStore) (*user_model.User, error) { if sess == nil { - return nil, nil + return nil, nil //nolint:nilnil // the auth method is not applicable } // Get user ID uid := sess.Get("uid") if uid == nil { - return nil, nil + return nil, nil //nolint:nilnil // the auth method is not applicable } log.Trace("Session Authorization: Found user[%d]", uid) id, ok := uid.(int64) if !ok { - return nil, nil + return nil, nil //nolint:nilnil // the auth method is not applicable } // Get user object @@ -52,7 +52,7 @@ func (s *Session) Verify(req *http.Request, w http.ResponseWriter, store DataSto // Return the err as-is to keep current signed-in session, in case the err is something like context.Canceled. Otherwise non-existing user (nil, nil) will make the caller clear the signed-in session. return nil, err } - return nil, nil + return nil, nil //nolint:nilnil // the auth method is not applicable } log.Trace("Session Authorization: Logged in user %-v", user) diff --git a/services/auth/source/oauth2/providers_test.go b/services/auth/source/oauth2/providers_test.go index 353816c71e..08c50b12a9 100644 --- a/services/auth/source/oauth2/providers_test.go +++ b/services/auth/source/oauth2/providers_test.go @@ -19,11 +19,11 @@ func (p *fakeProvider) Name() string { func (p *fakeProvider) SetName(name string) {} func (p *fakeProvider) BeginAuth(state string) (goth.Session, error) { - return nil, nil + return nil, nil //nolint:nilnil // the auth method is not applicable } func (p *fakeProvider) UnmarshalSession(string) (goth.Session, error) { - return nil, nil + return nil, nil //nolint:nilnil // the auth method is not applicable } func (p *fakeProvider) FetchUser(goth.Session) (goth.User, error) { diff --git a/services/auth/sspi.go b/services/auth/sspi.go index 8cb39886c4..6450753935 100644 --- a/services/auth/sspi.go +++ b/services/auth/sspi.go @@ -63,7 +63,7 @@ func (s *SSPI) Verify(req *http.Request, w http.ResponseWriter, store DataStore, return nil, sspiAuthErrInit } if !s.shouldAuthenticate(req) { - return nil, nil + return nil, nil //nolint:nilnil // the auth method is not applicable } cfg, err := s.getConfig(req.Context()) @@ -97,7 +97,7 @@ func (s *SSPI) Verify(req *http.Request, w http.ResponseWriter, store DataStore, username := sanitizeUsername(userInfo.Username, cfg) if len(username) == 0 { - return nil, nil + return nil, nil //nolint:nilnil // the auth method is not applicable } log.Info("Authenticated as %s\n", username) @@ -109,7 +109,7 @@ func (s *SSPI) Verify(req *http.Request, w http.ResponseWriter, store DataStore, } if !cfg.AutoCreateUsers { log.Error("User '%s' not found", username) - return nil, nil + return nil, nil //nolint:nilnil // the auth method is not applicable } user, err = s.newUser(req.Context(), username, cfg) if err != nil { diff --git a/services/contexttest/context_tests.go b/services/contexttest/context_tests.go index 33e632ea4d..701c25e442 100644 --- a/services/contexttest/context_tests.go +++ b/services/contexttest/context_tests.go @@ -192,7 +192,7 @@ func LoadGitRepo(t *testing.T, ctx gocontext.Context) { type MockRender struct{} func (tr *MockRender) TemplateLookup(tmpl string, _ gocontext.Context) (templates.TemplateExecutor, error) { - return nil, nil + return nil, nil //nolint:nilnil // mock implementation returns nil to indicate no template found } func (tr *MockRender) HTML(w io.Writer, status int, _ templates.TplName, _ any, _ gocontext.Context) error { diff --git a/services/gitdiff/csv.go b/services/gitdiff/csv.go index c10ee14490..3f62f15ca5 100644 --- a/services/gitdiff/csv.go +++ b/services/gitdiff/csv.go @@ -193,7 +193,7 @@ func createCsvDiff(diffFile *DiffFile, baseReader, headReader *csv.Reader) ([]*T } if aRow == nil && bRow == nil { // No content - return nil, nil + return nil, nil //nolint:nilnil // return nil to indicate that the row has no content } aIndex := 0 // tracks where we are in the a2bColMap diff --git a/services/issue/assignee.go b/services/issue/assignee.go index 97b32d5865..ae4b7138ee 100644 --- a/services/issue/assignee.go +++ b/services/issue/assignee.go @@ -234,7 +234,7 @@ func TeamReviewRequest(ctx context.Context, issue *issues_model.Issue, doer *use } if comment == nil || !isAdd { - return nil, nil + return nil, nil //nolint:nilnil // return nil because no comment was created or it is a removal } return comment, teamReviewRequestNotify(ctx, issue, doer, reviewer, isAdd, comment) diff --git a/services/issue/commit.go b/services/issue/commit.go index 66ad93a97d..6cc120697a 100644 --- a/services/issue/commit.go +++ b/services/issue/commit.go @@ -113,7 +113,7 @@ func getIssueFromRef(ctx context.Context, repo *repo_model.Repository, index int issue, err := issues_model.GetIssueByIndex(ctx, repo.ID, index) if err != nil { if issues_model.IsErrIssueNotExist(err) { - return nil, nil + return nil, nil //nolint:nilnil // return nil to indicate that the object does not exist } return nil, err } diff --git a/services/issue/issue.go b/services/issue/issue.go index bb208e43a9..9beb4c46ec 100644 --- a/services/issue/issue.go +++ b/services/issue/issue.go @@ -229,7 +229,7 @@ func AddAssigneeIfNotAssigned(ctx context.Context, issue *issues_model.Issue, do } if isAssigned { // nothing to do - return nil, nil + return nil, nil //nolint:nilnil // return nil because the user is already assigned } valid, err := access_model.CanBeAssigned(ctx, assignee, issue.Repo, issue.IsPull) diff --git a/services/packages/auth.go b/services/packages/auth.go index 6fcc408adc..dd1f68a7ee 100644 --- a/services/packages/auth.go +++ b/services/packages/auth.go @@ -56,7 +56,7 @@ func CreateAuthorizationToken(u *user_model.User, packageScope auth_model.Access func ParseAuthorizationRequest(req *http.Request) (*PackageMeta, error) { h := req.Header.Get("Authorization") if h == "" { - return nil, nil + return nil, nil //nolint:nilnil // the auth method is not applicable } parts := strings.SplitN(h, " ", 2) diff --git a/services/packages/cargo/index.go b/services/packages/cargo/index.go index ebcaa3e56d..580d84ebc2 100644 --- a/services/packages/cargo/index.go +++ b/services/packages/cargo/index.go @@ -152,7 +152,7 @@ func BuildPackageIndex(ctx context.Context, p *packages_model.Package) (*bytes.B return nil, fmt.Errorf("SearchVersions[%s]: %w", p.Name, err) } if len(pvs) == 0 { - return nil, nil + return nil, nil //nolint:nilnil // return nil to indicate that the package has no versions } pds, err := packages_model.GetPackageDescriptors(ctx, pvs) diff --git a/services/pull/check.go b/services/pull/check.go index 8826fca280..f6e8433cf2 100644 --- a/services/pull/check.go +++ b/services/pull/check.go @@ -291,7 +291,7 @@ func getMergeCommit(ctx context.Context, pr *issues_model.PullRequest) (*git.Com if err := gitrepo.RunCmdWithStderr(ctx, pr.BaseRepo, cmd); err != nil { if gitcmd.IsErrorExitCode(err, 1) { // prHeadRef is not an ancestor of the base branch - return nil, nil + return nil, nil //nolint:nilnil // return nil to indicate that the PR head is not merged } // Errors are signaled by a non-zero status that is not 1 return nil, fmt.Errorf("%-v git merge-base --is-ancestor: %w", pr, err) diff --git a/services/pull/comment.go b/services/pull/comment.go index f24e8128e9..6c10bf2aa8 100644 --- a/services/pull/comment.go +++ b/services/pull/comment.go @@ -49,7 +49,7 @@ func getCommitIDsFromRepo(ctx context.Context, repo *repo_model.Repository, oldC // CreatePushPullComment create push code to pull base comment func CreatePushPullComment(ctx context.Context, pusher *user_model.User, pr *issues_model.PullRequest, oldCommitID, newCommitID string, isForcePush bool) (comment *issues_model.Comment, err error) { if pr.HasMerged || oldCommitID == "" || newCommitID == "" { - return nil, nil + return nil, nil //nolint:nilnil // return nil because no comment needs to be created } opts := &issues_model.CreateCommentOptions{ @@ -71,7 +71,7 @@ func CreatePushPullComment(ctx context.Context, pusher *user_model.User, pr *iss } // It maybe an empty pull request. Only non-empty pull request need to create push comment if len(data.CommitIDs) == 0 { - return nil, nil + return nil, nil //nolint:nilnil // return nil because no comment needs to be created } } diff --git a/services/pull/review.go b/services/pull/review.go index acbb620e92..261cf234b3 100644 --- a/services/pull/review.go +++ b/services/pull/review.go @@ -465,7 +465,7 @@ func DismissReview(ctx context.Context, reviewID, repoID int64, message string, } if !isDismiss { - return nil, nil + return nil, nil //nolint:nilnil // return nil because this is not a dismiss action } if err := review.Issue.LoadAttributes(ctx); err != nil { diff --git a/services/repository/archiver/archiver.go b/services/repository/archiver/archiver.go index bfd941ebf6..07214d0bfa 100644 --- a/services/repository/archiver/archiver.go +++ b/services/repository/archiver/archiver.go @@ -156,7 +156,7 @@ func doArchive(ctx context.Context, r *ArchiveRequest) (*repo_model.RepoArchiver // FIXME: If another process are generating it, we think it's not ready and just return // Or we should wait until the archive generated. if archiver.Status == repo_model.ArchiverGenerating { - return nil, nil + return nil, nil //nolint:nilnil // return nil because the archive is still being generated } } else { archiver = &repo_model.RepoArchiver{ diff --git a/services/repository/files/update.go b/services/repository/files/update.go index bd992d06de..3523b2d342 100644 --- a/services/repository/files/update.go +++ b/services/repository/files/update.go @@ -510,7 +510,7 @@ func modifyFile(ctx context.Context, t *TemporaryUploadRepository, file *ChangeR } if writeObjectRet.LfsContent == nil { - return nil, nil // No LFS pointer, so nothing to do + return nil, nil //nolint:nilnil // No LFS pointer, so nothing to do } defer writeObjectRet.LfsContent.Close()