Ver Fonte

autofix: unused parameter should be replaced by underscore (#6799)

Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
deepsource-autofix[bot] há 3 anos atrás
pai
commit
3acc13038d

+ 1 - 1
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")
 }

+ 1 - 1
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
 }
 

+ 1 - 1
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)
 

+ 3 - 3
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
 	}

+ 1 - 1
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")
 }

+ 1 - 1
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

+ 2 - 2
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()
 

+ 1 - 1
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})
 }
 

+ 1 - 1
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

+ 1 - 1
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 {

+ 1 - 1
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
 }

+ 1 - 1
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

+ 1 - 1
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,

+ 2 - 3
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

+ 1 - 1
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] == '(' {

+ 2 - 2
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
 }

+ 1 - 1
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
 }
 

+ 1 - 2
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) {

+ 1 - 1
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
 	}