Skip to content

Commit 4131da2

Browse files
committed
fix(lint): resolve R001, R002, S024, S013, R010, S019, S006, S020 issues
1 parent 77edfaf commit 4131da2

19 files changed

Lines changed: 67 additions & 71 deletions

github/data_source_github_actions_registration_token.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ func dataSourceGithubActionsRegistrationToken() *schema.Resource {
1717
"repository": {
1818
Type: schema.TypeString,
1919
Required: true,
20-
ForceNew: true,
2120
Description: "The name of the repository.",
2221
},
2322
"token": {

github/data_source_github_app_token_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ func TestAccGithubAppTokenDataSource(t *testing.T) {
4848
}
4949

5050
testSchema := map[string]*schema.Schema{
51-
"app_id": {Type: schema.TypeString, Description: "The GitHub App ID."},
52-
"installation_id": {Type: schema.TypeString, Description: "The GitHub App installation instance ID."},
53-
"pem_file": {Type: schema.TypeString, Description: "The content of the GitHub App PEM file."},
54-
"token": {Type: schema.TypeString, Description: "The generated GitHub App installation access token."},
51+
"app_id": {Type: schema.TypeString, Required: true, Description: "The GitHub App ID."},
52+
"installation_id": {Type: schema.TypeString, Required: true, Description: "The GitHub App installation instance ID."},
53+
"pem_file": {Type: schema.TypeString, Required: true, Description: "The content of the GitHub App PEM file."},
54+
"token": {Type: schema.TypeString, Computed: true, Description: "The generated GitHub App installation access token."},
5555
}
5656

5757
schema := schema.TestResourceDataRaw(t, testSchema, map[string]any{

github/data_source_github_branch.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,11 @@ func dataSourceGithubBranch() *schema.Resource {
1919
"repository": {
2020
Type: schema.TypeString,
2121
Required: true,
22-
ForceNew: true,
2322
Description: "The GitHub repository name.",
2423
},
2524
"branch": {
2625
Type: schema.TypeString,
2726
Required: true,
28-
ForceNew: true,
2927
Description: "The repository branch to retrieve.",
3028
},
3129
"etag": {
@@ -73,11 +71,11 @@ func dataSourceGithubBranchRead(d *schema.ResourceData, meta any) error {
7371
if err != nil {
7472
return err
7573
}
76-
err = d.Set("ref", *ref.Ref)
74+
err = d.Set("ref", ref.Ref)
7775
if err != nil {
7876
return err
7977
}
80-
err = d.Set("sha", *ref.Object.SHA)
78+
err = d.Set("sha", ref.Object.SHA)
8179
if err != nil {
8280
return err
8381
}

github/data_source_github_organization_repository_role.go

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -75,20 +75,22 @@ func dataSourceGithubOrganizationRepositoryRoleRead(ctx context.Context, d *sche
7575
return diag.FromErr(fmt.Errorf("custom organization repo role with ID %d not found", roleId))
7676
}
7777

78-
r := map[string]any{
79-
"role_id": role.GetID(),
80-
"name": role.GetName(),
81-
"description": role.GetDescription(),
82-
"base_role": role.GetBaseRole(),
83-
"permissions": role.Permissions,
84-
}
85-
8678
d.SetId(strconv.FormatInt(role.GetID(), 10))
8779

88-
for k, v := range r {
89-
if err := d.Set(k, v); err != nil {
90-
return diag.FromErr(err)
91-
}
80+
if err := d.Set("role_id", role.GetID()); err != nil {
81+
return diag.FromErr(err)
82+
}
83+
if err := d.Set("name", role.GetName()); err != nil {
84+
return diag.FromErr(err)
85+
}
86+
if err := d.Set("description", role.GetDescription()); err != nil {
87+
return diag.FromErr(err)
88+
}
89+
if err := d.Set("base_role", role.GetBaseRole()); err != nil {
90+
return diag.FromErr(err)
91+
}
92+
if err := d.Set("permissions", role.Permissions); err != nil {
93+
return diag.FromErr(err)
9294
}
9395

9496
return nil

github/data_source_github_organization_role.go

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -61,21 +61,25 @@ func dataSourceGithubOrganizationRoleRead(ctx context.Context, d *schema.Resourc
6161
return diag.FromErr(err)
6262
}
6363

64-
r := map[string]any{
65-
"role_id": int(role.GetID()),
66-
"name": role.GetName(),
67-
"description": role.GetDescription(),
68-
"source": role.GetSource(),
69-
"base_role": role.GetBaseRole(),
70-
"permissions": role.Permissions,
71-
}
72-
7364
d.SetId(strconv.FormatInt(role.GetID(), 10))
7465

75-
for k, v := range r {
76-
if err := d.Set(k, v); err != nil {
77-
return diag.FromErr(err)
78-
}
66+
if err := d.Set("role_id", int(role.GetID())); err != nil {
67+
return diag.FromErr(err)
68+
}
69+
if err := d.Set("name", role.GetName()); err != nil {
70+
return diag.FromErr(err)
71+
}
72+
if err := d.Set("description", role.GetDescription()); err != nil {
73+
return diag.FromErr(err)
74+
}
75+
if err := d.Set("source", role.GetSource()); err != nil {
76+
return diag.FromErr(err)
77+
}
78+
if err := d.Set("base_role", role.GetBaseRole()); err != nil {
79+
return diag.FromErr(err)
80+
}
81+
if err := d.Set("permissions", role.Permissions); err != nil {
82+
return diag.FromErr(err)
7983
}
8084

8185
return nil

github/data_source_github_ref.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,11 @@ func dataSourceGithubRef() *schema.Resource {
1919
"ref": {
2020
Type: schema.TypeString,
2121
Required: true,
22-
ForceNew: true,
2322
Description: "The repository ref to look up. Must be formatted 'heads/<ref>' for branches, and 'tags/<ref>' for tags.",
2423
},
2524
"repository": {
2625
Type: schema.TypeString,
2726
Required: true,
28-
ForceNew: true,
2927
Description: "The GitHub repository name.",
3028
},
3129
"owner": {
@@ -75,7 +73,7 @@ func dataSourceGithubRefRead(d *schema.ResourceData, meta any) error {
7573
if err != nil {
7674
return err
7775
}
78-
err = d.Set("sha", *refData.Object.SHA)
76+
err = d.Set("sha", refData.Object.SHA)
7977
if err != nil {
8078
return err
8179
}

github/data_source_github_repository_deployment_branch_policies.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,11 @@ func dataSourceGithubRepositoryDeploymentBranchPolicies() *schema.Resource {
1818
"repository": {
1919
Type: schema.TypeString,
2020
Required: true,
21-
ForceNew: true,
2221
Description: "The GitHub repository name.",
2322
},
2423
"environment_name": {
2524
Type: schema.TypeString,
2625
Required: true,
27-
ForceNew: true,
2826
Description: "The target environment name.",
2927
},
3028
"deployment_branch_policies": {

github/data_source_github_rest_api.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ func dataSourceGithubRestApi() *schema.Resource {
1717
"endpoint": {
1818
Type: schema.TypeString,
1919
Required: true,
20-
ForceNew: true,
2120
Description: "REST API endpoint to send the GET request to.",
2221
},
2322
"code": {

github/resource_github_actions_organization_variable.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ func resourceGithubActionsOrganizationVariableRead(d *schema.ResourceData, meta
181181
if err = d.Set("updated_at", variable.UpdatedAt.String()); err != nil {
182182
return err
183183
}
184-
if err = d.Set("visibility", *variable.Visibility); err != nil {
184+
if err = d.Set("visibility", variable.Visibility); err != nil {
185185
return err
186186
}
187187

github/resource_github_branch.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ func resourceGithubBranchCreate(d *schema.ResourceData, meta any) error {
9393
return fmt.Errorf("error querying GitHub branch reference %s/%s (%s): %w",
9494
orgName, repoName, sourceBranchRefName, err)
9595
}
96-
if err = d.Set("source_sha", *ref.Object.SHA); err != nil {
96+
if err = d.Set("source_sha", ref.Object.SHA); err != nil {
9797
return err
9898
}
9999
}
@@ -157,10 +157,10 @@ func resourceGithubBranchRead(d *schema.ResourceData, meta any) error {
157157
if err = d.Set("branch", branchName); err != nil {
158158
return err
159159
}
160-
if err = d.Set("ref", *ref.Ref); err != nil {
160+
if err = d.Set("ref", ref.Ref); err != nil {
161161
return err
162162
}
163-
if err = d.Set("sha", *ref.Object.SHA); err != nil {
163+
if err = d.Set("sha", ref.Object.SHA); err != nil {
164164
return err
165165
}
166166

0 commit comments

Comments
 (0)