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

Enable rule.unused-paramater #17803

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions .revive.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ warningCode = 1
[rule.indent-error-flow]
[rule.errorf]
[rule.duplicated-imports]
[rule.unused-parameter]
12 changes: 6 additions & 6 deletions cmd/admin_auth_ldap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,11 @@ func TestAddLdapBindDn(t *testing.T) {
createdLoginSource = loginSource
return nil
},
updateLoginSource: func(loginSource *login.Source) error {
updateLoginSource: func(_ *login.Source) error {
assert.FailNow(t, "case %d: should not call updateLoginSource", n)
return nil
},
getLoginSourceByID: func(id int64) (*login.Source, error) {
getLoginSourceByID: func(_ int64) (*login.Source, error) {
assert.FailNow(t, "case %d: should not call getLoginSourceByID", n)
return nil, nil
},
Expand Down Expand Up @@ -446,11 +446,11 @@ func TestAddLdapSimpleAuth(t *testing.T) {
createdLoginSource = loginSource
return nil
},
updateLoginSource: func(loginSource *login.Source) error {
updateLoginSource: func(_ *login.Source) error {
assert.FailNow(t, "case %d: should not call updateLoginSource", n)
return nil
},
getLoginSourceByID: func(id int64) (*login.Source, error) {
getLoginSourceByID: func(_ int64) (*login.Source, error) {
assert.FailNow(t, "case %d: should not call getLoginSourceByID", n)
return nil, nil
},
Expand Down Expand Up @@ -867,7 +867,7 @@ func TestUpdateLdapBindDn(t *testing.T) {
initDB: func(context.Context) error {
return nil
},
createLoginSource: func(loginSource *login.Source) error {
createLoginSource: func(_ *login.Source) error {
assert.FailNow(t, "case %d: should not call createLoginSource", n)
return nil
},
Expand Down Expand Up @@ -1231,7 +1231,7 @@ func TestUpdateLdapSimpleAuth(t *testing.T) {
initDB: func(context.Context) error {
return nil
},
createLoginSource: func(loginSource *login.Source) error {
createLoginSource: func(_ *login.Source) error {
assert.FailNow(t, "case %d: should not call createLoginSource", n)
return nil
},
Expand Down
2 changes: 1 addition & 1 deletion cmd/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var CmdConvert = cli.Command{
Action: runConvert,
}

func runConvert(ctx *cli.Context) error {
func runConvert(_ *cli.Context) error {
stdCtx, cancel := installSignals()
defer cancel()

Expand Down
2 changes: 1 addition & 1 deletion cmd/embedded_stub.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var (
}
)

func extractorNotImplemented(c *cli.Context) error {
func extractorNotImplemented(_ *cli.Context) error {
err := fmt.Errorf("Sorry: the 'embedded' subcommand is not available in builds without bindata")
fmt.Fprintf(os.Stderr, "%s\n", err)
return err
Expand Down
6 changes: 3 additions & 3 deletions cmd/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ var (
}
)

func runGenerateInternalToken(c *cli.Context) error {
func runGenerateInternalToken(_ *cli.Context) error {
internalToken, err := generate.NewInternalToken()
if err != nil {
return err
Expand All @@ -70,7 +70,7 @@ func runGenerateInternalToken(c *cli.Context) error {
return nil
}

func runGenerateLfsJwtSecret(c *cli.Context) error {
func runGenerateLfsJwtSecret(_ *cli.Context) error {
JWTSecretBase64, err := generate.NewJwtSecretBase64()
if err != nil {
return err
Expand All @@ -85,7 +85,7 @@ func runGenerateLfsJwtSecret(c *cli.Context) error {
return nil
}

func runGenerateSecretKey(c *cli.Context) error {
func runGenerateSecretKey(_ *cli.Context) error {
secretKey, err := generate.NewSecretKey()
if err != nil {
return err
Expand Down
8 changes: 4 additions & 4 deletions cmd/hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func runHookPreReceive(c *cli.Context) error {
ctx, cancel := installSignals()
defer cancel()

setup("hooks/pre-receive.log", c.Bool("debug"))
setup(c.Bool("debug"))

if len(os.Getenv("SSH_ORIGINAL_COMMAND")) == 0 {
if setting.OnlyAllowPushIfGiteaEnvironmentSet {
Expand Down Expand Up @@ -299,7 +299,7 @@ Gitea or set your environment appropriately.`, "")
return nil
}

func runHookUpdate(c *cli.Context) error {
func runHookUpdate(_ *cli.Context) error {
// Update is empty and is kept only for backwards compatibility
return nil
}
Expand All @@ -318,7 +318,7 @@ func runHookPostReceive(c *cli.Context) error {
return nil
}

setup("hooks/post-receive.log", c.Bool("debug"))
setup(c.Bool("debug"))

if len(os.Getenv("SSH_ORIGINAL_COMMAND")) == 0 {
if setting.OnlyAllowPushIfGiteaEnvironmentSet {
Expand Down Expand Up @@ -484,7 +484,7 @@ func pushOptions() map[string]string {
}

func runHookProcReceive(c *cli.Context) error {
setup("hooks/proc-receive.log", c.Bool("debug"))
setup(c.Bool("debug"))

if len(os.Getenv("SSH_ORIGINAL_COMMAND")) == 0 {
if setting.OnlyAllowPushIfGiteaEnvironmentSet {
Expand Down
2 changes: 1 addition & 1 deletion cmd/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func runKeys(c *cli.Context) error {
ctx, cancel := installSignals()
defer cancel()

setup("keys.log", false)
setup(false)

authorizedString, err := private.AuthorizedPublicKeyByContent(ctx, content)
if err != nil {
Expand Down
22 changes: 11 additions & 11 deletions cmd/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ var (
)

func runRemoveLogger(c *cli.Context) error {
setup("manager", c.Bool("debug"))
setup(c.Bool("debug"))
group := c.String("group")
if len(group) == 0 {
group = log.DEFAULT
Expand All @@ -250,7 +250,7 @@ func runRemoveLogger(c *cli.Context) error {
}

func runAddSMTPLogger(c *cli.Context) error {
setup("manager", c.Bool("debug"))
setup(c.Bool("debug"))
vals := map[string]interface{}{}
mode := "smtp"
if c.IsSet("host") {
Expand Down Expand Up @@ -281,7 +281,7 @@ func runAddSMTPLogger(c *cli.Context) error {
}

func runAddConnLogger(c *cli.Context) error {
setup("manager", c.Bool("debug"))
setup(c.Bool("debug"))
vals := map[string]interface{}{}
mode := "conn"
vals["net"] = "tcp"
Expand All @@ -308,7 +308,7 @@ func runAddConnLogger(c *cli.Context) error {
}

func runAddFileLogger(c *cli.Context) error {
setup("manager", c.Bool("debug"))
setup(c.Bool("debug"))
vals := map[string]interface{}{}
mode := "file"
if c.IsSet("filename") {
Expand Down Expand Up @@ -338,7 +338,7 @@ func runAddFileLogger(c *cli.Context) error {
}

func runAddConsoleLogger(c *cli.Context) error {
setup("manager", c.Bool("debug"))
setup(c.Bool("debug"))
vals := map[string]interface{}{}
mode := "console"
if c.IsSet("stderr") && c.Bool("stderr") {
Expand Down Expand Up @@ -391,7 +391,7 @@ func runShutdown(c *cli.Context) error {
ctx, cancel := installSignals()
defer cancel()

setup("manager", c.Bool("debug"))
setup(c.Bool("debug"))
statusCode, msg := private.Shutdown(ctx)
switch statusCode {
case http.StatusInternalServerError:
Expand All @@ -406,7 +406,7 @@ func runRestart(c *cli.Context) error {
ctx, cancel := installSignals()
defer cancel()

setup("manager", c.Bool("debug"))
setup(c.Bool("debug"))
statusCode, msg := private.Restart(ctx)
switch statusCode {
case http.StatusInternalServerError:
Expand All @@ -421,7 +421,7 @@ func runFlushQueues(c *cli.Context) error {
ctx, cancel := installSignals()
defer cancel()

setup("manager", c.Bool("debug"))
setup(c.Bool("debug"))
statusCode, msg := private.FlushQueues(ctx, c.Duration("timeout"), c.Bool("non-blocking"))
switch statusCode {
case http.StatusInternalServerError:
Expand All @@ -436,7 +436,7 @@ func runPauseLogging(c *cli.Context) error {
ctx, cancel := installSignals()
defer cancel()

setup("manager", c.Bool("debug"))
setup(c.Bool("debug"))
statusCode, msg := private.PauseLogging(ctx)
switch statusCode {
case http.StatusInternalServerError:
Expand All @@ -451,7 +451,7 @@ func runResumeLogging(c *cli.Context) error {
ctx, cancel := installSignals()
defer cancel()

setup("manager", c.Bool("debug"))
setup(c.Bool("debug"))
statusCode, msg := private.ResumeLogging(ctx)
switch statusCode {
case http.StatusInternalServerError:
Expand All @@ -466,7 +466,7 @@ func runReleaseReopenLogging(c *cli.Context) error {
ctx, cancel := installSignals()
defer cancel()

setup("manager", c.Bool("debug"))
setup(c.Bool("debug"))
statusCode, msg := private.ReleaseReopenLogging(ctx)
switch statusCode {
case http.StatusInternalServerError:
Expand Down
2 changes: 1 addition & 1 deletion cmd/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var CmdMigrate = cli.Command{
Action: runMigrate,
}

func runMigrate(ctx *cli.Context) error {
func runMigrate(_ *cli.Context) error {
stdCtx, cancel := installSignals()
defer cancel()

Expand Down
4 changes: 2 additions & 2 deletions cmd/serv.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ var CmdServ = cli.Command{
},
}

func setup(logPath string, debug bool) {
func setup(debug bool) {
_ = log.DelLogger("console")
if debug {
_ = log.NewLogger(1000, "console", "console", `{"level":"trace","stacktracelevel":"NONE","stderr":true}`)
Expand Down Expand Up @@ -98,7 +98,7 @@ func runServ(c *cli.Context) error {
defer cancel()

// FIXME: This needs to internationalised
setup("serv.log", c.Bool("debug"))
setup(c.Bool("debug"))

if setting.SSH.Disabled {
println("Gitea: SSH has been disabled")
Expand Down
2 changes: 1 addition & 1 deletion cmd/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func runWeb(ctx *cli.Context) error {
}

// Perform pre-initialization
needsInstall := install.PreloadSettings(graceful.GetManager().HammerContext())
needsInstall := install.PreloadSettings()
if needsInstall {
// Flag for port number in case first time run conflict
if ctx.IsSet("port") {
Expand Down
2 changes: 1 addition & 1 deletion integrations/api_repo_edit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func getNewRepoEditOption(opts *api.EditRepoOption) *api.EditRepoOption {
}

func TestAPIRepoEdit(t *testing.T) {
onGiteaRun(t, func(t *testing.T, u *url.URL) {
onGiteaRun(t, func(t *testing.T, _ *url.URL) {
bFalse, bTrue := false, true

user2 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2}).(*user_model.User) // owner of the repo1 & repo16
Expand Down
6 changes: 3 additions & 3 deletions integrations/api_repo_file_create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func getExpectedFileResponseForCreate(commitID, treePath string) *api.FileRespon
}

func BenchmarkAPICreateFileSmall(b *testing.B) {
onGiteaRunTB(b, func(t testing.TB, u *url.URL) {
onGiteaRunTB(b, func(t testing.TB, _ *url.URL) {
b := t.(*testing.B)
user2 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2}).(*user_model.User) // owner of the repo1 & repo16
repo1 := unittest.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository) // public repo
Expand All @@ -123,7 +123,7 @@ func BenchmarkAPICreateFileSmall(b *testing.B) {
func BenchmarkAPICreateFileMedium(b *testing.B) {
data := make([]byte, 10*1024*1024)

onGiteaRunTB(b, func(t testing.TB, u *url.URL) {
onGiteaRunTB(b, func(t testing.TB, _ *url.URL) {
b := t.(*testing.B)
user2 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2}).(*user_model.User) // owner of the repo1 & repo16
repo1 := unittest.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository) // public repo
Expand All @@ -138,7 +138,7 @@ func BenchmarkAPICreateFileMedium(b *testing.B) {
}

func TestAPICreateFile(t *testing.T) {
onGiteaRun(t, func(t *testing.T, u *url.URL) {
onGiteaRun(t, func(t *testing.T, _ *url.URL) {
user2 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2}).(*user_model.User) // owner of the repo1 & repo16
user3 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 3}).(*user_model.User) // owner of the repo3, is an org
user4 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 4}).(*user_model.User) // owner of neither repos
Expand Down
2 changes: 1 addition & 1 deletion integrations/api_repo_file_delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func getDeleteFileOptions() *api.DeleteFileOptions {
}

func TestAPIDeleteFile(t *testing.T) {
onGiteaRun(t, func(t *testing.T, u *url.URL) {
onGiteaRun(t, func(t *testing.T, _ *url.URL) {
user2 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2}).(*user_model.User) // owner of the repo1 & repo16
user3 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 3}).(*user_model.User) // owner of the repo3, is an org
user4 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 4}).(*user_model.User) // owner of neither repos
Expand Down
2 changes: 1 addition & 1 deletion integrations/api_repo_file_update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func getExpectedFileResponseForUpdate(commitID, treePath string) *api.FileRespon
}

func TestAPIUpdateFile(t *testing.T) {
onGiteaRun(t, func(t *testing.T, u *url.URL) {
onGiteaRun(t, func(t *testing.T, _ *url.URL) {
user2 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2}).(*user_model.User) // owner of the repo1 & repo16
user3 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 3}).(*user_model.User) // owner of the repo3, is an org
user4 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 4}).(*user_model.User) // owner of neither repos
Expand Down
2 changes: 1 addition & 1 deletion integrations/api_repo_get_contents_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func TestAPIGetContentsList(t *testing.T) {
onGiteaRun(t, testAPIGetContentsList)
}

func testAPIGetContentsList(t *testing.T, u *url.URL) {
func testAPIGetContentsList(t *testing.T, _ *url.URL) {
/*** SETUP ***/
user2 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2}).(*user_model.User) // owner of the repo1 & repo16
user3 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 3}).(*user_model.User) // owner of the repo3, is an org
Expand Down
2 changes: 1 addition & 1 deletion integrations/api_repo_get_contents_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func TestAPIGetContents(t *testing.T) {
onGiteaRun(t, testAPIGetContents)
}

func testAPIGetContents(t *testing.T, u *url.URL) {
func testAPIGetContents(t *testing.T, _ *url.URL) {
/*** SETUP ***/
user2 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2}).(*user_model.User) // owner of the repo1 & repo16
user3 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 3}).(*user_model.User) // owner of the repo3, is an org
Expand Down
2 changes: 1 addition & 1 deletion integrations/api_repo_languages_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
)

func TestRepoLanguages(t *testing.T) {
onGiteaRun(t, func(t *testing.T, u *url.URL) {
onGiteaRun(t, func(t *testing.T, _ *url.URL) {
session := loginUser(t, "user2")

// Request editor page
Expand Down
2 changes: 1 addition & 1 deletion integrations/benchmarks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func StringWithCharset(length int, charset string) string {
}

func BenchmarkRepoBranchCommit(b *testing.B) {
onGiteaRunTB(b, func(t testing.TB, u *url.URL) {
onGiteaRunTB(b, func(t testing.TB, _ *url.URL) {
b := t.(*testing.B)

samples := []int64{1, 2, 3}
Expand Down
2 changes: 1 addition & 1 deletion integrations/branches_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func TestDeleteBranch(t *testing.T) {
}

func TestUndoDeleteBranch(t *testing.T) {
onGiteaRun(t, func(t *testing.T, u *url.URL) {
onGiteaRun(t, func(t *testing.T, _ *url.URL) {
deleteBranch(t)
htmlDoc, name := branchAction(t, ".undo-button")
assert.Contains(t,
Expand Down
Loading