diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index e685ab744..1a68ac12f 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -17,7 +17,7 @@ jobs: steps: - uses: actions/checkout@v3 - name: golangci-lint - uses: golangci/golangci-lint-action@v3 + uses: golangci/golangci-lint-action@v6.1.0 with: - version: v1.51.0 + version: v1.59.1 args: --timeout=500s diff --git a/.golangci.yml b/.golangci.yml index 54f56ff1c..5b60bf5d4 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -2,8 +2,6 @@ linters: disable-all: true enable: - bodyclose - - deadcode - - depguard - dupl - gochecknoinits - gocritic @@ -22,10 +20,8 @@ linters: - rowserrcheck - exportloopref - staticcheck - - structcheck - typecheck - unconvert - unparam - - varcheck - whitespace - - errcheck \ No newline at end of file + - errcheck diff --git a/Makefile b/Makefile index c23314949..6d2f9f733 100644 --- a/Makefile +++ b/Makefile @@ -54,7 +54,7 @@ staticcheck: tools/bin/golangci-lint tools/bin/golangci-lint run $$($(PACKAGE_DIRECTORIES)) --timeout 500s tools/bin/golangci-lint: - curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b ./tools/bin v1.41.1 + curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b ./tools/bin v1.59.1 label-dumpling-checks: @echo "label-dumpling checks" diff --git a/internal/pkg/externalplugins/blunderbuss/blunderbuss.go b/internal/pkg/externalplugins/blunderbuss/blunderbuss.go index 38dab5318..50fcb34f9 100644 --- a/internal/pkg/externalplugins/blunderbuss/blunderbuss.go +++ b/internal/pkg/externalplugins/blunderbuss/blunderbuss.go @@ -225,7 +225,6 @@ func handle(gc githubClient, opts *tiexternalplugins.TiCommunityBlunderbuss, rep } // Always seed random! - //nolint: staticcheck rand.Seed(time.Now().UTC().UnixNano()) // List the contributors of the changes. contributors, err := listChangesContributors(gc, repo.Owner.Login, repo.Name, pr.Number, log) diff --git a/internal/pkg/externalplugins/cherrypicker/cherrypicker.go b/internal/pkg/externalplugins/cherrypicker/cherrypicker.go index 381fa33be..194b80fa0 100644 --- a/internal/pkg/externalplugins/cherrypicker/cherrypicker.go +++ b/internal/pkg/externalplugins/cherrypicker/cherrypicker.go @@ -646,7 +646,7 @@ func (s *Server) handle(logger *logrus.Entry, requestor string, } // Try git cherry-pick. - cherrypick := ex.Command("git", "cherry-pick", "-m", "1", *pr.MergeSHA) + cherrypick := ex.Command("git", "cherry-pick", "-m", "1", "--cleanup=verbatim", *pr.MergeSHA) cherrypick.SetDir(dir) out, err = cherrypick.CombinedOutput() if err != nil { diff --git a/internal/pkg/externalplugins/cherrypicker/cherrypicker_invite_test.go b/internal/pkg/externalplugins/cherrypicker/cherrypicker_invite_test.go index f8275c796..0b932e9b8 100644 --- a/internal/pkg/externalplugins/cherrypicker/cherrypicker_invite_test.go +++ b/internal/pkg/externalplugins/cherrypicker/cherrypicker_invite_test.go @@ -203,7 +203,7 @@ func TestInviteIC(t *testing.T) { BotUser: botUser, GitClient: c, ConfigAgent: ca, - Push: func(forkName, newBranch string, force bool) error { return nil }, + Push: func(_, _ string, _ bool) error { return nil }, GitHubClient: ghc, WebhookSecretGenerator: getSecret, GitHubTokenGenerator: getGithubToken, diff --git a/internal/pkg/externalplugins/cherrypicker/cherrypicker_test.go b/internal/pkg/externalplugins/cherrypicker/cherrypicker_test.go index 6c81634b2..4b2c0bb12 100644 --- a/internal/pkg/externalplugins/cherrypicker/cherrypicker_test.go +++ b/internal/pkg/externalplugins/cherrypicker/cherrypicker_test.go @@ -109,13 +109,13 @@ type fghc struct { collaborators []string } -func (f *fghc) GetSingleCommit(org, repo, sha string) (github.RepositoryCommit, error) { +func (f *fghc) GetSingleCommit(_, _, sha string) (github.RepositoryCommit, error) { f.Lock() defer f.Unlock() return f.commits[sha], nil } -func (f *fghc) AddLabels(org, repo string, number int, labels ...string) error { +func (f *fghc) AddLabels(_, _ string, number int, labels ...string) error { f.Lock() defer f.Unlock() for i := range f.prs { @@ -128,7 +128,7 @@ func (f *fghc) AddLabels(org, repo string, number int, labels ...string) error { return nil } -func (f *fghc) AssignIssue(org, repo string, number int, logins []string) error { +func (f *fghc) AssignIssue(_, _ string, number int, logins []string) error { f.Lock() defer f.Unlock() var users []github.User @@ -143,19 +143,19 @@ func (f *fghc) AssignIssue(org, repo string, number int, logins []string) error return nil } -func (f *fghc) GetPullRequest(org, repo string, number int) (*github.PullRequest, error) { +func (f *fghc) GetPullRequest(string, string, int) (*github.PullRequest, error) { f.Lock() defer f.Unlock() return f.pr, nil } -func (f *fghc) GetPullRequestPatch(org, repo string, number int) ([]byte, error) { +func (f *fghc) GetPullRequestPatch(string, string, int) ([]byte, error) { f.Lock() defer f.Unlock() return f.patch, nil } -func (f *fghc) GetPullRequests(org, repo string) ([]github.PullRequest, error) { +func (f *fghc) GetPullRequests(string, string) ([]github.PullRequest, error) { f.Lock() defer f.Unlock() return f.prs, nil @@ -172,13 +172,13 @@ func (f *fghc) CreateComment(org, repo string, number int, comment string) error return nil } -func (f *fghc) GetRepo(owner, name string) (github.FullRepo, error) { +func (f *fghc) GetRepo(_, _ string) (github.FullRepo, error) { f.Lock() defer f.Unlock() return github.FullRepo{}, nil } -func (f *fghc) EnsureFork(forkingUser, org, repo string) (string, error) { +func (f *fghc) EnsureFork(_, _, repo string) (string, error) { if repo == "changeme" { return "changed", nil } @@ -188,7 +188,7 @@ func (f *fghc) EnsureFork(forkingUser, org, repo string) (string, error) { return repo, nil } -func (f *fghc) IsMember(org, user string) (bool, error) { +func (f *fghc) IsMember(_, user string) (bool, error) { f.Lock() defer f.Unlock() @@ -200,7 +200,7 @@ func (f *fghc) IsMember(org, user string) (bool, error) { } } -func (f *fghc) IsCollaborator(org, repo, user string) (bool, error) { +func (f *fghc) IsCollaborator(_, _, user string) (bool, error) { if strings.Contains(user, patternErrWhenIsCollaborator) { return false, errors.New("fake error") } @@ -208,7 +208,7 @@ func (f *fghc) IsCollaborator(org, repo, user string) (bool, error) { return sets.NewString(f.collaborators...).Has(user), nil } -func (f *fghc) AddCollaborator(org, repo, user string, permission github.RepoPermissionLevel) error { +func (f *fghc) AddCollaborator(_, _, user string, _ github.RepoPermissionLevel) error { if strings.Contains(user, patternErrWhenAddCollaborator) { return errors.New("fake error") } @@ -217,7 +217,7 @@ func (f *fghc) AddCollaborator(org, repo, user string, permission github.RepoPer return nil } -func (f *fghc) ListRepoInvitations(org, repo string) ([]*gc.RepositoryInvitation, error) { +func (f *fghc) ListRepoInvitations(string, string) ([]*gc.RepositoryInvitation, error) { return f.repoInvitations, nil } @@ -234,7 +234,7 @@ func prToString(pr github.PullRequest) string { return fmt.Sprintf(prFormat, pr.Title, pr.Body, pr.Head.Ref, pr.Base.Ref, labels, assignees) } -func (f *fghc) CreateIssue(org, repo, title, body string, milestone int, labels, assignees []string) (int, error) { +func (f *fghc) CreateIssue(_, _, title, body string, _ int, labels, assignees []string) (int, error) { f.Lock() defer f.Unlock() @@ -262,7 +262,7 @@ func (f *fghc) CreateIssue(org, repo, title, body string, milestone int, labels, return num, nil } -func (f *fghc) CreatePullRequest(org, repo, title, body, head, base string, canModify bool) (int, error) { +func (f *fghc) CreatePullRequest(_, _, title, body, head, base string, _ bool) (int, error) { f.Lock() defer f.Unlock() num := len(f.prs) + 1 @@ -276,19 +276,19 @@ func (f *fghc) CreatePullRequest(org, repo, title, body, head, base string, canM return num, nil } -func (f *fghc) ListIssueComments(org, repo string, number int) ([]github.IssueComment, error) { +func (f *fghc) ListIssueComments(_, _ string, _ int) ([]github.IssueComment, error) { f.Lock() defer f.Unlock() return f.prComments, nil } -func (f *fghc) GetIssueLabels(org, repo string, number int) ([]github.Label, error) { +func (f *fghc) GetIssueLabels(_, _ string, _ int) ([]github.Label, error) { f.Lock() defer f.Unlock() return f.prLabels, nil } -func (f *fghc) ListOrgMembers(org, role string) ([]github.TeamMember, error) { +func (f *fghc) ListOrgMembers(_, role string) ([]github.TeamMember, error) { f.Lock() defer f.Unlock() if role != "all" { @@ -297,7 +297,7 @@ func (f *fghc) ListOrgMembers(org, role string) ([]github.TeamMember, error) { return f.orgMembers, nil } -func (f *fghc) CreateFork(org, repo string) (string, error) { +func (f *fghc) CreateFork(_, repo string) (string, error) { return repo, nil } @@ -418,7 +418,7 @@ func testCherryPickIC(clients localgit.Clients, t *testing.T) { BotUser: botUser, GitClient: c, ConfigAgent: ca, - Push: func(forkName, newBranch string, force bool) error { return nil }, + Push: func(_, _ string, _ bool) error { return nil }, GitHubClient: ghc, WebhookSecretGenerator: getSecret, GitHubTokenGenerator: getGithubToken, @@ -600,7 +600,7 @@ func testCherryPickPRWithLabels(clients localgit.Clients, t *testing.T) { BotUser: botUser, GitClient: c, ConfigAgent: ca, - Push: func(forkName, newBranch string, force bool) error { return nil }, + Push: func(_, _ string, _ bool) error { return nil }, GitHubClient: ghc, WebhookSecretGenerator: getSecret, GitHubTokenGenerator: getGithubToken, @@ -810,7 +810,7 @@ func testCherryPickPRWithComment(clients localgit.Clients, t *testing.T) { BotUser: botUser, GitClient: c, ConfigAgent: ca, - Push: func(forkName, newBranch string, force bool) error { return nil }, + Push: func(_, _ string, _ bool) error { return nil }, GitHubClient: ghc, WebhookSecretGenerator: getSecret, GitHubTokenGenerator: getGithubToken, @@ -1037,7 +1037,7 @@ func testCherryPickPRLabeled(clients localgit.Clients, t *testing.T) { BotUser: botUser, GitClient: c, ConfigAgent: ca, - Push: func(forkName, newBranch string, force bool) error { return nil }, + Push: func(_, _ string, _ bool) error { return nil }, GitHubClient: ghc, WebhookSecretGenerator: getSecret, GitHubTokenGenerator: getGithubToken, @@ -1363,7 +1363,7 @@ type threadUnsafeFGHC struct { orgRepoCountCalled int } -func (tuf *threadUnsafeFGHC) EnsureFork(login, org, repo string) (string, error) { +func (tuf *threadUnsafeFGHC) EnsureFork(_, _, _ string) (string, error) { tuf.orgRepoCountCalled++ return "", errors.New("that is enough") } diff --git a/internal/pkg/externalplugins/config.go b/internal/pkg/externalplugins/config.go index 088c23dda..02f813132 100644 --- a/internal/pkg/externalplugins/config.go +++ b/internal/pkg/externalplugins/config.go @@ -761,9 +761,7 @@ func validateLabelBlockerAction(actions []string) error { allowActionSet := sets.NewString(LabeledAction, UnlabeledAction) for _, action := range actions { - if allowActionSet.Has(action) { - continue - } else { + if !allowActionSet.Has(action) { return fmt.Errorf("actions contain illegal value %s", action) } } diff --git a/internal/pkg/externalplugins/formatchecker/formatchecker_test.go b/internal/pkg/externalplugins/formatchecker/formatchecker_test.go index 40ba98e20..a8514844d 100644 --- a/internal/pkg/externalplugins/formatchecker/formatchecker_test.go +++ b/internal/pkg/externalplugins/formatchecker/formatchecker_test.go @@ -13,11 +13,14 @@ import ( "k8s.io/test-infra/prow/config" "k8s.io/test-infra/prow/github" "k8s.io/test-infra/prow/github/fakegithub" + + _ "embed" ) const ( issueTitleRegex = "^(\\[TI-(?P[1-9]\\d*)\\])+.+: .{10,160}$" issueNumberRegex = "#([1-9]\\d*)" + testTaskCheckedRegex = `\s*[\n]{1,}(\- \[[xX ]\] .*\n)*(\- \[[xX]\] .*\n)(\- \[[xX ]\] .*\n)*\n` //nolint: lll issueNumberPrefixRegex = "((https|http)://github\\.com/{{.Org}}/{{.Repo}}/issues/|{{.Org}}/{{.Repo}}#|#)" keywordPrefixRegex = "(ref|close[sd]?|resolve[sd]?|fix(e[sd])?)" issueNumberLineTemplate = "(?im)^Issue Number:\\s*((,\\s*)?%s\\s*%s(?P[1-9]\\d*))+" @@ -27,6 +30,9 @@ var ( issueNumberLineRegexp = fmt.Sprintf(issueNumberLineTemplate, keywordPrefixRegex, issueNumberPrefixRegex) ) +//go:embed test-task-body.md +var testTaskBody string + func TestHandlePullRequestEvent(t *testing.T) { formattedLabel := func(label string) string { return fmt.Sprintf("%s/%s#%d:%s", "org", "repo", 1, label) @@ -871,6 +877,26 @@ func TestHandleIssueEvent(t *testing.T) { expectDeletedLabels: []string{}, shouldComment: false, }, + { + name: "Issue body without test task checked", + action: github.IssueActionOpened, + body: testTaskBody, + createdAt: earlierCreatedAt, + labels: []string{}, + requiredMatchRules: []externalplugins.RequiredMatchRule{ + { + Issue: true, + Body: true, + Regexp: testTaskCheckedRegex, + MissingLabel: "do-not-merge/needs-finish-test-tasks", + }, + }, + expectAddedLabels: []string{ + formattedLabel("do-not-merge/needs-finish-test-tasks"), + }, + expectDeletedLabels: []string{}, + shouldComment: false, + }, { name: "Issue body with issue number", action: github.IssueActionOpened, @@ -1109,85 +1135,87 @@ func TestHandleIssueEvent(t *testing.T) { } for _, testcase := range testcases { - tc := testcase - - labels := make([]github.Label, 0) - for _, l := range tc.labels { - labels = append(labels, github.Label{ - Name: l, - }) - } + t.Run(testcase.name, func(t *testing.T) { + tc := testcase + + labels := make([]github.Label, 0) + for _, l := range tc.labels { + labels = append(labels, github.Label{ + Name: l, + }) + } - fc := &fakegithub.FakeClient{ - Issues: map[int]*github.Issue{ - 12345: { - Number: 12345, - PullRequest: nil, - }, - 1234: { - Number: 1234, - PullRequest: &struct{}{}, + fc := &fakegithub.FakeClient{ + Issues: map[int]*github.Issue{ + 12345: { + Number: 12345, + PullRequest: nil, + }, + 1234: { + Number: 1234, + PullRequest: &struct{}{}, + }, }, - }, - IssueComments: make(map[int][]github.IssueComment), - IssueLabelsAdded: []string{}, - IssueLabelsRemoved: []string{}, - } + IssueComments: make(map[int][]github.IssueComment), + IssueLabelsAdded: []string{}, + IssueLabelsRemoved: []string{}, + } - cfg := &externalplugins.Configuration{} - cfg.TiCommunityFormatChecker = []externalplugins.TiCommunityFormatChecker{ - { - Repos: []string{"org/repo"}, - RequiredMatchRules: tc.requiredMatchRules, - }, - } + cfg := &externalplugins.Configuration{} + cfg.TiCommunityFormatChecker = []externalplugins.TiCommunityFormatChecker{ + { + Repos: []string{"org/repo"}, + RequiredMatchRules: tc.requiredMatchRules, + }, + } - ie := &github.IssueEvent{ - Action: tc.action, - Issue: github.Issue{ - Number: 1, - Title: tc.title, - Body: tc.body, - User: github.User{Login: "zhang-san"}, - CreatedAt: tc.createdAt, - Labels: labels, - }, - Repo: github.Repo{ - Owner: github.User{ - Login: "org", + ie := &github.IssueEvent{ + Action: tc.action, + Issue: github.Issue{ + Number: 1, + Title: tc.title, + Body: tc.body, + User: github.User{Login: "zhang-san"}, + CreatedAt: tc.createdAt, + Labels: labels, }, - Name: "repo", - }, - Label: github.Label{ - Name: tc.label, - }, - } - err := HandleIssueEvent(fc, ie, cfg, logrus.WithField("plugin", PluginName)) - if err != nil { - t.Errorf("For case %s, didn't expect error: %v", tc.name, err) - } + Repo: github.Repo{ + Owner: github.User{ + Login: "org", + }, + Name: "repo", + }, + Label: github.Label{ + Name: tc.label, + }, + } + err := HandleIssueEvent(fc, ie, cfg, logrus.WithField("plugin", PluginName)) + if err != nil { + t.Errorf("For case %s, didn't expect error: %v", tc.name, err) + } - sort.Strings(tc.expectAddedLabels) - sort.Strings(fc.IssueLabelsAdded) - if !reflect.DeepEqual(tc.expectAddedLabels, fc.IssueLabelsAdded) { - t.Errorf("For case \"%s\", expected the labels %q to be added, but %q were added", - tc.name, tc.expectAddedLabels, fc.IssueLabelsAdded) - } + sort.Strings(tc.expectAddedLabels) + sort.Strings(fc.IssueLabelsAdded) + if !reflect.DeepEqual(tc.expectAddedLabels, fc.IssueLabelsAdded) { + t.Errorf("For case \"%s\", expected the labels %q to be added, but %q were added", + tc.name, tc.expectAddedLabels, fc.IssueLabelsAdded) + } - sort.Strings(tc.expectDeletedLabels) - sort.Strings(fc.IssueLabelsRemoved) - if !reflect.DeepEqual(tc.expectDeletedLabels, fc.IssueLabelsRemoved) { - t.Errorf("For case %s, expected the labels %q to be deleted, but %q were deleted", - tc.name, tc.expectDeletedLabels, fc.IssueLabelsRemoved) - } + sort.Strings(tc.expectDeletedLabels) + sort.Strings(fc.IssueLabelsRemoved) + if !reflect.DeepEqual(tc.expectDeletedLabels, fc.IssueLabelsRemoved) { + t.Errorf("For case %s, expected the labels %q to be deleted, but %q were deleted", + tc.name, tc.expectDeletedLabels, fc.IssueLabelsRemoved) + } - if !tc.shouldComment && len(fc.IssueCommentsAdded) != 0 { - t.Errorf("unexpected comment %v", fc.IssueCommentsAdded) - } + if !tc.shouldComment && len(fc.IssueCommentsAdded) != 0 { + t.Errorf("unexpected comment %v", fc.IssueCommentsAdded) + } - if tc.shouldComment && len(fc.IssueCommentsAdded) == 0 { - t.Fatalf("expected comments but got none") - } + if tc.shouldComment && len(fc.IssueCommentsAdded) == 0 { + t.Fatalf("expected comments but got none") + } + }) } } diff --git a/internal/pkg/externalplugins/formatchecker/test-task-body.md b/internal/pkg/externalplugins/formatchecker/test-task-body.md new file mode 100644 index 000000000..936690036 --- /dev/null +++ b/internal/pkg/externalplugins/formatchecker/test-task-body.md @@ -0,0 +1,63 @@ +manually cherry-pick https://github.com/pingcap/tidb/pull/45330 + +--- + + +### What problem does this PR solve? + + +Issue Number: close #46540 + +Problem Summary: + +### What is changed and how it works? + +### Check List + +Tests + +- [ ] Unit test +- [ ] Integration test +- [ ] Manual test (add detailed scripts or steps below) +- [ ] No code + +Side effects + +- [x] Performance regression: Consumes more CPU +- [ ] Performance regression: Consumes more Memory +- [ ] Breaking backward compatibility + +Documentation + +- [ ] Affects user behaviors +- [ ] Contains syntax changes +- [ ] Contains variable changes +- [ ] Contains experimental features +- [ ] Changes MySQL compatibility + +### Release note + + + +Please refer to [Release Notes Language Style Guide](https://pingcap.github.io/tidb-dev-guide/contribute-to-tidb/release-notes-style-guide.html) to write a quality release note. + +```release-note +None +``` diff --git a/internal/pkg/externalplugins/issuetriage/issuetriage_test.go b/internal/pkg/externalplugins/issuetriage/issuetriage_test.go index e28f53a2b..2a0c7844e 100644 --- a/internal/pkg/externalplugins/issuetriage/issuetriage_test.go +++ b/internal/pkg/externalplugins/issuetriage/issuetriage_test.go @@ -82,7 +82,7 @@ func (f *fghc) RemoveLabel(owner, repo string, number int, label string) error { return fmt.Errorf("cannot remove %v from %s/%s/#%d", label, owner, repo, number) } -func (f *fghc) CreateStatus(owner, repo, sha string, s github.Status) error { +func (f *fghc) CreateStatus(_, _, sha string, s github.Status) error { f.lock.Lock() defer f.lock.Unlock() if f.Error != nil { @@ -110,13 +110,13 @@ func (f *fghc) CreateStatus(owner, repo, sha string, s github.Status) error { return nil } -func (f *fghc) GetCombinedStatus(owner, repo, ref string) (*github.CombinedStatus, error) { +func (f *fghc) GetCombinedStatus(_, _, ref string) (*github.CombinedStatus, error) { f.lock.RLock() defer f.lock.RUnlock() return f.CombinedStatuses[ref], nil } -func (f *fghc) GetPullRequest(owner, repo string, number int) (*github.PullRequest, error) { +func (f *fghc) GetPullRequest(_, _ string, number int) (*github.PullRequest, error) { f.lock.RLock() defer f.lock.RUnlock() val, exists := f.PullRequests[number] @@ -126,7 +126,7 @@ func (f *fghc) GetPullRequest(owner, repo string, number int) (*github.PullReque return val, nil } -func (f *fghc) GetIssue(owner, repo string, number int) (*github.Issue, error) { +func (f *fghc) GetIssue(_, _ string, number int) (*github.Issue, error) { f.lock.RLock() defer f.lock.RUnlock() val, exists := f.Issues[number] @@ -157,7 +157,7 @@ func (f *fghc) BotUserChecker() (func(candidate string) bool, error) { } func (f *fghc) QueryWithGitHubAppsSupport( - ctx context.Context, q interface{}, _ map[string]interface{}, _ string) error { + _ context.Context, q interface{}, _ map[string]interface{}, _ string) error { sq, ok := q.(*referencePullRequestQuery) if !ok { return errors.New("unexpected query type") diff --git a/internal/pkg/externalplugins/labelblocker/labelblocker_test.go b/internal/pkg/externalplugins/labelblocker/labelblocker_test.go index f4331f7d1..0b569d8cb 100644 --- a/internal/pkg/externalplugins/labelblocker/labelblocker_test.go +++ b/internal/pkg/externalplugins/labelblocker/labelblocker_test.go @@ -79,7 +79,7 @@ func (f *fghc) RemoveLabel(owner, repo string, number int, label string) error { } // ListTeams return a list of fake teams that correspond to the fake team members returned by ListTeamAllMembers -func (f *fghc) ListTeams(org string) ([]github.Team, error) { +func (f *fghc) ListTeams(_ string) ([]github.Team, error) { f.lock.RLock() defer f.lock.RUnlock() return []github.Team{ @@ -120,8 +120,7 @@ func (f *fghc) CreateComment(owner, repo string, number int, comment string) err return nil } -func (f *fghc) QueryWithGitHubAppsSupport( - ctx context.Context, q interface{}, vars map[string]interface{}, _ string) error { +func (f *fghc) QueryWithGitHubAppsSupport(_ context.Context, q interface{}, _ map[string]interface{}, _ string) error { sq, ok := q.(*lib.TeamMembersQuery) if !ok { return errors.New("unexpected query type") diff --git a/internal/pkg/externalplugins/lgtm/lgtm.go b/internal/pkg/externalplugins/lgtm/lgtm.go index 793d20a9f..d5bf871aa 100644 --- a/internal/pkg/externalplugins/lgtm/lgtm.go +++ b/internal/pkg/externalplugins/lgtm/lgtm.go @@ -41,7 +41,7 @@ var ( // HelpProvider constructs the PluginHelp for this plugin that takes into account enabled repositories. // HelpProvider defines the type for function that construct the PluginHelp for plugins. func HelpProvider(_ *tiexternalplugins.ConfigAgent) externalplugins.ExternalPluginHelpProvider { - return func(enabledRepos []config.OrgRepo) (*pluginhelp.PluginHelp, error) { + return func(_ []config.OrgRepo) (*pluginhelp.PluginHelp, error) { yamlSnippet, err := plugins.CommentMap.GenYaml(&tiexternalplugins.Configuration{ TiCommunityLgtm: []tiexternalplugins.TiCommunityLgtm{ { diff --git a/internal/pkg/externalplugins/lgtm/lgtm_test.go b/internal/pkg/externalplugins/lgtm/lgtm_test.go index a4f7f94fd..1d83bce90 100644 --- a/internal/pkg/externalplugins/lgtm/lgtm_test.go +++ b/internal/pkg/externalplugins/lgtm/lgtm_test.go @@ -139,7 +139,7 @@ func (f *fakeGithubClient) CreateComment(owner, repo string, number int, comment } // EditComment edits a comment. Its a stub that does nothing. -func (f *fakeGithubClient) EditComment(org, repo string, id int, comment string) error { +func (f *fakeGithubClient) EditComment(_, _ string, id int, comment string) error { f.lock.Lock() defer f.lock.Unlock() for num, ics := range f.IssueComments { @@ -170,7 +170,7 @@ func (f *fakeGithubClient) DeleteComment(owner, repo string, id int) error { } // ListIssueComments returns comments. -func (f *fakeGithubClient) ListIssueComments(owner, repo string, number int) ([]github.IssueComment, error) { +func (f *fakeGithubClient) ListIssueComments(_, _ string, number int) ([]github.IssueComment, error) { f.lock.RLock() defer f.lock.RUnlock() return append([]github.IssueComment{}, f.IssueComments[number]...), nil diff --git a/internal/pkg/externalplugins/owners/owners_test.go b/internal/pkg/externalplugins/owners/owners_test.go index b728336ae..642b678f1 100644 --- a/internal/pkg/externalplugins/owners/owners_test.go +++ b/internal/pkg/externalplugins/owners/owners_test.go @@ -27,7 +27,7 @@ type fakegithub struct { } // GetPullRequest returns details about the PR. -func (f *fakegithub) GetPullRequest(owner, repo string, number int) (*github.PullRequest, error) { +func (f *fakegithub) GetPullRequest(_, _ string, number int) (*github.PullRequest, error) { val, exists := f.PullRequests[number] if !exists { return nil, fmt.Errorf("pull request number %d does not exist", number) @@ -89,7 +89,7 @@ func (f *fakegithub) QueryWithGitHubAppsSupport( } // ListTeams return a list of fake teams that correspond to the fake team members returned by ListTeamMembers. -func (f *fakegithub) ListTeams(org string) ([]github.Team, error) { +func (f *fakegithub) ListTeams(string) ([]github.Team, error) { return []github.Team{ { ID: 0, diff --git a/internal/pkg/externalplugins/plugins.go b/internal/pkg/externalplugins/plugins.go index 87ef0c535..3cce2a0b1 100644 --- a/internal/pkg/externalplugins/plugins.go +++ b/internal/pkg/externalplugins/plugins.go @@ -64,7 +64,7 @@ func (pa *ConfigAgent) Set(pc *Configuration) { // then start returns the error. Future errors will halt updates but not stop. // If checkUnknownPlugins is true, unrecognized plugin names will make config // loading fail. -func (pa *ConfigAgent) Start(path string, checkUnknownPlugins bool) error { +func (pa *ConfigAgent) Start(path string, _ bool) error { if err := pa.Load(path); err != nil { return err } diff --git a/internal/pkg/rerere/rerere_test.go b/internal/pkg/rerere/rerere_test.go index 4738b0be0..53072e7b2 100644 --- a/internal/pkg/rerere/rerere_test.go +++ b/internal/pkg/rerere/rerere_test.go @@ -227,8 +227,7 @@ func TestRetesting(t *testing.T) { Timeout: time.Nanosecond * 5, }, run: func() mockCheck { - return func(log *logrus.Entry, ghc githubClient, contexts prowflagutil.Strings, - retestingBranch string, org string, repo string) (bool, error) { + return func(_ *logrus.Entry, _ githubClient, _ prowflagutil.Strings, _, _, _ string) (bool, error) { return true, nil } }, @@ -255,8 +254,7 @@ func TestRetesting(t *testing.T) { i++ return err == nil, err } - return func(log *logrus.Entry, ghc githubClient, contexts prowflagutil.Strings, - retestingBranch string, org string, repo string) (bool, error) { + return func(_ *logrus.Entry, _ githubClient, _ prowflagutil.Strings, _, _, _ string) (bool, error) { return next() } }, @@ -283,8 +281,8 @@ func TestRetesting(t *testing.T) { i++ return err == nil, err } - return func(log *logrus.Entry, ghc githubClient, contexts prowflagutil.Strings, - retestingBranch string, org string, repo string) (bool, error) { + return func(_ *logrus.Entry, _ githubClient, _ prowflagutil.Strings, + _, _, _ string) (bool, error) { return next() } }, @@ -311,8 +309,8 @@ func TestRetesting(t *testing.T) { i++ return err == nil, err } - return func(log *logrus.Entry, ghc githubClient, contexts prowflagutil.Strings, - retestingBranch string, org string, repo string) (bool, error) { + return func(_ *logrus.Entry, _ githubClient, _ prowflagutil.Strings, + _ string, _ string, _ string) (bool, error) { return next() } },