Skip to content

Commit

Permalink
chore: linting configuration fixes + forgotten lint violations (#154)
Browse files Browse the repository at this point in the history
* remove unneeded checks, bc they are enabled already

* linting fixes
  • Loading branch information
parkedwards authored Mar 29, 2024
1 parent 5166550 commit da98660
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 45 deletions.
33 changes: 0 additions & 33 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,59 +84,37 @@ linters:
linters-settings:
gocritic:
enabled-checks:
- appendAssign
- appendCombine
- argOrder
- assignOp
- badCall
- badCond
- badLock
- badRegexp
- badSorting
- boolExprSimplify
- builtinShadow
- builtinShadowDecl
- captLocal
- caseOrder
- codegenComment
- commentedOutCode
- commentedOutImport
- commentFormatting
- defaultCaseOrder
- deferInLoop
- deferUnlambda
- deprecatedComment
- docStub
- dupArg
- dupBranchBody
- dupCase
- dupImport
- dupSubExpr
- dynamicFmtString
- elseif
- emptyDecl
- emptyFallthrough
- emptyStringTest
- equalFold
- evalOrder
- exitAfterDefer
- exposedSyncMutex
- externalErrorReassign
- filepathJoin
- flagDeref
- flagName
- hexLiteral
- httpNoBody
- importShadow
- indexAlloc
- initClause
- mapKey
- methodExprCall
- nestingReduce
- newDeref
- nilValReturn
- octalLiteral
- offBy1
- preferDecodeRune
- preferFilepathJoin
- preferFprint
Expand All @@ -146,42 +124,31 @@ linters-settings:
- rangeExprCopy
- rangeValCopy
- redundantSprint
- regexpMust
- regexpPattern
- regexpSimplify
- returnAfterHttpError
- ruleguard
- singleCaseSwitch
- sliceClear
- sloppyLen
- sloppyReassign
- sloppyTypeAssert
- sortSlice
- sprintfQuotedString
- sqlQuery
- stringConcatSimplify
- stringsCompare
- stringXbytes
- switchTrue
- syncMapLoadAndDelete
- timeExprSimplify
- todoCommentWithoutDetail
- tooManyResultsChecker
- truncateCmp
- typeAssertChain
- typeDefFirst
- typeSwitchVar
- typeUnparen
- uncheckedInlineErr
- underef
- unlabelStmt
- unlambda
- unnamedResult
- unnecessaryBlock
- unnecessaryDefer
- unslice
- valSwap
- weakCond
- whyNoLint
- wrapperFunc
- yodaStyleExpr
8 changes: 5 additions & 3 deletions internal/provider/datasources/variable.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,13 @@ func (d *VariableDataSource) Read(ctx context.Context, req datasource.ReadReques
}

var variable *api.Variable
if !model.ID.IsNull() {

switch {
case !model.ID.IsNull():
variable, err = client.Get(ctx, model.ID.ValueUUID())
} else if !model.Name.IsNull() {
case !model.Name.IsNull():
variable, err = client.GetByName(ctx, model.Name.ValueString())
} else {
default:
resp.Diagnostics.AddError(
"Both ID and Name are unset",
"This is a bug in the Terraform provider. Please report it to the maintainers.",
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/resources/service_account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func testAccCheckServiceAccountResourceExists(serviceAccountResourceName string,
}

func testAccCheckServiceAccountValues(fetchedBot *api.ServiceAccount, valuesToCheck *api.ServiceAccount) resource.TestCheckFunc {
return func(s *terraform.State) error {
return func(_ *terraform.State) error {
if fetchedBot.Name != valuesToCheck.Name {
return fmt.Errorf("Expected Service Account name %s, got: %s", fetchedBot.Name, valuesToCheck.Name)
}
Expand Down
9 changes: 5 additions & 4 deletions internal/provider/resources/variable.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,9 @@ func (r *VariableResource) Read(ctx context.Context, req resource.ReadRequest, r
//
// If we are importing by name, then we will need to load once using the name.
var variable *api.Variable
if !model.ID.IsNull() {

switch {
case !model.ID.IsNull():
var variableID uuid.UUID
variableID, err = uuid.Parse(model.ID.ValueString())
if err != nil {
Expand All @@ -238,11 +240,10 @@ func (r *VariableResource) Read(ctx context.Context, req resource.ReadRequest, r

return
}

variable, err = client.Get(ctx, variableID)
} else if !model.Name.IsNull() {
case !model.Name.IsNull():
variable, err = client.GetByName(ctx, model.Name.ValueString())
} else {
default:
resp.Diagnostics.AddError(
"Both ID and Name are unset",
"This is a bug in the Terraform provider. Please report it to the maintainers.",
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/resources/variable_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func testAccCheckVariableExists(variableResourceName string, workspaceDatasource
}
}
func testAccCheckVariableValues(fetchedVariable *api.Variable, valuesToCheck *api.Variable) resource.TestCheckFunc {
return func(state *terraform.State) error {
return func(_ *terraform.State) error {
if fetchedVariable.Name != valuesToCheck.Name {
return fmt.Errorf("Expected variable name to be %s, got %s", valuesToCheck.Name, fetchedVariable.Name)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/resources/work_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func testAccCheckWorkPoolExists(workPoolResourceName string, workspaceDatasource
}

func testAccCheckWorkPoolValues(fetchedWorkPool *api.WorkPool, valuesToCheck *api.WorkPool) resource.TestCheckFunc {
return func(state *terraform.State) error {
return func(_ *terraform.State) error {
if fetchedWorkPool.Name != valuesToCheck.Name {
return fmt.Errorf("Expected work pool name to be %s, got %s", valuesToCheck.Name, fetchedWorkPool.Name)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/resources/workspace_role_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func testAccCheckWorkspaceRoleExists(roleResourceName string, role *api.Workspac
}

func testAccCheckWorkspaceRoleValues(fetchedRole *api.WorkspaceRole, valuesToCheck *api.WorkspaceRole) resource.TestCheckFunc {
return func(state *terraform.State) error {
return func(_ *terraform.State) error {
if fetchedRole.Name != valuesToCheck.Name {
return fmt.Errorf("Expected Workspace Role name %s, got: %s", fetchedRole.Name, valuesToCheck.Name)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/resources/workspace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func testAccCheckWorkspaceExists(workspaceResourceName string, workspace *api.Wo
}

func testAccCheckWorkspaceValues(fetchedWorkspace *api.Workspace, valuesToCheck *api.Workspace) resource.TestCheckFunc {
return func(s *terraform.State) error {
return func(_ *terraform.State) error {
if fetchedWorkspace.Name != valuesToCheck.Name {
return fmt.Errorf("Expected workspace name %s, got: %s", fetchedWorkspace.Name, valuesToCheck.Name)
}
Expand Down

0 comments on commit da98660

Please sign in to comment.