From 8067f3b227cf709850d2071c32342fda5b114f72 Mon Sep 17 00:00:00 2001 From: Christoph Witzko <github@christophwitzko.com> Date: Fri, 13 Jan 2023 13:56:43 +0100 Subject: [PATCH] style: add .golangci-lint.yaml --- .golangci.yaml | 25 +++++++++++++++++++++++++ pkg/condition/gitlab.go | 7 +++---- pkg/condition/gitlab_test.go | 2 +- 3 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 .golangci.yaml diff --git a/.golangci.yaml b/.golangci.yaml new file mode 100644 index 0000000..f5c0478 --- /dev/null +++ b/.golangci.yaml @@ -0,0 +1,25 @@ +linters: + enable: + - errorlint + - forbidigo + - gochecknoinits + - gocritic + - goconst + - gocyclo + - gofumpt + - goimports + - misspell + - revive + - unconvert + - unparam + - wastedassign + +linters-settings: + gocyclo: + min-complexity: 12 + gofumpt: + extra-rules: true + govet: + enable-all: true + disable: + - fieldalignment diff --git a/pkg/condition/gitlab.go b/pkg/condition/gitlab.go index 5aab319..517d2b6 100644 --- a/pkg/condition/gitlab.go +++ b/pkg/condition/gitlab.go @@ -7,8 +7,7 @@ import ( var CIVERSION = "dev" -type GitLab struct { -} +type GitLab struct{} func (gl *GitLab) Name() string { return "GitLab CI" @@ -33,10 +32,10 @@ func (gl *GitLab) IsBranchRef() bool { func (gl *GitLab) RunCondition(config map[string]string) error { defaultBranch := config["defaultBranch"] if !gl.IsBranchRef() { - return fmt.Errorf("This test run is not running on a branch build.") + return fmt.Errorf("this test run is not running on a branch build") } if branch := gl.GetCurrentBranch(); defaultBranch != "*" && branch != defaultBranch { - return fmt.Errorf("This test run was triggered on the branch %s, while semantic-release is configured to only publish from %s.", branch, defaultBranch) + return fmt.Errorf("this test run was triggered on the branch %s, while semantic-release is configured to only publish from %s", branch, defaultBranch) } return nil } diff --git a/pkg/condition/gitlab_test.go b/pkg/condition/gitlab_test.go index 1c127b2..e72d41e 100644 --- a/pkg/condition/gitlab_test.go +++ b/pkg/condition/gitlab_test.go @@ -11,5 +11,5 @@ func TestGitlabValid(t *testing.T) { gl := GitLab{} os.Setenv("CI_COMMIT_BRANCH", "") err := gl.RunCondition(map[string]string{"defaultBranch": ""}) - assert.EqualError(t, err, "This test run is not running on a branch build.") + assert.EqualError(t, err, "this test run is not running on a branch build") } -- GitLab