Skip to content

Commit ae1e404

Browse files
authored
chore: run golangci-lint for pull requests and annotate failing checks so we can fix them individually (#658)
1 parent d28c502 commit ae1e404

17 files changed

+36
-36
lines changed

.github/workflows/golangci-lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: golangci-lint
22

3-
on: push
3+
on: [push,pull_request]
44

55
jobs:
66
golangci:

gitlab/data_source_gitlab_group_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
)
1111

1212
func TestAccDataSourceGitlabGroup_basic(t *testing.T) {
13-
rString := fmt.Sprintf("%s", acctest.RandString(5))
13+
rString := fmt.Sprintf("%s", acctest.RandString(5)) // nolint // TODO: Resolve this golangci-lint issue: S1025: the argument is already a string, there's no need to use fmt.Sprintf (gosimple)
1414

1515
resource.Test(t, resource.TestCase{
1616
PreCheck: func() { testAccPreCheck(t) },

gitlab/data_source_gitlab_projects.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ func flattenGitlabBasicUser(user *gitlab.User) (values []map[string]interface{})
102102
}
103103

104104
func flattenProjects(projects []*gitlab.Project) (values []map[string]interface{}) {
105-
if projects != nil {
105+
if projects != nil { // nolint // TODO: Resolve this golangci-lint issue: S1031: unnecessary nil check around range (gosimple)
106106
for _, project := range projects {
107107
v := map[string]interface{}{
108108
"id": project.ID,

gitlab/data_source_gitlab_projects_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ func testAccDataSourceGitlabProjects(src string, n string) resource.TestCheckFun
137137

138138
var errorMessageExpected strings.Builder
139139
for _, attr := range testAttributes {
140-
errorMessageExpected.WriteString(fmt.Sprintf("%s=%v, ", attr, projectResource[fmt.Sprintf("%s", attr)]))
140+
errorMessageExpected.WriteString(fmt.Sprintf("%s=%v, ", attr, projectResource[fmt.Sprintf("%s", attr)])) // nolint // TODO: Resolve this golangci-lint issue: S1025: the argument is already a string, there's no need to use fmt.Sprintf (gosimple)
141141
}
142142

143143
var errorMessageGot strings.Builder

gitlab/data_source_gitlab_user_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
)
1111

1212
func TestAccDataSourceGitlabUser_basic(t *testing.T) {
13-
rString := fmt.Sprintf("%s", acctest.RandString(5))
13+
rString := fmt.Sprintf("%s", acctest.RandString(5)) // nolint // TODO: Resolve this golangci-lint issue: S1025: the argument is already a string, there's no need to use fmt.Sprintf (gosimple)
1414

1515
resource.Test(t, resource.TestCase{
1616
PreCheck: func() { testAccPreCheck(t) },

gitlab/helper_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ import (
1414
func testAccCompareGitLabAttribute(attr string, expected, received *schema.ResourceData) error {
1515
e := expected.Get(attr)
1616
r := received.Get(attr)
17-
switch e.(type) {
17+
switch e.(type) { // nolint // TODO: Resolve this golangci-lint issue: S1034: assigning the result of this type assertion to a variable (switch e := e.(type)) could eliminate type assertions in switch cases (gosimple)
1818
case *schema.Set:
19-
if !e.(*schema.Set).Equal(r) {
19+
if !e.(*schema.Set).Equal(r) { // nolint // TODO: Resolve this golangci-lint issue: S1034(related information): could eliminate this type assertion (gosimple)
2020
return fmt.Errorf(`attribute set %s expected "%+v" received "%+v"`, attr, e, r)
2121
}
2222
default:

gitlab/provider.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ func providerConfigure(p *schema.Provider, d *schema.ResourceData) (interface{},
142142

143143
// NOTE: httpclient.TerraformUserAgent is deprecated and removed in Terraform SDK v2
144144
// After upgrading the SDK to v2 replace with p.UserAgent("terraform-provider-gitlab")
145-
client.UserAgent = httpclient.TerraformUserAgent(p.TerraformVersion) + " terraform-provider-gitlab"
145+
client.UserAgent = httpclient.TerraformUserAgent(p.TerraformVersion) + " terraform-provider-gitlab" // nolint // TODO: Resolve this golangci-lint issue: SA1019: httpclient.TerraformUserAgent is deprecated: This will be removed in v2 without replacement. If you need its functionality, you can copy it or reference the v1 package. (staticcheck)
146146

147147
return client, err
148148
}

gitlab/resource_gitlab_deploy_key_enable.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func resourceGitlabDeployEnableKey() *schema.Resource {
5252
func resourceGitlabDeployKeyEnableCreate(d *schema.ResourceData, meta interface{}) error {
5353
client := meta.(*gitlab.Client)
5454
project := d.Get("project").(string)
55-
key_id, err := strconv.Atoi(d.Get("key_id").(string))
55+
key_id, err := strconv.Atoi(d.Get("key_id").(string)) // nolint // TODO: Resolve this golangci-lint issue: ineffectual assignment to err (ineffassign)
5656

5757
log.Printf("[DEBUG] enable gitlab deploy key %s/%d", project, key_id)
5858

gitlab/resource_gitlab_deploy_key_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ func testAccCheckGitlabDeployKeyDestroy(s *terraform.State) error {
153153
if rs.Type != "gitlab_project" {
154154
continue
155155
}
156-
deployKeyID, err := strconv.Atoi(rs.Primary.ID)
156+
deployKeyID, err := strconv.Atoi(rs.Primary.ID) // nolint // TODO: Resolve this golangci-lint issue: ineffectual assignment to err (ineffassign)
157157
project := rs.Primary.Attributes["project"]
158158

159159
gotDeployKey, resp, err := conn.DeployKeys.GetDeployKey(project, deployKeyID)

gitlab/resource_gitlab_group_ldap_link.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func resourceGitlabGroupLdapLinkCreate(d *schema.ResourceData, meta interface{})
7171
}
7272

7373
if force {
74-
resourceGitlabGroupLdapLinkDelete(d, meta)
74+
resourceGitlabGroupLdapLinkDelete(d, meta) // nolint // TODO: Resolve this golangci-lint issue: Error return value is not checked (errcheck)
7575
}
7676

7777
log.Printf("[DEBUG] Create GitLab group LdapLink %s", d.Id())
@@ -95,9 +95,9 @@ func resourceGitlabGroupLdapLinkRead(d *schema.ResourceData, meta interface{}) e
9595
if err != nil {
9696
// The read/GET API wasn't implemented in GitLab until version 12.8 (March 2020, well after the add and delete APIs).
9797
// If we 404, assume GitLab is at an older version and take things on faith.
98-
switch err.(type) {
98+
switch err.(type) { // nolint // TODO: Resolve this golangci-lint issue: S1034: assigning the result of this type assertion to a variable (switch err := err.(type)) could eliminate type assertions in switch cases (gosimple)
9999
case *gitlab.ErrorResponse:
100-
if err.(*gitlab.ErrorResponse).Response.StatusCode == 404 {
100+
if err.(*gitlab.ErrorResponse).Response.StatusCode == 404 { // nolint // TODO: Resolve this golangci-lint issue: S1034(related information): could eliminate this type assertion (gosimple)
101101
log.Printf("[WARNING] This GitLab instance doesn't have the GET API for group_ldap_sync. Please upgrade to 12.8 or later for best results.")
102102
} else {
103103
return err
@@ -124,7 +124,7 @@ func resourceGitlabGroupLdapLinkRead(d *schema.ResourceData, meta interface{}) e
124124

125125
if !found {
126126
d.SetId("")
127-
return errors.New(fmt.Sprintf("LdapLink %s does not exist.", d.Id()))
127+
return errors.New(fmt.Sprintf("LdapLink %s does not exist.", d.Id())) // nolint // TODO: Resolve this golangci-lint issue: S1028: should use fmt.Errorf(...) instead of errors.New(fmt.Sprintf(...)) (gosimple)
128128
}
129129
}
130130

@@ -140,10 +140,10 @@ func resourceGitlabGroupLdapLinkDelete(d *schema.ResourceData, meta interface{})
140140
log.Printf("[DEBUG] Delete GitLab group LdapLink %s", d.Id())
141141
_, err := client.Groups.DeleteGroupLDAPLinkForProvider(groupId, ldap_provider, cn)
142142
if err != nil {
143-
switch err.(type) {
143+
switch err.(type) { // nolint // TODO: Resolve this golangci-lint issue: S1034: assigning the result of this type assertion to a variable (switch err := err.(type)) could eliminate type assertions in switch cases (gosimple)
144144
case *gitlab.ErrorResponse:
145145
// Ignore LDAP links that don't exist
146-
if strings.Contains(string(err.(*gitlab.ErrorResponse).Message), "Linked LDAP group not found") {
146+
if strings.Contains(string(err.(*gitlab.ErrorResponse).Message), "Linked LDAP group not found") { // nolint // TODO: Resolve this golangci-lint issue: S1034(related information): could eliminate this type assertion (gosimple)
147147
log.Printf("[WARNING] %s", err)
148148
} else {
149149
return err

0 commit comments

Comments
 (0)