Enable some linters (#3129)

Mostly those that did not require much work.

From #2960

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
qwerty287
2024-01-09 21:35:37 +01:00
committed by GitHub
parent 631b7c2fed
commit 768fd71841
21 changed files with 121 additions and 63 deletions

View File

@@ -232,8 +232,7 @@ func Test_helper(t *testing.T) {
from.Sender.Login = github.String("octocat")
from.Sender.AvatarURL = github.String("https://avatars1.githubusercontent.com/u/583231")
_, pipeline, err := parseDeployHook(from)
g.Assert(err).IsNil()
_, pipeline := parseDeployHook(from)
g.Assert(pipeline.Event).Equal(model.EventDeploy)
g.Assert(pipeline.Branch).Equal("main")
g.Assert(pipeline.Ref).Equal("refs/heads/main")
@@ -255,8 +254,7 @@ func Test_helper(t *testing.T) {
from.HeadCommit.ID = github.String("f72fc19")
from.Ref = github.String("refs/heads/main")
_, pipeline, err := parsePushHook(from)
g.Assert(err).IsNil()
_, pipeline := parsePushHook(from)
g.Assert(pipeline.Event).Equal(model.EventPush)
g.Assert(pipeline.Branch).Equal("main")
g.Assert(pipeline.Ref).Equal("refs/heads/main")
@@ -273,8 +271,7 @@ func Test_helper(t *testing.T) {
from := &github.PushEvent{}
from.Ref = github.String("refs/tags/v1.0.0")
_, pipeline, err := parsePushHook(from)
g.Assert(err).IsNil()
_, pipeline := parsePushHook(from)
g.Assert(pipeline.Event).Equal(model.EventTag)
g.Assert(pipeline.Ref).Equal("refs/tags/v1.0.0")
})
@@ -284,8 +281,7 @@ func Test_helper(t *testing.T) {
from.Ref = github.String("refs/tags/v1.0.0")
from.BaseRef = github.String("refs/heads/main")
_, pipeline, err := parsePushHook(from)
g.Assert(err).IsNil()
_, pipeline := parsePushHook(from)
g.Assert(pipeline.Event).Equal(model.EventTag)
g.Assert(pipeline.Branch).Equal("main")
})
@@ -295,8 +291,7 @@ func Test_helper(t *testing.T) {
from.Ref = github.String("refs/tags/v1.0.0")
from.BaseRef = github.String("refs/refs/main")
_, pipeline, err := parsePushHook(from)
g.Assert(err).IsNil()
_, pipeline := parsePushHook(from)
g.Assert(pipeline.Event).Equal(model.EventTag)
g.Assert(pipeline.Branch).Equal("refs/tags/v1.0.0")
})

View File

@@ -61,11 +61,11 @@ func parseHook(r *http.Request, merge bool) (*github.PullRequest, *model.Repo, *
switch hook := payload.(type) {
case *github.PushEvent:
repo, pipeline, err := parsePushHook(hook)
return nil, repo, pipeline, err
repo, pipeline := parsePushHook(hook)
return nil, repo, pipeline, nil
case *github.DeploymentEvent:
repo, pipeline, err := parseDeployHook(hook)
return nil, repo, pipeline, err
repo, pipeline := parseDeployHook(hook)
return nil, repo, pipeline, nil
case *github.PullRequestEvent:
return parsePullHook(hook, merge)
default:
@@ -75,9 +75,9 @@ func parseHook(r *http.Request, merge bool) (*github.PullRequest, *model.Repo, *
// parsePushHook parses a push hook and returns the Repo and Pipeline details.
// If the commit type is unsupported nil values are returned.
func parsePushHook(hook *github.PushEvent) (*model.Repo, *model.Pipeline, error) {
func parsePushHook(hook *github.PushEvent) (*model.Repo, *model.Pipeline) {
if hook.Deleted != nil && *hook.Deleted {
return nil, nil, nil
return nil, nil
}
pipeline := &model.Pipeline{
@@ -110,12 +110,12 @@ func parsePushHook(hook *github.PushEvent) (*model.Repo, *model.Pipeline, error)
}
}
return convertRepoHook(hook.GetRepo()), pipeline, nil
return convertRepoHook(hook.GetRepo()), pipeline
}
// parseDeployHook parses a deployment and returns the Repo and Pipeline details.
// If the commit type is unsupported nil values are returned.
func parseDeployHook(hook *github.DeploymentEvent) (*model.Repo, *model.Pipeline, error) {
func parseDeployHook(hook *github.DeploymentEvent) (*model.Repo, *model.Pipeline) {
pipeline := &model.Pipeline{
Event: model.EventDeploy,
Commit: hook.GetDeployment().GetSHA(),
@@ -138,7 +138,7 @@ func parseDeployHook(hook *github.DeploymentEvent) (*model.Repo, *model.Pipeline
pipeline.Ref = fmt.Sprintf("refs/heads/%s", pipeline.Branch)
}
return convertRepo(hook.GetRepo()), pipeline, nil
return convertRepo(hook.GetRepo()), pipeline
}
// parsePullHook parses a pull request hook and returns the Repo and Pipeline