Skip to content

Commit 11e07db

Browse files
committed
fix lint issues minus the disable ones
1 parent 7056f21 commit 11e07db

25 files changed

+73
-69
lines changed

.golangci.yml

+8-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ linters:
1515
- stylecheck #https://github.com/dominikh/go-tools/tree/master/stylecheck
1616
- revive #golint is deprecated and golangci-lint recommends to use revive instead https://github.com/mgechev/revive
1717
#other deprecated lint libraries: maligned, scopelint, interfacer
18-
- gocritic
19-
- unparam
20-
- misspell
18+
- gocritic #https://github.com/go-critic/go-critic
19+
- unparam #https://github.com/mvdan/unparam
20+
- misspell #https://github.com/client9/misspell
2121
issues:
2222
exclude-rules:
2323
- path: _test\.go
@@ -38,6 +38,11 @@ linters-settings:
3838
- diagnostic
3939
- opinionated
4040
- performance
41+
disabled-checks:
42+
- unnamedResult
43+
- hugeParam
44+
- singleCaseSwitch
45+
- ifElseChain
4146
revive:
4247
# see https://github.com/mgechev/revive#available-rules for details.
4348
ignore-generated-header: false #recommended in their configuration

admin_organization.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ type AdminOrganizationID struct {
102102

103103
// List all the organizations visible to the current user.
104104
func (s *adminOrganizations) List(ctx context.Context, options *AdminOrganizationListOptions) (*AdminOrganizationList, error) {
105-
url := "admin/organizations"
106-
req, err := s.client.newRequest("GET", url, options)
105+
u := "admin/organizations"
106+
req, err := s.client.newRequest("GET", u, options)
107107
if err != nil {
108108
return nil, err
109109
}
@@ -122,9 +122,9 @@ func (s *adminOrganizations) ListModuleConsumers(ctx context.Context, organizati
122122
return nil, ErrInvalidOrg
123123
}
124124

125-
url := fmt.Sprintf("admin/organizations/%s/relationships/module-consumers", url.QueryEscape(organization))
125+
u := fmt.Sprintf("admin/organizations/%s/relationships/module-consumers", url.QueryEscape(organization))
126126

127-
req, err := s.client.newRequest("GET", url, nil)
127+
req, err := s.client.newRequest("GET", u, nil)
128128
if err != nil {
129129
return nil, err
130130
}
@@ -183,7 +183,7 @@ func (s *adminOrganizations) UpdateModuleConsumers(ctx context.Context, organiza
183183
return ErrInvalidOrg
184184
}
185185

186-
url := fmt.Sprintf("admin/organizations/%s/relationships/module-consumers", url.QueryEscape(organization))
186+
u := fmt.Sprintf("admin/organizations/%s/relationships/module-consumers", url.QueryEscape(organization))
187187

188188
var organizations []*AdminOrganizationID
189189
for _, id := range consumerOrganizationIDs {
@@ -193,7 +193,7 @@ func (s *adminOrganizations) UpdateModuleConsumers(ctx context.Context, organiza
193193
organizations = append(organizations, &AdminOrganizationID{ID: id})
194194
}
195195

196-
req, err := s.client.newRequest("PATCH", url, organizations)
196+
req, err := s.client.newRequest("PATCH", u, organizations)
197197
if err != nil {
198198
return err
199199
}

admin_user.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ type AdminUsers interface {
2727
// Unsuspend a user by its ID.
2828
Unsuspend(ctx context.Context, userID string) (*AdminUser, error)
2929

30-
// GrantAdmin grants admin privilages to a user by its ID.
30+
// GrantAdmin grants admin privileges to a user by its ID.
3131
GrantAdmin(ctx context.Context, userID string) (*AdminUser, error)
3232

33-
// RevokeAdmin revokees admin privilages to a user by its ID.
33+
// RevokeAdmin revokees admin privileges to a user by its ID.
3434
RevokeAdmin(ctx context.Context, userID string) (*AdminUser, error)
3535

3636
// Disable2FA disables a user's two-factor authentication in the situation
@@ -163,7 +163,7 @@ func (a *adminUsers) Unsuspend(ctx context.Context, userID string) (*AdminUser,
163163
return au, nil
164164
}
165165

166-
// GrantAdmin grants admin privilages to a user by its ID.
166+
// GrantAdmin grants admin privileges to a user by its ID.
167167
func (a *adminUsers) GrantAdmin(ctx context.Context, userID string) (*AdminUser, error) {
168168
if !validStringID(&userID) {
169169
return nil, ErrInvalidUserValue
@@ -184,7 +184,7 @@ func (a *adminUsers) GrantAdmin(ctx context.Context, userID string) (*AdminUser,
184184
return au, nil
185185
}
186186

187-
// RevokeAdmin revokes admin privilages to a user by its ID.
187+
// RevokeAdmin revokes admin privileges to a user by its ID.
188188
func (a *adminUsers) RevokeAdmin(ctx context.Context, userID string) (*AdminUser, error) {
189189
if !validStringID(&userID) {
190190
return nil, ErrInvalidUserValue

apply.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ type applies struct {
3131
// ApplyStatus represents an apply state.
3232
type ApplyStatus string
3333

34-
//List all available apply statuses.
34+
// List all available apply statuses.
3535
const (
3636
ApplyCanceled ApplyStatus = "canceled"
3737
ApplyCreated ApplyStatus = "created"

configuration_version.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ type configurationVersions struct {
4747
// ConfigurationStatus represents a configuration version status.
4848
type ConfigurationStatus string
4949

50-
//List all available configuration version statuses.
50+
// List all available configuration version statuses.
5151
const (
5252
ConfigurationErrored ConfigurationStatus = "errored"
5353
ConfigurationPending ConfigurationStatus = "pending"
@@ -234,7 +234,7 @@ func (s *configurationVersions) ReadWithOptions(ctx context.Context, cvID string
234234
// Upload packages and uploads Terraform configuration files. It requires the
235235
// upload URL from a configuration version and the path to the configuration
236236
// files on disk.
237-
func (s *configurationVersions) Upload(ctx context.Context, url, path string) error {
237+
func (s *configurationVersions) Upload(ctx context.Context, u, path string) error {
238238
file, err := os.Stat(path)
239239
if err != nil {
240240
return err
@@ -250,7 +250,7 @@ func (s *configurationVersions) Upload(ctx context.Context, url, path string) er
250250
return err
251251
}
252252

253-
req, err := s.client.newRequest("PUT", url, body)
253+
req, err := s.client.newRequest("PUT", u, body)
254254
if err != nil {
255255
return err
256256
}

helper_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ var _testAccountDetails *TestAccountDetails
2323

2424
func testClient(t *testing.T) *Client {
2525
client, err := NewClient(nil)
26-
client.RetryServerErrors(true) // because ocasionally we get a 500 internal when deleting an organization's workspace
26+
client.RetryServerErrors(true) // because occasionally we get a 500 internal when deleting an organization's workspace
2727
if err != nil {
2828
t.Fatal(err)
2929
}
@@ -457,7 +457,7 @@ func createOrganizationToken(t *testing.T, client *Client, org *Organization) (*
457457
}
458458
}
459459

460-
func createRunTrigger(t *testing.T, client *Client, w *Workspace, sourceable *Workspace) (*RunTrigger, func()) {
460+
func createRunTrigger(t *testing.T, client *Client, w, sourceable *Workspace) (*RunTrigger, func()) {
461461
var wCleanup func()
462462
var sourceableCleanup func()
463463

organization_tags_integration_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ func TestOrganizationTagsDelete(t *testing.T) {
122122
})
123123
require.NoError(t, err)
124124

125-
//sanity check ensure tags were deleted from the organization
125+
// sanity check ensure tags were deleted from the organization
126126
tags, err = client.OrganizationTags.List(ctx, orgTest.Name, nil)
127127
require.NoError(t, err)
128128

@@ -175,7 +175,7 @@ func TestOrganizationTagsAddWorkspace(t *testing.T) {
175175
})
176176
require.NoError(t, err)
177177

178-
//Ensure the tag was properly associated with the workspaces
178+
// Ensure the tag was properly associated with the workspaces
179179
fetched, err := client.Workspaces.ListTags(ctx, workspaceToAdd1.ID, nil)
180180
require.NoError(t, err)
181181
assert.Equal(t, fetched.Items[0].ID, tagID)

plan.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ type plans struct {
3535
// PlanStatus represents a plan state.
3636
type PlanStatus string
3737

38-
//List all available plan statuses.
38+
// List all available plan statuses.
3939
const (
4040
PlanCanceled PlanStatus = "canceled"
4141
PlanCreated PlanStatus = "created"

policy_check.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const (
4848
// PolicyStatus represents a policy check state.
4949
type PolicyStatus string
5050

51-
//List all available policy check statuses.
51+
// List all available policy check statuses.
5252
const (
5353
PolicyCanceled PolicyStatus = "canceled"
5454
PolicyErrored PolicyStatus = "errored"

policy_set.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ type PolicySetUpdateOptions struct {
236236
// https://jsonapi.org/format/#crud-creating
237237
Type string `jsonapi:"primary,policy-sets"`
238238

239-
/// The name of the policy set.
239+
// The name of the policy set.
240240
Name *string `jsonapi:"attr,name,omitempty"`
241241

242242
// The description of the policy set.
@@ -293,7 +293,7 @@ func (s *policySets) Update(ctx context.Context, policySetID string, options Pol
293293
// PolicySetAddPoliciesOptions represents the options for adding policies
294294
// to a policy set.
295295
type PolicySetAddPoliciesOptions struct {
296-
/// The policies to add to the policy set.
296+
// The policies to add to the policy set.
297297
Policies []*Policy
298298
}
299299

@@ -328,7 +328,7 @@ func (s *policySets) AddPolicies(ctx context.Context, policySetID string, option
328328
// PolicySetRemovePoliciesOptions represents the options for removing
329329
// policies from a policy set.
330330
type PolicySetRemovePoliciesOptions struct {
331-
/// The policies to remove from the policy set.
331+
// The policies to remove from the policy set.
332332
Policies []*Policy
333333
}
334334

@@ -363,7 +363,7 @@ func (s *policySets) RemovePolicies(ctx context.Context, policySetID string, opt
363363
// PolicySetAddWorkspacesOptions represents the options for adding workspaces
364364
// to a policy set.
365365
type PolicySetAddWorkspacesOptions struct {
366-
/// The workspaces to add to the policy set.
366+
// The workspaces to add to the policy set.
367367
Workspaces []*Workspace
368368
}
369369

@@ -398,7 +398,7 @@ func (s *policySets) AddWorkspaces(ctx context.Context, policySetID string, opti
398398
// PolicySetRemoveWorkspacesOptions represents the options for removing
399399
// workspaces from a policy set.
400400
type PolicySetRemoveWorkspacesOptions struct {
401-
/// The workspaces to remove from the policy set.
401+
// The workspaces to remove from the policy set.
402402
Workspaces []*Workspace
403403
}
404404

policy_set_parameter.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ func (s *policySetParameters) Create(ctx context.Context, policySetID string, op
138138
}
139139

140140
// Read a parameter by its ID.
141-
func (s *policySetParameters) Read(ctx context.Context, policySetID string, parameterID string) (*PolicySetParameter, error) {
141+
func (s *policySetParameters) Read(ctx context.Context, policySetID, parameterID string) (*PolicySetParameter, error) {
142142
if !validStringID(&policySetID) {
143143
return nil, ErrInvalidPolicySetID
144144
}
@@ -180,7 +180,7 @@ type PolicySetParameterUpdateOptions struct {
180180
}
181181

182182
// Update values of an existing parameter.
183-
func (s *policySetParameters) Update(ctx context.Context, policySetID string, parameterID string, options PolicySetParameterUpdateOptions) (*PolicySetParameter, error) {
183+
func (s *policySetParameters) Update(ctx context.Context, policySetID, parameterID string, options PolicySetParameterUpdateOptions) (*PolicySetParameter, error) {
184184
if !validStringID(&policySetID) {
185185
return nil, ErrInvalidPolicySetID
186186
}
@@ -204,7 +204,7 @@ func (s *policySetParameters) Update(ctx context.Context, policySetID string, pa
204204
}
205205

206206
// Delete a parameter by its ID.
207-
func (s *policySetParameters) Delete(ctx context.Context, policySetID string, parameterID string) error {
207+
func (s *policySetParameters) Delete(ctx context.Context, policySetID, parameterID string) error {
208208
if !validStringID(&policySetID) {
209209
return ErrInvalidPolicySetID
210210
}

policy_set_version.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const (
4747
// PolicySetVersionStatus represents a policy set version status.
4848
type PolicySetVersionStatus string
4949

50-
//List all available policy set version statuses.
50+
// List all available policy set version statuses.
5151
const (
5252
PolicySetVersionErrored PolicySetVersionStatus = "errored"
5353
PolicySetVersionIngressing PolicySetVersionStatus = "ingressing"

registry_module.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ func (o RegistryModuleCreateVersionOptions) valid() error {
214214
}
215215

216216
// Create a new registry module version
217-
func (r *registryModules) CreateVersion(ctx context.Context, organization string, name string, provider string, options RegistryModuleCreateVersionOptions) (*RegistryModuleVersion, error) {
217+
func (r *registryModules) CreateVersion(ctx context.Context, organization, name, provider string, options RegistryModuleCreateVersionOptions) (*RegistryModuleVersion, error) {
218218
if !validStringID(&organization) {
219219
return nil, ErrInvalidOrg
220220
}
@@ -313,7 +313,7 @@ func (r *registryModules) CreateWithVCSConnection(ctx context.Context, options R
313313
}
314314

315315
// Read a specific registry module
316-
func (r *registryModules) Read(ctx context.Context, organization string, name string, provider string) (*RegistryModule, error) {
316+
func (r *registryModules) Read(ctx context.Context, organization, name, provider string) (*RegistryModule, error) {
317317
if !validStringID(&organization) {
318318
return nil, ErrInvalidOrg
319319
}
@@ -351,7 +351,7 @@ func (r *registryModules) Read(ctx context.Context, organization string, name st
351351
}
352352

353353
// Delete is used to delete the entire registry module
354-
func (r *registryModules) Delete(ctx context.Context, organization string, name string) error {
354+
func (r *registryModules) Delete(ctx context.Context, organization, name string) error {
355355
if !validStringID(&organization) {
356356
return ErrInvalidOrg
357357
}
@@ -376,7 +376,7 @@ func (r *registryModules) Delete(ctx context.Context, organization string, name
376376
}
377377

378378
// DeleteProvider is used to delete the specific registry module provider
379-
func (r *registryModules) DeleteProvider(ctx context.Context, organization string, name string, provider string) error {
379+
func (r *registryModules) DeleteProvider(ctx context.Context, organization, name, provider string) error {
380380
if !validStringID(&organization) {
381381
return ErrInvalidOrg
382382
}
@@ -408,7 +408,7 @@ func (r *registryModules) DeleteProvider(ctx context.Context, organization strin
408408
}
409409

410410
// DeleteVersion is used to delete the specific registry module version
411-
func (r *registryModules) DeleteVersion(ctx context.Context, organization string, name string, provider string, version string) error {
411+
func (r *registryModules) DeleteVersion(ctx context.Context, organization, name, provider, version string) error {
412412
if !validStringID(&organization) {
413413
return ErrInvalidOrg
414414
}

run.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ type runs struct {
4848
// RunStatus represents a run state.
4949
type RunStatus string
5050

51-
//List all available run statuses.
51+
// List all available run statuses.
5252
const (
5353
RunApplied RunStatus = "applied"
5454
RunApplyQueued RunStatus = "apply_queued"

run_task.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ func (s *runTasks) Delete(ctx context.Context, runTaskID string) error {
267267
}
268268

269269
// Convenient method to attach a run task to a workspace. See: WorkspaceRunTasks.Create()
270-
func (s *runTasks) AttachToWorkspace(ctx context.Context, workspaceID string, runTaskID string, enforcement TaskEnforcementLevel) (*WorkspaceRunTask, error) {
270+
func (s *runTasks) AttachToWorkspace(ctx context.Context, workspaceID, runTaskID string, enforcement TaskEnforcementLevel) (*WorkspaceRunTask, error) {
271271
return s.client.WorkspaceRunTasks.Create(ctx, workspaceID, WorkspaceRunTaskCreateOptions{
272272
EnforcementLevel: enforcement,
273273
RunTask: &RunTask{ID: runTaskID},

state_version.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ type StateVersionListOptions struct {
7474
Workspace string `url:"filter[workspace][name]"`
7575
}
7676

77-
//check that StateVersionListOptions fields had valid values
7877
func (o *StateVersionListOptions) valid() error {
7978
if o == nil {
8079
return ErrRequiredStateVerListOps
@@ -247,8 +246,8 @@ func (s *stateVersions) ReadCurrent(ctx context.Context, workspaceID string) (*S
247246
}
248247

249248
// Download retrieves the actual stored state of a state version
250-
func (s *stateVersions) Download(ctx context.Context, url string) ([]byte, error) {
251-
req, err := s.client.newRequest("GET", url, nil)
249+
func (s *stateVersions) Download(ctx context.Context, u string) ([]byte, error) {
250+
req, err := s.client.newRequest("GET", u, nil)
252251
if err != nil {
253252
return nil, err
254253
}

state_version_output.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import (
99
// Compile-time proof of interface implementation.
1010
var _ StateVersionOutputs = (*stateVersionOutputs)(nil)
1111

12-
//State version outputs are the output values from a Terraform state file.
13-
//They include the name and value of the output, as well as a sensitive boolean
14-
//if the value should be hidden by default in UIs.
12+
// State version outputs are the output values from a Terraform state file.
13+
// They include the name and value of the output, as well as a sensitive boolean
14+
// if the value should be hidden by default in UIs.
1515
//
1616
// TFE API docs: https://www.terraform.io/docs/cloud/api/state-version-outputs.html
1717
type StateVersionOutputs interface {

task_result.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ type taskResults struct {
2121
client *Client
2222
}
2323

24-
//TaskResultStatus is an enum that represents all possible statuses for a task result
24+
// TaskResultStatus is an enum that represents all possible statuses for a task result
2525
type TaskResultStatus string
2626

27-
//TaskEnforcementLevel is an enum that describes the enforcement levels for a run task
27+
// TaskEnforcementLevel is an enum that describes the enforcement levels for a run task
2828
type TaskEnforcementLevel string
2929

3030
const (

team_access.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ type TeamAccessListOptions struct {
106106
WorkspaceID string `url:"filter[workspace][id]"`
107107
}
108108

109-
//check that workspaceID field has a valid value
109+
// check that workspaceID field has a valid value
110110
func (o *TeamAccessListOptions) valid() error {
111111
if o == nil {
112112
return ErrRequiredTeamAccessListOps

0 commit comments

Comments
 (0)