loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Enable `unparam` linter (#31277)

Enable [unparam](https://github.com/mvdan/unparam) linter.

Often I could not tell the intention why param is unused, so I put
`//nolint` for those cases like webhook request creation functions never
using `ctx`.

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: delvh <dev.lh@web.de>
(cherry picked from commit fc2d75f86d77b022ece848acf2581c14ef21d43b)

Conflicts:
modules/setting/config_env.go
modules/storage/azureblob.go
services/webhook/dingtalk.go
services/webhook/discord.go
services/webhook/feishu.go
services/webhook/matrix.go
services/webhook/msteams.go
services/webhook/packagist.go
services/webhook/slack.go
services/webhook/telegram.go
services/webhook/wechatwork.go

run make lint-go and fix Forgejo specific warnings

authored by

silverwind
Lunny Xiao
delvh
and committed by
Earl Warren
d8bc0495 8346cd6c

+88 -123
+1
.golangci.yml
··· 22 22 - typecheck 23 23 - unconvert 24 24 - unused 25 + - unparam 25 26 - wastedassign 26 27 27 28 run:
+5 -12
models/dbfs/dbfile.go
··· 215 215 return time.UnixMicro(timestamp) 216 216 } 217 217 218 - func (f *file) loadMetaByPath() (*dbfsMeta, error) { 218 + func (f *file) loadMetaByPath() error { 219 219 var fileMeta dbfsMeta 220 220 if ok, err := db.GetEngine(f.ctx).Where("full_path = ?", f.fullPath).Get(&fileMeta); err != nil { 221 - return nil, err 221 + return err 222 222 } else if ok { 223 223 f.metaID = fileMeta.ID 224 224 f.blockSize = fileMeta.BlockSize 225 - return &fileMeta, nil 226 225 } 227 - return nil, nil 226 + return nil 228 227 } 229 228 230 229 func (f *file) open(flag int) (err error) { ··· 288 287 if err != nil { 289 288 return err 290 289 } 291 - if _, err = f.loadMetaByPath(); err != nil { 292 - return err 293 - } 294 - return nil 290 + return f.loadMetaByPath() 295 291 } 296 292 297 293 func (f *file) truncate() error { ··· 368 364 func newDbFile(ctx context.Context, path string) (*file, error) { 369 365 path = buildPath(path) 370 366 f := &file{ctx: ctx, fullPath: path, blockSize: defaultFileBlockSize} 371 - if _, err := f.loadMetaByPath(); err != nil { 372 - return nil, err 373 - } 374 - return f, nil 367 + return f, f.loadMetaByPath() 375 368 }
+20 -31
models/issues/issue_search.go
··· 99 99 } 100 100 } 101 101 102 - func applyLimit(sess *xorm.Session, opts *IssuesOptions) *xorm.Session { 102 + func applyLimit(sess *xorm.Session, opts *IssuesOptions) { 103 103 if opts.Paginator == nil || opts.Paginator.IsListAll() { 104 - return sess 104 + return 105 105 } 106 106 107 107 start := 0 ··· 109 109 start = (opts.Paginator.Page - 1) * opts.Paginator.PageSize 110 110 } 111 111 sess.Limit(opts.Paginator.PageSize, start) 112 - 113 - return sess 114 112 } 115 113 116 - func applyLabelsCondition(sess *xorm.Session, opts *IssuesOptions) *xorm.Session { 114 + func applyLabelsCondition(sess *xorm.Session, opts *IssuesOptions) { 117 115 if len(opts.LabelIDs) > 0 { 118 116 if opts.LabelIDs[0] == 0 { 119 117 sess.Where("issue.id NOT IN (SELECT issue_id FROM issue_label)") ··· 136 134 if len(opts.ExcludedLabelNames) > 0 { 137 135 sess.And(builder.NotIn("issue.id", BuildLabelNamesIssueIDsCondition(opts.ExcludedLabelNames))) 138 136 } 139 - 140 - return sess 141 137 } 142 138 143 - func applyMilestoneCondition(sess *xorm.Session, opts *IssuesOptions) *xorm.Session { 139 + func applyMilestoneCondition(sess *xorm.Session, opts *IssuesOptions) { 144 140 if len(opts.MilestoneIDs) == 1 && opts.MilestoneIDs[0] == db.NoConditionID { 145 141 sess.And("issue.milestone_id = 0") 146 142 } else if len(opts.MilestoneIDs) > 0 { ··· 153 149 From("milestone"). 154 150 Where(builder.In("name", opts.IncludeMilestones))) 155 151 } 156 - 157 - return sess 158 152 } 159 153 160 - func applyProjectCondition(sess *xorm.Session, opts *IssuesOptions) *xorm.Session { 154 + func applyProjectCondition(sess *xorm.Session, opts *IssuesOptions) { 161 155 if opts.ProjectID > 0 { // specific project 162 156 sess.Join("INNER", "project_issue", "issue.id = project_issue.issue_id"). 163 157 And("project_issue.project_id=?", opts.ProjectID) ··· 166 160 } 167 161 // opts.ProjectID == 0 means all projects, 168 162 // do not need to apply any condition 169 - return sess 170 163 } 171 164 172 - func applyProjectColumnCondition(sess *xorm.Session, opts *IssuesOptions) *xorm.Session { 165 + func applyProjectColumnCondition(sess *xorm.Session, opts *IssuesOptions) { 173 166 // opts.ProjectColumnID == 0 means all project columns, 174 167 // do not need to apply any condition 175 168 if opts.ProjectColumnID > 0 { ··· 177 170 } else if opts.ProjectColumnID == db.NoConditionID { 178 171 sess.In("issue.id", builder.Select("issue_id").From("project_issue").Where(builder.Eq{"project_board_id": 0})) 179 172 } 180 - return sess 181 173 } 182 174 183 - func applyRepoConditions(sess *xorm.Session, opts *IssuesOptions) *xorm.Session { 175 + func applyRepoConditions(sess *xorm.Session, opts *IssuesOptions) { 184 176 if len(opts.RepoIDs) == 1 { 185 177 opts.RepoCond = builder.Eq{"issue.repo_id": opts.RepoIDs[0]} 186 178 } else if len(opts.RepoIDs) > 1 { ··· 195 187 if opts.RepoCond != nil { 196 188 sess.And(opts.RepoCond) 197 189 } 198 - return sess 199 190 } 200 191 201 - func applyConditions(sess *xorm.Session, opts *IssuesOptions) *xorm.Session { 192 + func applyConditions(sess *xorm.Session, opts *IssuesOptions) { 202 193 if len(opts.IssueIDs) > 0 { 203 194 sess.In("issue.id", opts.IssueIDs) 204 195 } ··· 261 252 if opts.User != nil { 262 253 sess.And(issuePullAccessibleRepoCond("issue.repo_id", opts.User.ID, opts.Org, opts.Team, opts.IsPull.Value())) 263 254 } 264 - 265 - return sess 266 255 } 267 256 268 257 // teamUnitsRepoCond returns query condition for those repo id in the special org team with special units access ··· 339 328 return cond 340 329 } 341 330 342 - func applyAssigneeCondition(sess *xorm.Session, assigneeID int64) *xorm.Session { 343 - return sess.Join("INNER", "issue_assignees", "issue.id = issue_assignees.issue_id"). 331 + func applyAssigneeCondition(sess *xorm.Session, assigneeID int64) { 332 + sess.Join("INNER", "issue_assignees", "issue.id = issue_assignees.issue_id"). 344 333 And("issue_assignees.assignee_id = ?", assigneeID) 345 334 } 346 335 347 - func applyPosterCondition(sess *xorm.Session, posterID int64) *xorm.Session { 348 - return sess.And("issue.poster_id=?", posterID) 336 + func applyPosterCondition(sess *xorm.Session, posterID int64) { 337 + sess.And("issue.poster_id=?", posterID) 349 338 } 350 339 351 - func applyMentionedCondition(sess *xorm.Session, mentionedID int64) *xorm.Session { 352 - return sess.Join("INNER", "issue_user", "issue.id = issue_user.issue_id"). 340 + func applyMentionedCondition(sess *xorm.Session, mentionedID int64) { 341 + sess.Join("INNER", "issue_user", "issue.id = issue_user.issue_id"). 353 342 And("issue_user.is_mentioned = ?", true). 354 343 And("issue_user.uid = ?", mentionedID) 355 344 } 356 345 357 - func applyReviewRequestedCondition(sess *xorm.Session, reviewRequestedID int64) *xorm.Session { 346 + func applyReviewRequestedCondition(sess *xorm.Session, reviewRequestedID int64) { 358 347 existInTeamQuery := builder.Select("team_user.team_id"). 359 348 From("team_user"). 360 349 Where(builder.Eq{"team_user.uid": reviewRequestedID}) ··· 375 364 ), 376 365 builder.In("review.id", maxReview), 377 366 )) 378 - return sess.Where("issue.poster_id <> ?", reviewRequestedID). 367 + sess.Where("issue.poster_id <> ?", reviewRequestedID). 379 368 And(builder.In("issue.id", subQuery)) 380 369 } 381 370 382 - func applyReviewedCondition(sess *xorm.Session, reviewedID int64) *xorm.Session { 371 + func applyReviewedCondition(sess *xorm.Session, reviewedID int64) { 383 372 // Query for pull requests where you are a reviewer or commenter, excluding 384 373 // any pull requests already returned by the review requested filter. 385 374 notPoster := builder.Neq{"issue.poster_id": reviewedID} ··· 406 395 builder.In("type", CommentTypeComment, CommentTypeCode, CommentTypeReview), 407 396 )), 408 397 ) 409 - return sess.And(notPoster, builder.Or(reviewed, commented)) 398 + sess.And(notPoster, builder.Or(reviewed, commented)) 410 399 } 411 400 412 - func applySubscribedCondition(sess *xorm.Session, subscriberID int64) *xorm.Session { 413 - return sess.And( 401 + func applySubscribedCondition(sess *xorm.Session, subscriberID int64) { 402 + sess.And( 414 403 builder. 415 404 NotIn("issue.id", 416 405 builder.Select("issue_id").
+4 -12
models/issues/pull_list.go
··· 28 28 MilestoneID int64 29 29 } 30 30 31 - func listPullRequestStatement(ctx context.Context, baseRepoID int64, opts *PullRequestsOptions) (*xorm.Session, error) { 31 + func listPullRequestStatement(ctx context.Context, baseRepoID int64, opts *PullRequestsOptions) *xorm.Session { 32 32 sess := db.GetEngine(ctx).Where("pull_request.base_repo_id=?", baseRepoID) 33 33 34 34 sess.Join("INNER", "issue", "pull_request.issue_id = issue.id") ··· 46 46 sess.And("issue.milestone_id=?", opts.MilestoneID) 47 47 } 48 48 49 - return sess, nil 49 + return sess 50 50 } 51 51 52 52 func GetUnmergedPullRequestsByHeadInfoMax(ctx context.Context, repoID, olderThan int64, branch string) ([]*PullRequest, error) { ··· 136 136 opts.Page = 1 137 137 } 138 138 139 - countSession, err := listPullRequestStatement(ctx, baseRepoID, opts) 140 - if err != nil { 141 - log.Error("listPullRequestStatement: %v", err) 142 - return nil, 0, err 143 - } 139 + countSession := listPullRequestStatement(ctx, baseRepoID, opts) 144 140 maxResults, err := countSession.Count(new(PullRequest)) 145 141 if err != nil { 146 142 log.Error("Count PRs: %v", err) 147 143 return nil, maxResults, err 148 144 } 149 145 150 - findSession, err := listPullRequestStatement(ctx, baseRepoID, opts) 146 + findSession := listPullRequestStatement(ctx, baseRepoID, opts) 151 147 applySorts(findSession, opts.SortType, 0) 152 - if err != nil { 153 - log.Error("listPullRequestStatement: %v", err) 154 - return nil, maxResults, err 155 - } 156 148 findSession = db.SetSessionPagination(findSession, opts) 157 149 prs := make([]*PullRequest, 0, opts.PageSize) 158 150 return prs, maxResults, findSession.Find(&prs)
+1 -1
modules/auth/password/hash/common.go
··· 18 18 return parsed, previousErr // <- Keep the previous error as this function should still return an error once everything has been checked if any call failed 19 19 } 20 20 21 - func parseUIntParam(value, param, algorithmName, config string, previousErr error) (uint64, error) { 21 + func parseUIntParam(value, param, algorithmName, config string, previousErr error) (uint64, error) { //nolint:unparam 22 22 parsed, err := strconv.ParseUint(value, 10, 64) 23 23 if err != nil { 24 24 log.Error("invalid integer for %s representation in %s hash spec %s", param, algorithmName, config)
+8 -9
modules/git/git.go
··· 42 42 ) 43 43 44 44 // loadGitVersion returns current Git version from shell. Internal usage only. 45 - func loadGitVersion() (*version.Version, error) { 45 + func loadGitVersion() error { 46 46 // doesn't need RWMutex because it's executed by Init() 47 47 if gitVersion != nil { 48 - return gitVersion, nil 48 + return nil 49 49 } 50 - 51 50 stdout, _, runErr := NewCommand(DefaultContext, "version").RunStdString(nil) 52 51 if runErr != nil { 53 - return nil, runErr 52 + return runErr 54 53 } 55 54 56 55 fields := strings.Fields(stdout) 57 56 if len(fields) < 3 { 58 - return nil, fmt.Errorf("invalid git version output: %s", stdout) 57 + return fmt.Errorf("invalid git version output: %s", stdout) 59 58 } 60 59 61 60 var versionString string ··· 70 69 71 70 var err error 72 71 gitVersion, err = version.NewVersion(versionString) 73 - return gitVersion, err 72 + return err 74 73 } 75 74 76 75 // SetExecutablePath changes the path of git executable and checks the file permission and version. ··· 85 84 } 86 85 GitExecutable = absPath 87 86 88 - _, err = loadGitVersion() 87 + err = loadGitVersion() 89 88 if err != nil { 90 89 return fmt.Errorf("unable to load git version: %w", err) 91 90 } ··· 312 311 313 312 // CheckGitVersionAtLeast check git version is at least the constraint version 314 313 func CheckGitVersionAtLeast(atLeast string) error { 315 - if _, err := loadGitVersion(); err != nil { 314 + if err := loadGitVersion(); err != nil { 316 315 return err 317 316 } 318 317 atLeastVersion, err := version.NewVersion(atLeast) ··· 327 326 328 327 // CheckGitVersionEqual checks if the git version is equal to the constraint version. 329 328 func CheckGitVersionEqual(equal string) error { 330 - if _, err := loadGitVersion(); err != nil { 329 + if err := loadGitVersion(); err != nil { 331 330 return err 332 331 } 333 332 atLeastVersion, err := version.NewVersion(equal)
+2 -2
modules/git/object_format.go
··· 34 34 ComputeHash(t ObjectType, content []byte) ObjectID 35 35 } 36 36 37 - func computeHash(dst []byte, hasher hash.Hash, t ObjectType, content []byte) []byte { 37 + func computeHash(dst []byte, hasher hash.Hash, t ObjectType, content []byte) { 38 38 _, _ = hasher.Write(t.Bytes()) 39 39 _, _ = hasher.Write([]byte(" ")) 40 40 _, _ = hasher.Write([]byte(strconv.Itoa(len(content)))) 41 41 _, _ = hasher.Write([]byte{0}) 42 42 _, _ = hasher.Write(content) 43 - return hasher.Sum(dst) 43 + hasher.Sum(dst) 44 44 } 45 45 46 46 /* SHA1 Type */
+1 -1
modules/markup/markdown/transform_codespan.go
··· 48 48 return ast.WalkContinue, nil 49 49 } 50 50 51 - func (g *ASTTransformer) transformCodeSpan(ctx *markup.RenderContext, v *ast.CodeSpan, reader text.Reader) { 51 + func (g *ASTTransformer) transformCodeSpan(_ *markup.RenderContext, v *ast.CodeSpan, reader text.Reader) { 52 52 colorContent := v.Text(reader.Source()) 53 53 if matchColor(strings.ToLower(string(colorContent))) { 54 54 v.AppendChild(v, NewColorPreview(colorContent))
+8 -10
modules/packages/cran/metadata.go
··· 185 185 } 186 186 187 187 func setField(p *Package, data string) error { 188 - const listDelimiter = ", " 189 - 190 188 if data == "" { 191 189 return nil 192 190 } ··· 215 213 case "Description": 216 214 p.Metadata.Description = value 217 215 case "URL": 218 - p.Metadata.ProjectURL = splitAndTrim(value, listDelimiter) 216 + p.Metadata.ProjectURL = splitAndTrim(value) 219 217 case "License": 220 218 p.Metadata.License = value 221 219 case "Author": 222 - p.Metadata.Authors = splitAndTrim(authorReplacePattern.ReplaceAllString(value, ""), listDelimiter) 220 + p.Metadata.Authors = splitAndTrim(authorReplacePattern.ReplaceAllString(value, "")) 223 221 case "Depends": 224 - p.Metadata.Depends = splitAndTrim(value, listDelimiter) 222 + p.Metadata.Depends = splitAndTrim(value) 225 223 case "Imports": 226 - p.Metadata.Imports = splitAndTrim(value, listDelimiter) 224 + p.Metadata.Imports = splitAndTrim(value) 227 225 case "Suggests": 228 - p.Metadata.Suggests = splitAndTrim(value, listDelimiter) 226 + p.Metadata.Suggests = splitAndTrim(value) 229 227 case "LinkingTo": 230 - p.Metadata.LinkingTo = splitAndTrim(value, listDelimiter) 228 + p.Metadata.LinkingTo = splitAndTrim(value) 231 229 case "NeedsCompilation": 232 230 p.Metadata.NeedsCompilation = value == "yes" 233 231 } ··· 235 233 return nil 236 234 } 237 235 238 - func splitAndTrim(s, sep string) []string { 239 - items := strings.Split(s, sep) 236 + func splitAndTrim(s string) []string { 237 + items := strings.Split(s, ", ") 240 238 for i := range items { 241 239 items[i] = strings.TrimSpace(items[i]) 242 240 }
+1 -1
modules/setting/config_env.go
··· 97 97 98 98 // decodeEnvironmentKey decode the environment key to section and key 99 99 // The environment key is in the form of GITEA__SECTION__KEY or GITEA__SECTION__KEY__FILE 100 - func decodeEnvironmentKey(prefixRegexp *regexp.Regexp, suffixFile, envKey string) (ok bool, section, key string, useFileValue bool) { 100 + func decodeEnvironmentKey(prefixRegexp *regexp.Regexp, suffixFile, envKey string) (ok bool, section, key string, useFileValue bool) { //nolint:unparam 101 101 if strings.HasSuffix(envKey, suffixFile) { 102 102 useFileValue = true 103 103 envKey = envKey[:len(envKey)-len(suffixFile)]
+1 -1
modules/setting/storage.go
··· 122 122 targetSecIsSec // target section is from the name seciont [name] 123 123 ) 124 124 125 - func getStorageSectionByType(rootCfg ConfigProvider, typ string) (ConfigSection, targetSecType, error) { 125 + func getStorageSectionByType(rootCfg ConfigProvider, typ string) (ConfigSection, targetSecType, error) { //nolint:unparam 126 126 targetSec, err := rootCfg.GetSection(storageSectionName + "." + typ) 127 127 if err != nil { 128 128 if !IsValidStorageType(StorageType(typ)) {
+3 -6
modules/util/keypair.go
··· 15 15 // GenerateKeyPair generates a public and private keypair 16 16 func GenerateKeyPair(bits int) (string, string, error) { 17 17 priv, _ := rsa.GenerateKey(rand.Reader, bits) 18 - privPem, err := pemBlockForPriv(priv) 19 - if err != nil { 20 - return "", "", err 21 - } 18 + privPem := pemBlockForPriv(priv) 22 19 pubPem, err := pemBlockForPub(&priv.PublicKey) 23 20 if err != nil { 24 21 return "", "", err ··· 26 23 return privPem, pubPem, nil 27 24 } 28 25 29 - func pemBlockForPriv(priv *rsa.PrivateKey) (string, error) { 26 + func pemBlockForPriv(priv *rsa.PrivateKey) string { 30 27 privBytes := pem.EncodeToMemory(&pem.Block{ 31 28 Type: "RSA PRIVATE KEY", 32 29 Bytes: x509.MarshalPKCS1PrivateKey(priv), 33 30 }) 34 - return string(privBytes), nil 31 + return string(privBytes) 35 32 } 36 33 37 34 func pemBlockForPub(pub *rsa.PublicKey) (string, error) {
+2 -6
routers/api/actions/artifacts.go
··· 241 241 } 242 242 243 243 // get upload file size 244 - fileRealTotalSize, contentLength, err := getUploadFileSize(ctx) 245 - if err != nil { 246 - log.Error("Error get upload file size: %v", err) 247 - ctx.Error(http.StatusInternalServerError, "Error get upload file size") 248 - return 249 - } 244 + fileRealTotalSize, contentLength := getUploadFileSize(ctx) 250 245 251 246 // get artifact retention days 252 247 expiredDays := setting.Actions.ArtifactRetentionDays 253 248 if queryRetentionDays := ctx.Req.URL.Query().Get("retentionDays"); queryRetentionDays != "" { 249 + var err error 254 250 expiredDays, err = strconv.ParseInt(queryRetentionDays, 10, 64) 255 251 if err != nil { 256 252 log.Error("Error parse retention days: %v", err)
+4 -4
routers/api/actions/artifacts_utils.go
··· 43 43 return task, runID, true 44 44 } 45 45 46 - func validateRunIDV4(ctx *ArtifactContext, rawRunID string) (*actions.ActionTask, int64, bool) { 46 + func validateRunIDV4(ctx *ArtifactContext, rawRunID string) (*actions.ActionTask, int64, bool) { //nolint:unparam 47 47 task := ctx.ActionTask 48 48 runID, err := strconv.ParseInt(rawRunID, 10, 64) 49 49 if err != nil || task.Job.RunID != runID { ··· 84 84 85 85 // getUploadFileSize returns the size of the file to be uploaded. 86 86 // The raw size is the size of the file as reported by the header X-TFS-FileLength. 87 - func getUploadFileSize(ctx *ArtifactContext) (int64, int64, error) { 87 + func getUploadFileSize(ctx *ArtifactContext) (int64, int64) { 88 88 contentLength := ctx.Req.ContentLength 89 89 xTfsLength, _ := strconv.ParseInt(ctx.Req.Header.Get(artifactXTfsFileLengthHeader), 10, 64) 90 90 if xTfsLength > 0 { 91 - return xTfsLength, contentLength, nil 91 + return xTfsLength, contentLength 92 92 } 93 - return contentLength, contentLength, nil 93 + return contentLength, contentLength 94 94 }
+1 -1
routers/api/packages/container/blob.go
··· 26 26 27 27 // saveAsPackageBlob creates a package blob from an upload 28 28 // The uploaded blob gets stored in a special upload version to link them to the package/image 29 - func saveAsPackageBlob(ctx context.Context, hsr packages_module.HashedSizeReader, pci *packages_service.PackageCreationInfo) (*packages_model.PackageBlob, error) { 29 + func saveAsPackageBlob(ctx context.Context, hsr packages_module.HashedSizeReader, pci *packages_service.PackageCreationInfo) (*packages_model.PackageBlob, error) { //nolint:unparam 30 30 pb := packages_service.NewPackageBlob(hsr) 31 31 32 32 exists := false
+1 -1
routers/api/packages/nuget/nuget.go
··· 36 36 }) 37 37 } 38 38 39 - func xmlResponse(ctx *context.Context, status int, obj any) { 39 + func xmlResponse(ctx *context.Context, status int, obj any) { //nolint:unparam 40 40 ctx.Resp.Header().Set("Content-Type", "application/atom+xml; charset=utf-8") 41 41 ctx.Resp.WriteHeader(status) 42 42 if _, err := ctx.Resp.Write([]byte(xml.Header)); err != nil {
+1 -1
routers/api/v1/repo/compare.go
··· 64 64 } 65 65 } 66 66 67 - _, _, headGitRepo, ci, _, _ := parseCompareInfo(ctx, api.CreatePullRequestOption{ 67 + _, headGitRepo, ci, _, _ := parseCompareInfo(ctx, api.CreatePullRequestOption{ 68 68 Base: infos[0], 69 69 Head: infos[1], 70 70 })
+14 -14
routers/api/v1/repo/pull.go
··· 406 406 ) 407 407 408 408 // Get repo/branch information 409 - _, headRepo, headGitRepo, compareInfo, baseBranch, headBranch := parseCompareInfo(ctx, form) 409 + headRepo, headGitRepo, compareInfo, baseBranch, headBranch := parseCompareInfo(ctx, form) 410 410 if ctx.Written() { 411 411 return 412 412 } ··· 1051 1051 ctx.Status(http.StatusOK) 1052 1052 } 1053 1053 1054 - func parseCompareInfo(ctx *context.APIContext, form api.CreatePullRequestOption) (*user_model.User, *repo_model.Repository, *git.Repository, *git.CompareInfo, string, string) { 1054 + func parseCompareInfo(ctx *context.APIContext, form api.CreatePullRequestOption) (*repo_model.Repository, *git.Repository, *git.CompareInfo, string, string) { 1055 1055 baseRepo := ctx.Repo.Repository 1056 1056 1057 1057 // Get compared branches information ··· 1084 1084 } else { 1085 1085 ctx.Error(http.StatusInternalServerError, "GetUserByName", err) 1086 1086 } 1087 - return nil, nil, nil, nil, "", "" 1087 + return nil, nil, nil, "", "" 1088 1088 } 1089 1089 headBranch = headInfos[1] 1090 1090 // The head repository can also point to the same repo 1091 1091 isSameRepo = ctx.Repo.Owner.ID == headUser.ID 1092 1092 } else { 1093 1093 ctx.NotFound() 1094 - return nil, nil, nil, nil, "", "" 1094 + return nil, nil, nil, "", "" 1095 1095 } 1096 1096 1097 1097 ctx.Repo.PullRequest.SameRepo = isSameRepo ··· 1099 1099 // Check if base branch is valid. 1100 1100 if !ctx.Repo.GitRepo.IsBranchExist(baseBranch) && !ctx.Repo.GitRepo.IsTagExist(baseBranch) { 1101 1101 ctx.NotFound("BaseNotExist") 1102 - return nil, nil, nil, nil, "", "" 1102 + return nil, nil, nil, "", "" 1103 1103 } 1104 1104 1105 1105 // Check if current user has fork of repository or in the same repository. ··· 1107 1107 if headRepo == nil && !isSameRepo { 1108 1108 log.Trace("parseCompareInfo[%d]: does not have fork or in same repository", baseRepo.ID) 1109 1109 ctx.NotFound("GetForkedRepo") 1110 - return nil, nil, nil, nil, "", "" 1110 + return nil, nil, nil, "", "" 1111 1111 } 1112 1112 1113 1113 var headGitRepo *git.Repository ··· 1118 1118 headGitRepo, err = gitrepo.OpenRepository(ctx, headRepo) 1119 1119 if err != nil { 1120 1120 ctx.Error(http.StatusInternalServerError, "OpenRepository", err) 1121 - return nil, nil, nil, nil, "", "" 1121 + return nil, nil, nil, "", "" 1122 1122 } 1123 1123 } 1124 1124 ··· 1127 1127 if err != nil { 1128 1128 headGitRepo.Close() 1129 1129 ctx.Error(http.StatusInternalServerError, "GetUserRepoPermission", err) 1130 - return nil, nil, nil, nil, "", "" 1130 + return nil, nil, nil, "", "" 1131 1131 } 1132 1132 if !permBase.CanReadIssuesOrPulls(true) || !permBase.CanRead(unit.TypeCode) { 1133 1133 if log.IsTrace() { ··· 1138 1138 } 1139 1139 headGitRepo.Close() 1140 1140 ctx.NotFound("Can't read pulls or can't read UnitTypeCode") 1141 - return nil, nil, nil, nil, "", "" 1141 + return nil, nil, nil, "", "" 1142 1142 } 1143 1143 1144 1144 // user should have permission to read headrepo's codes ··· 1146 1146 if err != nil { 1147 1147 headGitRepo.Close() 1148 1148 ctx.Error(http.StatusInternalServerError, "GetUserRepoPermission", err) 1149 - return nil, nil, nil, nil, "", "" 1149 + return nil, nil, nil, "", "" 1150 1150 } 1151 1151 if !permHead.CanRead(unit.TypeCode) { 1152 1152 if log.IsTrace() { ··· 1157 1157 } 1158 1158 headGitRepo.Close() 1159 1159 ctx.NotFound("Can't read headRepo UnitTypeCode") 1160 - return nil, nil, nil, nil, "", "" 1160 + return nil, nil, nil, "", "" 1161 1161 } 1162 1162 1163 1163 // Check if head branch is valid. 1164 1164 if !headGitRepo.IsBranchExist(headBranch) && !headGitRepo.IsTagExist(headBranch) { 1165 1165 headGitRepo.Close() 1166 1166 ctx.NotFound() 1167 - return nil, nil, nil, nil, "", "" 1167 + return nil, nil, nil, "", "" 1168 1168 } 1169 1169 1170 1170 compareInfo, err := headGitRepo.GetCompareInfo(repo_model.RepoPath(baseRepo.Owner.Name, baseRepo.Name), baseBranch, headBranch, false, false) 1171 1171 if err != nil { 1172 1172 headGitRepo.Close() 1173 1173 ctx.Error(http.StatusInternalServerError, "GetCompareInfo", err) 1174 - return nil, nil, nil, nil, "", "" 1174 + return nil, nil, nil, "", "" 1175 1175 } 1176 1176 1177 - return headUser, headRepo, headGitRepo, compareInfo, baseBranch, headBranch 1177 + return headRepo, headGitRepo, compareInfo, baseBranch, headBranch 1178 1178 } 1179 1179 1180 1180 // UpdatePullRequest merge PR's baseBranch into headBranch
+2 -2
routers/private/hook_pre_receive.go
··· 434 434 } 435 435 } 436 436 437 - func preReceiveTag(ctx *preReceiveContext, oldCommitID, newCommitID string, refFullName git.RefName) { 437 + func preReceiveTag(ctx *preReceiveContext, oldCommitID, newCommitID string, refFullName git.RefName) { //nolint:unparam 438 438 if !ctx.AssertCanWriteCode() { 439 439 return 440 440 } ··· 470 470 } 471 471 } 472 472 473 - func preReceiveFor(ctx *preReceiveContext, oldCommitID, newCommitID string, refFullName git.RefName) { 473 + func preReceiveFor(ctx *preReceiveContext, oldCommitID, newCommitID string, refFullName git.RefName) { //nolint:unparam 474 474 if !ctx.AssertCreatePullRequest() { 475 475 return 476 476 }
+1 -1
routers/web/admin/config.go
··· 183 183 value := ctx.FormString("value") 184 184 cfg := setting.Config() 185 185 186 - marshalBool := func(v string) (string, error) { 186 + marshalBool := func(v string) (string, error) { //nolint:unparam 187 187 if b, _ := strconv.ParseBool(v); b { 188 188 return "true", nil 189 189 }
+1 -1
routers/web/repo/badges/badges.go
··· 39 39 ctx.Redirect(getBadgeURL(ctx, label, text, color)) 40 40 } 41 41 42 - func errorBadge(ctx *context_module.Context, label, text string) { 42 + func errorBadge(ctx *context_module.Context, label, text string) { //nolint:unparam 43 43 ctx.Redirect(getBadgeURL(ctx, label, text, "crimson")) 44 44 } 45 45
+1 -1
services/actions/notifier_helper.go
··· 474 474 detectedWorkflows []*actions_module.DetectedWorkflow, 475 475 commit *git.Commit, 476 476 input *notifyInput, 477 - ref string, 477 + _ string, 478 478 ) error { 479 479 branch, err := commit.GetBranchName() 480 480 if err != nil {
+1 -1
services/f3/driver/repository.go
··· 92 92 return o.getURL() 93 93 } 94 94 95 - func newRepository(ctx context.Context) generic.NodeDriverInterface { 95 + func newRepository(_ context.Context) generic.NodeDriverInterface { 96 96 r := &repository{ 97 97 f: &f3.Repository{}, 98 98 }
+1 -1
services/f3/driver/tests/options.go
··· 14 14 "code.forgejo.org/f3/gof3/v3/options" 15 15 ) 16 16 17 - func newTestOptions(t *testing.T) options.Interface { 17 + func newTestOptions(_ *testing.T) options.Interface { 18 18 o := options.GetFactory(driver_options.Name)().(*driver_options.Options) 19 19 o.SetLogger(util.NewF3Logger(nil, forgejo_log.GetLogger(forgejo_log.DEFAULT))) 20 20 return o
+1 -1
services/mailer/mail_admin_new_user.go
··· 45 45 } 46 46 } 47 47 48 - func mailNewUser(ctx context.Context, u *user_model.User, lang string, tos []string) { 48 + func mailNewUser(_ context.Context, u *user_model.User, lang string, tos []string) { 49 49 locale := translation.NewLocale(lang) 50 50 51 51 manageUserURL := setting.AppURL + "admin/users/" + strconv.FormatInt(u.ID, 10)
+1 -1
services/pull/merge.go
··· 252 252 } 253 253 254 254 // doMergeAndPush performs the merge operation without changing any pull information in database and pushes it up to the base repository 255 - func doMergeAndPush(ctx context.Context, pr *issues_model.PullRequest, doer *user_model.User, mergeStyle repo_model.MergeStyle, expectedHeadCommitID, message string, pushTrigger repo_module.PushTrigger) (string, error) { 255 + func doMergeAndPush(ctx context.Context, pr *issues_model.PullRequest, doer *user_model.User, mergeStyle repo_model.MergeStyle, expectedHeadCommitID, message string, pushTrigger repo_module.PushTrigger) (string, error) { //nolint:unparam 256 256 // Clone base repo. 257 257 mergeCtx, cancel, err := createTemporaryRepoForMerge(ctx, pr, doer, expectedHeadCommitID) 258 258 if err != nil {
+1 -1
services/remote/promote.go
··· 84 84 return true, reason, nil 85 85 } 86 86 87 - func getRemoteUserToPromote(ctx context.Context, source *auth_model.Source, loginName, email string) (*user_model.User, Reason, error) { 87 + func getRemoteUserToPromote(ctx context.Context, source *auth_model.Source, loginName, email string) (*user_model.User, Reason, error) { //nolint:unparam 88 88 if !source.IsOAuth2() { 89 89 return nil, NewReason(log.DEBUG, ReasonNotAuth2, "source %v is not OAuth2", source), nil 90 90 }