Skip to content

Commit 9e750b3

Browse files
committed
Enable extra rules and goimports
1 parent 68d71b6 commit 9e750b3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+69
-71
lines changed

.golangci.yaml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ linters:
1010
- unused
1111
- gofmt
1212
- gofumpt
13-
#- goimports
13+
- goimports
1414
linters-settings:
1515
govet:
1616
enable-all: true
@@ -31,10 +31,8 @@ linters-settings:
3131
- (*github.com/spf13/pflag.FlagSet).MarkHidden
3232
gofumpt:
3333
module-path: github.com/databricks/cli
34-
# Choose whether to use the extra rules.
35-
# Default: false
36-
#extra-rules: true
37-
goimports:
38-
local-prefixes: github.com/databricks/cli
34+
extra-rules: true
35+
#goimports:
36+
# local-prefixes: github.com/databricks/cli
3937
issues:
4038
exclude-dirs-use-default: false # recommended by docs https://golangci-lint.run/usage/false-positives/

bundle/config/mutator/initialize_urls.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func (m *initializeURLs) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagn
3838
return nil
3939
}
4040

41-
func initializeForWorkspace(b *bundle.Bundle, orgId string, host string) error {
41+
func initializeForWorkspace(b *bundle.Bundle, orgId, host string) error {
4242
baseURL, err := url.Parse(host)
4343
if err != nil {
4444
return err

bundle/config/mutator/python/python_mutator.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ func createCacheDir(ctx context.Context) (string, error) {
150150
return os.MkdirTemp("", "-pydabs")
151151
}
152152

153-
func (m *pythonMutator) runPythonMutator(ctx context.Context, cacheDir string, rootPath string, pythonPath string, root dyn.Value) (dyn.Value, diag.Diagnostics) {
153+
func (m *pythonMutator) runPythonMutator(ctx context.Context, cacheDir, rootPath, pythonPath string, root dyn.Value) (dyn.Value, diag.Diagnostics) {
154154
inputPath := filepath.Join(cacheDir, "input.json")
155155
outputPath := filepath.Join(cacheDir, "output.json")
156156
diagnosticsPath := filepath.Join(cacheDir, "diagnostics.json")
@@ -264,7 +264,7 @@ func writeInputFile(inputPath string, input dyn.Value) error {
264264
return os.WriteFile(inputPath, rootConfigJson, 0o600)
265265
}
266266

267-
func loadOutputFile(rootPath string, outputPath string) (dyn.Value, diag.Diagnostics) {
267+
func loadOutputFile(rootPath, outputPath string) (dyn.Value, diag.Diagnostics) {
268268
outputFile, err := os.Open(outputPath)
269269
if err != nil {
270270
return dyn.InvalidValue, diag.FromErr(fmt.Errorf("failed to open output file: %w", err))
@@ -379,7 +379,7 @@ func createLoadOverrideVisitor(ctx context.Context) merge.OverrideVisitor {
379379

380380
return right, nil
381381
},
382-
VisitUpdate: func(valuePath dyn.Path, left dyn.Value, right dyn.Value) (dyn.Value, error) {
382+
VisitUpdate: func(valuePath dyn.Path, left, right dyn.Value) (dyn.Value, error) {
383383
return dyn.InvalidValue, fmt.Errorf("unexpected change at %q (update)", valuePath.String())
384384
},
385385
}
@@ -428,7 +428,7 @@ func createInitOverrideVisitor(ctx context.Context) merge.OverrideVisitor {
428428

429429
return right, nil
430430
},
431-
VisitUpdate: func(valuePath dyn.Path, left dyn.Value, right dyn.Value) (dyn.Value, error) {
431+
VisitUpdate: func(valuePath dyn.Path, left, right dyn.Value) (dyn.Value, error) {
432432
if !valuePath.HasPrefix(jobsPath) {
433433
return dyn.InvalidValue, fmt.Errorf("unexpected change at %q (update)", valuePath.String())
434434
}

bundle/config/mutator/python/python_mutator_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ or activate the environment before running CLI commands:
587587
assert.Equal(t, expected, out)
588588
}
589589

590-
func withProcessStub(t *testing.T, args []string, output string, diagnostics string) context.Context {
590+
func withProcessStub(t *testing.T, args []string, output, diagnostics string) context.Context {
591591
ctx := context.Background()
592592
ctx, stub := process.WithStub(ctx)
593593

@@ -625,7 +625,7 @@ func withProcessStub(t *testing.T, args []string, output string, diagnostics str
625625
return ctx
626626
}
627627

628-
func loadYaml(name string, content string) *bundle.Bundle {
628+
func loadYaml(name, content string) *bundle.Bundle {
629629
v, diag := config.LoadFromBytes(name, []byte(content))
630630

631631
if diag.Error() != nil {

bundle/config/mutator/run_as.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func (m *setRunAs) Name() string {
2929
return "SetRunAs"
3030
}
3131

32-
func reportRunAsNotSupported(resourceType string, location dyn.Location, currentUser string, runAsUser string) diag.Diagnostics {
32+
func reportRunAsNotSupported(resourceType string, location dyn.Location, currentUser, runAsUser string) diag.Diagnostics {
3333
return diag.Diagnostics{{
3434
Summary: fmt.Sprintf("%s do not support a setting a run_as user that is different from the owner.\n"+
3535
"Current identity: %s. Run as identity: %s.\n"+

bundle/config/mutator/sync_infer_root.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func (m *syncInferRoot) Name() string {
3535
// If the path does not exist, it returns an empty string.
3636
//
3737
// See "sync_infer_root_internal_test.go" for examples.
38-
func (m *syncInferRoot) computeRoot(path string, root string) string {
38+
func (m *syncInferRoot) computeRoot(path, root string) string {
3939
for !filepath.IsLocal(path) {
4040
// Break if we have reached the root of the filesystem.
4141
dir := filepath.Dir(root)

bundle/deferred.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ func (d *DeferredMutator) Name() string {
1515
return "deferred"
1616
}
1717

18-
func Defer(mutator Mutator, finally Mutator) Mutator {
18+
func Defer(mutator, finally Mutator) Mutator {
1919
return &DeferredMutator{
2020
mutator: mutator,
2121
finally: finally,

bundle/deploy/state.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ func (f Filelist) ToSlice(root vfs.Path) []fileset.File {
134134
return files
135135
}
136136

137-
func isLocalStateStale(local io.Reader, remote io.Reader) bool {
137+
func isLocalStateStale(local, remote io.Reader) bool {
138138
localState, err := loadState(local)
139139
if err != nil {
140140
return true

bundle/deploy/terraform/init.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ func inheritEnvVars(ctx context.Context, environ map[string]string) error {
145145
// This function is used for env vars set by the Databricks VSCode extension. The variables are intended to be used by the CLI
146146
// bundled with the Databricks VSCode extension, but users can use different CLI versions in the VSCode terminals, in which case we want to ignore
147147
// the variables if that CLI uses different versions of the dependencies.
148-
func getEnvVarWithMatchingVersion(ctx context.Context, envVarName string, versionVarName string, currentVersion string) (string, error) {
148+
func getEnvVarWithMatchingVersion(ctx context.Context, envVarName, versionVarName, currentVersion string) (string, error) {
149149
envValue := env.Get(ctx, envVarName)
150150
versionValue := env.Get(ctx, versionVarName)
151151

bundle/deploy/terraform/init_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ func TestFindExecPathFromEnvironmentWithCorrectVersionAndBinary(t *testing.T) {
400400
require.Equal(t, tmpBinPath, b.Config.Bundle.Terraform.ExecPath)
401401
}
402402

403-
func createTempFile(t *testing.T, dest string, name string, executable bool) string {
403+
func createTempFile(t *testing.T, dest, name string, executable bool) string {
404404
binPath := filepath.Join(dest, name)
405405
f, err := os.Create(binPath)
406406
require.NoError(t, err)

0 commit comments

Comments
 (0)