From 3acc13038dfe5e0643112140d329c6eb0ed4cd6a Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Sun, 6 Mar 2022 15:46:21 +0800 Subject: [PATCH] autofix: unused parameter should be replaced by underscore (#6799) Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com> --- internal/auth/pam/pam_stub.go | 2 +- internal/auth/smtp/provider.go | 2 +- internal/cmd/cert_stub.go | 2 +- internal/conf/computed_test.go | 6 +++--- internal/conf/conf_test.go | 2 +- internal/db/action.go | 2 +- internal/db/login_sources.go | 4 ++-- internal/db/repo.go | 2 +- internal/db/repos.go | 2 +- internal/db/two_factor.go | 2 +- internal/db/two_factors.go | 2 +- internal/db/users.go | 2 +- internal/email/email.go | 2 +- internal/email/message.go | 5 ++--- internal/markup/markup.go | 2 +- internal/route/lfs/basic_test.go | 4 ++-- internal/route/repo/commit.go | 2 +- internal/route/user/profile.go | 3 +-- internal/testutil/exec_test.go | 2 +- 19 files changed, 24 insertions(+), 26 deletions(-) diff --git a/internal/auth/pam/pam_stub.go b/internal/auth/pam/pam_stub.go index 65777fd23..a9da5de64 100644 --- a/internal/auth/pam/pam_stub.go +++ b/internal/auth/pam/pam_stub.go @@ -11,6 +11,6 @@ import ( "github.com/pkg/errors" ) -func (c *Config) doAuth(login, password string) error { +func (c *Config) doAuth(_, _ string) error { return errors.New("PAM not supported") } diff --git a/internal/auth/smtp/provider.go b/internal/auth/smtp/provider.go index 3e39aa229..1a136f0e9 100644 --- a/internal/auth/smtp/provider.go +++ b/internal/auth/smtp/provider.go @@ -115,7 +115,7 @@ type smtpLoginAuth struct { username, password string } -func (auth *smtpLoginAuth) Start(server *smtp.ServerInfo) (string, []byte, error) { +func (auth *smtpLoginAuth) Start(_ *smtp.ServerInfo) (string, []byte, error) { return "LOGIN", []byte(auth.username), nil } diff --git a/internal/cmd/cert_stub.go b/internal/cmd/cert_stub.go index ddeb92b0d..fff99e3ff 100644 --- a/internal/cmd/cert_stub.go +++ b/internal/cmd/cert_stub.go @@ -22,7 +22,7 @@ var Cert = cli.Command{ Action: runCert, } -func runCert(ctx *cli.Context) error { +func runCert(_ *cli.Context) error { fmt.Println("Command cert not available, please use build tags 'cert' to rebuild.") os.Exit(1) diff --git a/internal/conf/computed_test.go b/internal/conf/computed_test.go index 908b7679b..8ed49a53a 100644 --- a/internal/conf/computed_test.go +++ b/internal/conf/computed_test.go @@ -39,7 +39,7 @@ func TestIsProdMode(t *testing.T) { } } -func TestWorkDirHelper(t *testing.T) { +func TestWorkDirHelper(_ *testing.T) { if !testutil.WantHelperProcess() { return } @@ -67,7 +67,7 @@ func TestWorkDir(t *testing.T) { } } -func TestCustomDirHelper(t *testing.T) { +func TestCustomDirHelper(_ *testing.T) { if !testutil.WantHelperProcess() { return } @@ -95,7 +95,7 @@ func TestCustomDir(t *testing.T) { } } -func TestHomeDirHelper(t *testing.T) { +func TestHomeDirHelper(_ *testing.T) { if !testutil.WantHelperProcess() { return } diff --git a/internal/conf/conf_test.go b/internal/conf/conf_test.go index 51ccf93c1..c5159bed5 100644 --- a/internal/conf/conf_test.go +++ b/internal/conf/conf_test.go @@ -31,7 +31,7 @@ func TestAssetDir(t *testing.T) { } } -func TestMustAsset(t *testing.T) { +func TestMustAsset(_ *testing.T) { // Make sure it does not blow up MustAsset("conf/app.ini") } diff --git a/internal/db/action.go b/internal/db/action.go index 292e936a1..a9efeeb80 100644 --- a/internal/db/action.go +++ b/internal/db/action.go @@ -175,7 +175,7 @@ func (a *Action) GetIssueContent() string { return issue.Content } -func newRepoAction(e Engine, doer, owner *User, repo *Repository) (err error) { +func newRepoAction(e Engine, doer, _ *User, repo *Repository) (err error) { opType := ACTION_CREATE_REPO if repo.IsFork { opType = ACTION_FORK_REPO diff --git a/internal/db/login_sources.go b/internal/db/login_sources.go index 1cce78290..79a236628 100644 --- a/internal/db/login_sources.go +++ b/internal/db/login_sources.go @@ -66,7 +66,7 @@ type LoginSource struct { } // NOTE: This is a GORM save hook. -func (s *LoginSource) BeforeSave(tx *gorm.DB) (err error) { +func (s *LoginSource) BeforeSave(_ *gorm.DB) (err error) { if s.Provider == nil { return nil } @@ -90,7 +90,7 @@ func (s *LoginSource) BeforeUpdate(tx *gorm.DB) error { } // NOTE: This is a GORM query hook. -func (s *LoginSource) AfterFind(tx *gorm.DB) error { +func (s *LoginSource) AfterFind(_ *gorm.DB) error { s.Created = time.Unix(s.CreatedUnix, 0).Local() s.Updated = time.Unix(s.UpdatedUnix, 0).Local() diff --git a/internal/db/repo.go b/internal/db/repo.go index f4a9f0ff3..c858f2eb9 100644 --- a/internal/db/repo.go +++ b/internal/db/repo.go @@ -1746,7 +1746,7 @@ func GetUserAndCollaborativeRepositories(userID int64) ([]*Repository, error) { return append(repos, ownRepos...), nil } -func getRepositoryCount(e Engine, u *User) (int64, error) { +func getRepositoryCount(_ Engine, u *User) (int64, error) { return x.Count(&Repository{OwnerID: u.ID}) } diff --git a/internal/db/repos.go b/internal/db/repos.go index fc5bce03c..ecdbc0a5b 100644 --- a/internal/db/repos.go +++ b/internal/db/repos.go @@ -40,7 +40,7 @@ func (r *Repository) BeforeUpdate(tx *gorm.DB) error { } // NOTE: This is a GORM query hook. -func (r *Repository) AfterFind(tx *gorm.DB) error { +func (r *Repository) AfterFind(_ *gorm.DB) error { r.Created = time.Unix(r.CreatedUnix, 0).Local() r.Updated = time.Unix(r.UpdatedUnix, 0).Local() return nil diff --git a/internal/db/two_factor.go b/internal/db/two_factor.go index ca990454e..1c310535d 100644 --- a/internal/db/two_factor.go +++ b/internal/db/two_factor.go @@ -111,7 +111,7 @@ func (err ErrTwoFactorRecoveryCodeNotFound) Error() string { } // UseRecoveryCode validates recovery code of given user and marks it is used if valid. -func UseRecoveryCode(userID int64, code string) error { +func UseRecoveryCode(_ int64, code string) error { recoveryCode := new(TwoFactorRecoveryCode) has, err := x.Where("code = ?", code).And("is_used = ?", false).Get(recoveryCode) if err != nil { diff --git a/internal/db/two_factors.go b/internal/db/two_factors.go index 7692e5d53..935f66db7 100644 --- a/internal/db/two_factors.go +++ b/internal/db/two_factors.go @@ -46,7 +46,7 @@ func (t *TwoFactor) BeforeCreate(tx *gorm.DB) error { } // NOTE: This is a GORM query hook. -func (t *TwoFactor) AfterFind(tx *gorm.DB) error { +func (t *TwoFactor) AfterFind(_ *gorm.DB) error { t.Created = time.Unix(t.CreatedUnix, 0).Local() return nil } diff --git a/internal/db/users.go b/internal/db/users.go index 5e1baf016..ebf2af87c 100644 --- a/internal/db/users.go +++ b/internal/db/users.go @@ -59,7 +59,7 @@ func (u *User) BeforeCreate(tx *gorm.DB) error { } // NOTE: This is a GORM query hook. -func (u *User) AfterFind(tx *gorm.DB) error { +func (u *User) AfterFind(_ *gorm.DB) error { u.Created = time.Unix(u.CreatedUnix, 0).Local() u.Updated = time.Unix(u.UpdatedUnix, 0).Local() return nil diff --git a/internal/email/email.go b/internal/email/email.go index 917e66654..81b772ea9 100644 --- a/internal/email/email.go +++ b/internal/email/email.go @@ -102,7 +102,7 @@ type Issue interface { HTMLURL() string } -func SendUserMail(c *macaron.Context, u User, tpl, code, subject, info string) { +func SendUserMail(_ *macaron.Context, u User, tpl, code, subject, info string) { data := map[string]interface{}{ "Username": u.DisplayName(), "ActiveCodeLives": conf.Auth.ActivateCodeLives / 60, diff --git a/internal/email/message.go b/internal/email/message.go index ec4f7cc17..587db1615 100644 --- a/internal/email/message.go +++ b/internal/email/message.go @@ -77,7 +77,7 @@ func LoginAuth(username, password string) smtp.Auth { return &loginAuth{username, password} } -func (a *loginAuth) Start(server *smtp.ServerInfo) (string, []byte, error) { +func (a *loginAuth) Start(_ *smtp.ServerInfo) (string, []byte, error) { return "LOGIN", []byte{}, nil } @@ -95,8 +95,7 @@ func (a *loginAuth) Next(fromServer []byte, more bool) ([]byte, error) { return nil, nil } -type Sender struct { -} +type Sender struct{} func (s *Sender) Send(from string, to []string, msg io.WriterTo) error { opts := conf.Email diff --git a/internal/markup/markup.go b/internal/markup/markup.go index d4784ff69..3f2a1172e 100644 --- a/internal/markup/markup.go +++ b/internal/markup/markup.go @@ -122,7 +122,7 @@ func RenderIssueIndexPattern(rawBytes []byte, urlPrefix string, metas map[string var pound = []byte("#") // RenderCrossReferenceIssueIndexPattern renders issue indexes from other repositories to corresponding links. -func RenderCrossReferenceIssueIndexPattern(rawBytes []byte, urlPrefix string, metas map[string]string) []byte { +func RenderCrossReferenceIssueIndexPattern(rawBytes []byte, _ string, _ map[string]string) []byte { ms := CrossReferenceIssueNumericPattern.FindAll(rawBytes, -1) for _, m := range ms { if m[0] == ' ' || m[0] == '(' { diff --git a/internal/route/lfs/basic_test.go b/internal/route/lfs/basic_test.go index db2fbe616..f874f536e 100644 --- a/internal/route/lfs/basic_test.go +++ b/internal/route/lfs/basic_test.go @@ -31,12 +31,12 @@ func (s *mockStorage) Storage() lfsutil.Storage { return "memory" } -func (s *mockStorage) Upload(oid lfsutil.OID, rc io.ReadCloser) (int64, error) { +func (s *mockStorage) Upload(_ lfsutil.OID, rc io.ReadCloser) (int64, error) { defer rc.Close() return io.Copy(s.buf, rc) } -func (s *mockStorage) Download(oid lfsutil.OID, w io.Writer) error { +func (s *mockStorage) Download(_ lfsutil.OID, w io.Writer) error { _, err := io.Copy(w, s.buf) return err } diff --git a/internal/route/repo/commit.go b/internal/route/repo/commit.go index a8a344bdd..ae424d064 100644 --- a/internal/route/repo/commit.go +++ b/internal/route/repo/commit.go @@ -35,7 +35,7 @@ func RefCommits(c *context.Context) { } // TODO(unknwon) -func RenderIssueLinks(oldCommits []*git.Commit, repoLink string) []*git.Commit { +func RenderIssueLinks(oldCommits []*git.Commit, _ string) []*git.Commit { return oldCommits } diff --git a/internal/route/user/profile.go b/internal/route/user/profile.go index 89d845092..3baee4e39 100644 --- a/internal/route/user/profile.go +++ b/internal/route/user/profile.go @@ -99,8 +99,7 @@ func Following(c *context.Context, puser *context.ParamsUser) { repo.RenderUserCards(c, puser.NumFollowing, puser.GetFollowing, FOLLOWERS) } -func Stars(c *context.Context) { - +func Stars(_ *context.Context) { } func Action(c *context.Context, puser *context.ParamsUser) { diff --git a/internal/testutil/exec_test.go b/internal/testutil/exec_test.go index 679dc9d05..c740c41e5 100644 --- a/internal/testutil/exec_test.go +++ b/internal/testutil/exec_test.go @@ -13,7 +13,7 @@ import ( "github.com/stretchr/testify/assert" ) -func TestExecHelper(t *testing.T) { +func TestExecHelper(_ *testing.T) { if !WantHelperProcess() { return }