Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,19 @@ linters:
- forbidigo
- depguard
- usestdlibvars
- nilerr
- fatcontext
- nosprintfhostport
- recvcheck
- usetesting
- dupword
- misspell
- nilnesserr
- durationcheck
- exptostd
- gocheckcompilerdirectives
- asciicheck
- reassign
settings:
depguard:
rules:
Expand Down
2 changes: 1 addition & 1 deletion acceptance/acceptance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ func runTest(t *testing.T,
if KeepTmp {
tempDirBase := filepath.Join(os.TempDir(), "acceptance")
_ = os.Mkdir(tempDirBase, 0o755)
tmpDir, err = os.MkdirTemp(tempDirBase, "")
tmpDir, err = os.MkdirTemp(tempDirBase, "") //nolint:usetesting // KeepTmp: dir must persist after test for debugging
require.NoError(t, err)
t.Logf("Created directory: %s", tmpDir)
} else if WorkspaceTmpDir {
Expand Down
8 changes: 4 additions & 4 deletions acceptance/internal/cmd_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ func chdir(t *testing.T, cwd string) func() {
require.NotEmpty(t, cwd)
prevDir, err := os.Getwd()
require.NoError(t, err)
err = os.Chdir(cwd)
err = os.Chdir(cwd) //nolint:usetesting // must restore before function ends, not at test cleanup
require.NoError(t, err)
return func() {
_ = os.Chdir(prevDir)
_ = os.Chdir(prevDir) //nolint:usetesting // see above
}
}

Expand All @@ -62,15 +62,15 @@ func configureEnv(t *testing.T, env map[string]string) func() {
// Set current process's environment to match the input.
os.Clearenv()
for key, val := range env {
os.Setenv(key, val)
os.Setenv(key, val) //nolint:usetesting // custom restore needed; t.Setenv can't clearenv+restore all
}

// Function callback to use with defer to restore original environment.
return func() {
os.Clearenv()
for _, kv := range oldEnv {
kvs := strings.SplitN(kv, "=", 2)
os.Setenv(kvs[0], kvs[1])
os.Setenv(kvs[0], kvs[1]) //nolint:usetesting // see above
}
}
}
4 changes: 2 additions & 2 deletions acceptance/internal/prepare_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func StartDefaultServer(t *testing.T, logRequests bool) {
// This approach ensures test reliability across platforms.
//
// See debugging journey in https://github.com/databricks/cli/pull/3575.
homeDir, err := os.MkdirTemp("", "acceptance-home-dir")
homeDir, err := os.MkdirTemp("", "acceptance-home-dir") //nolint:usetesting // t.TempDir() fails on Windows; see PR #3575
require.NoError(t, err)
t.Cleanup(func() {
err := os.RemoveAll(homeDir)
Expand Down Expand Up @@ -123,7 +123,7 @@ func PrepareServerAndClient(t *testing.T, config TestConfig, logRequests bool, o
}

// For the purposes of replacements, use testUser for local runs.
// Note, users might have overriden /api/2.0/preview/scim/v2/Me but that should not affect the replacement:
// Note, users might have overridden /api/2.0/preview/scim/v2/Me but that should not affect the replacement:
return cfg, testUser
}

Expand Down
2 changes: 1 addition & 1 deletion bundle/apps/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (v *validate) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnostics
diags = append(diags, diag.Diagnostic{
Severity: diag.Error,
Summary: "Duplicate app source code path",
Detail: fmt.Sprintf("app resource '%s' has the same source code path as app resource '%s', this will lead to the app configuration being overriden by each other", key, usedSourceCodePaths[app.SourceCodePath]),
Detail: fmt.Sprintf("app resource '%s' has the same source code path as app resource '%s', this will lead to the app configuration being overridden by each other", key, usedSourceCodePaths[app.SourceCodePath]),
Locations: b.Config.GetLocations(fmt.Sprintf("resources.apps.%s.source_code_path", key)),
})
}
Expand Down
2 changes: 1 addition & 1 deletion bundle/artifacts/prepare.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func InsertPythonArtifact(ctx context.Context, b *bundle.Bundle) error {
_, err := os.Stat(setupPy)
if err != nil {
log.Infof(ctx, "No Python wheel project found at bundle root folder")
return nil
return nil //nolint:nilerr // setup.py not found means no wheel project to detect
}

log.Infof(ctx, "Found Python wheel project at %s", b.BundleRootPath)
Expand Down
2 changes: 1 addition & 1 deletion bundle/config/mutator/resourcemutator/apply_target_mode.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func (m *applyTargetMode) Name() string {
}

// Mark all resources as being for 'development' purposes, i.e.
// changing their their name, adding tags, and (in the future)
// changing their name, adding tags, and (in the future)
// marking them as 'hidden' in the UI.
func transformDevelopmentMode(ctx context.Context, b *bundle.Bundle) {
if !b.Config.Bundle.Deployment.Lock.IsExplicitlyEnabled() {
Expand Down
2 changes: 1 addition & 1 deletion bundle/config/mutator/rewrite_workspace_prefix.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

type rewriteWorkspacePrefix struct{}

// RewriteWorkspacePrefix finds any strings in bundle configration that have
// RewriteWorkspacePrefix finds any strings in bundle configuration that have
// workspace prefix plus workspace path variable used and removes workspace prefix from it.
func RewriteWorkspacePrefix() bundle.Mutator {
return &rewriteWorkspacePrefix{}
Expand Down
2 changes: 1 addition & 1 deletion bundle/config/mutator/set_variables_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func TestSetVariablesMutator(t *testing.T) {
Default: defaultValForA,
},
"b": {
Description: "resolved from environment vairables",
Description: "resolved from environment variables",
Default: defaultValForB,
},
"c": {
Expand Down
4 changes: 2 additions & 2 deletions bundle/config/resources/secret_scope.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type SecretScopePermission struct {
GroupName string `json:"group_name,omitempty"`
}

type SecretScope struct {
type SecretScope struct { //nolint:recvcheck // pointer receiver needed for UnmarshalJSON, value for other methods
BaseResource

// A unique name to identify the secret scope.
Expand Down Expand Up @@ -67,7 +67,7 @@ func (s SecretScope) Exists(ctx context.Context, w *databricks.WorkspaceClient,
// The indirect methods are not semantically ideal for simple existence checks, so we use the list API here
scopes, err := w.Secrets.ListScopesAll(ctx)
if err != nil {
return false, nil
return false, nil //nolint:nilerr // treat API errors as "scope not found"
}

for _, scope := range scopes {
Expand Down
6 changes: 3 additions & 3 deletions bundle/config/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type Script struct {
Content string `json:"content"`
}

type Root struct {
type Root struct { //nolint:recvcheck // value receivers for read-only accessors, pointer for mutators
value dyn.Value
depth int

Expand Down Expand Up @@ -443,7 +443,7 @@ var allowedVariableDefinitions = []([]string){
{"lookup"},
}

// isFullVariableOverrideDef checks if the given value is a full syntax varaible override.
// isFullVariableOverrideDef checks if the given value is a full syntax variable override.
// A full syntax variable override is a map with either 1 of 2 keys.
// If it's 2 keys, the keys should be "default" and "type".
// If it's 1 key, the key should be one of the following keys: "default", "lookup".
Expand Down Expand Up @@ -514,7 +514,7 @@ func rewriteShorthands(v dyn.Value) (dyn.Value, error) {

// Check if the original definition of variable has a type field.
// If it has a type field, it means the shorthand is a value of a complex type.
// Type might not be found if the variable overriden in a separate file
// Type might not be found if the variable overridden in a separate file
// and configuration is not merged yet.
typeV, err := dyn.GetByPath(v, p.Append(dyn.Key("type")))
if err == nil && typeV.MustString() == "complex" {
Expand Down
2 changes: 1 addition & 1 deletion bundle/config/variable/variable.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ type Variable struct {
}

// True if the variable has been assigned a default value. Variables without a
// a default value are by defination required
// default value are by definition required
func (v *Variable) HasDefault() bool {
return v.Default != nil
}
Expand Down
2 changes: 1 addition & 1 deletion bundle/configsync/patch.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ func strPathToJSONPointer(pathStr string) (string, error) {
func clearAddedFlowStyle(content []byte, fieldChanges []FieldChange) ([]byte, error) {
var doc yaml.Node
if err := yaml.Unmarshal(content, &doc); err != nil {
return content, nil
return content, nil //nolint:nilerr // return original content if YAML parsing fails
}
for _, fc := range fieldChanges {
for _, candidate := range fc.FieldCandidates {
Expand Down
2 changes: 1 addition & 1 deletion bundle/direct/bundle_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ func isEmpty(rv reflect.Value) bool {
return rv.Len() == 0
}

// Certain structs come up set even if fully empty and and not set by client, e.g. email_notifications and webhook_notifications
// Certain structs come up set even if fully empty and not set by client, e.g. email_notifications and webhook_notifications
if isEmptyStruct(rv) {
return true
}
Expand Down
4 changes: 2 additions & 2 deletions bundle/libraries/local_path.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func IsLocalPath(p string) bool {
// IsLibraryLocal returns true if the specified library or environment dependency
// should be interpreted as a local path.
// We use this to check if the dependency in environment spec is local or that library is local.
// We can't use IsLocalPath beacuse environment dependencies can be
// We can't use IsLocalPath because environment dependencies can be
// a pypi package name which can be misinterpreted as a local path by IsLocalPath.
func IsLibraryLocal(dep string) bool {
if dep == "" {
Expand Down Expand Up @@ -96,7 +96,7 @@ func IsLocalPathInPipFlag(dep string) (string, string, bool) {
}

func containsPipFlag(input string) bool {
// Trailing space means the the flag takes an argument or there's multiple arguments in input
// Trailing space means the flag takes an argument or there's multiple arguments in input
// Alternatively it could be a flag with no argument and no space after it
// For example: -r myfile.txt or --index-url http://myindexurl.com or -i
re := regexp.MustCompile(`(^|\s+)--?[a-zA-Z0-9-]+(([\s|=]+)|$)`)
Expand Down
2 changes: 1 addition & 1 deletion bundle/mutator_read_only.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func ApplyParallel(ctx context.Context, b *Bundle, mutators ...ReadOnlyMutator)
contexts := make([]context.Context, len(mutators))

for ind, m := range mutators {
contexts[ind] = log.NewContext(ctx, log.GetLogger(ctx).With("mutator", m.Name()))
contexts[ind] = log.NewContext(ctx, log.GetLogger(ctx).With("mutator", m.Name())) //nolint:fatcontext // independent contexts from same parent, not nested
// log right away to have deterministic order of log messages
log.Debug(contexts[ind], "ApplyParallel")
}
Expand Down
2 changes: 1 addition & 1 deletion bundle/run/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ func (a *appRunner) resolvedConfig() (*resources.AppConfig, error) {
configPath := dyn.MustPathFromString("resources." + a.Key() + ".config")
configV, err := dyn.GetByPath(root, configPath)
if err != nil || !configV.IsValid() {
return a.app.Config, nil
return a.app.Config, nil //nolint:nilerr // missing config path means use default config
}

resourcesPrefix := dyn.MustPathFromString("resources")
Expand Down
2 changes: 1 addition & 1 deletion bundle/run/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ func TestAppDeployWithDeploymentInProgress(t *testing.T) {

appApi.EXPECT().WaitGetDeploymentAppSucceeded(mock.Anything, "my_app", "active_deployment_id", mock.Anything, mock.Anything).Return(nil, nil)

// Second one should succeeed
// Second one should succeed
appApi.EXPECT().Deploy(mock.Anything, apps.CreateAppDeploymentRequest{
AppName: "my_app",
AppDeployment: apps.AppDeployment{
Expand Down
2 changes: 1 addition & 1 deletion bundle/run/output/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (out *JobOutput) String() (string, error) {
}
taskString, err := v.Output.String()
if err != nil {
return "", nil
return "", nil //nolint:nilerr // skip tasks with unparseable output
}
result.WriteString("=======\n")
result.WriteString(fmt.Sprintf("Task %s:\n", v.TaskKey))
Expand Down
6 changes: 3 additions & 3 deletions bundle/run/progress/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ import (
"github.com/databricks/databricks-sdk-go/service/pipelines"
)

// The dlt backend computes events for pipeline runs which are accessable through
// The dlt backend computes events for pipeline runs which are accessible through
// the 2.0/pipelines/{pipeline_id}/events API
//
// There are 4 levels for these events: ("ERROR", "WARN", "INFO", "METRICS")
//
// Here's short introduction to a few important events we display on the console:
//
// 1. `update_progress`: A state transition occured for the entire pipeline update
// 2. `flow_progress`: A state transition occured for a single flow in the pipeine
// 1. `update_progress`: A state transition occurred for the entire pipeline update
// 2. `flow_progress`: A state transition occurred for a single flow in the pipeine
type ProgressEvent pipelines.PipelineEvent

func (event *ProgressEvent) String() string {
Expand Down
3 changes: 1 addition & 2 deletions bundle/statemgmt/check_running_resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,8 @@ func checkAnyResourceRunning(ctx context.Context, w *databricks.WorkspaceClient,
if resourceType == "pipelines" {
errs.Go(func() error {
isRunning, err := IsPipelineRunning(errCtx, w, id)
// If there's an error retrieving the pipeline, we assume it's not running
if err != nil {
return nil
return nil //nolint:nilerr // assume not running if pipeline check fails
}
if isRunning {
return &ErrResourceIsRunning{resourceType: "pipeline", resourceId: id}
Expand Down
2 changes: 1 addition & 1 deletion bundle/trampoline/python_wheel.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func (t *pythonTrampoline) GetTemplateData(task *jobs.Task) (map[string]any, err

func (t *pythonTrampoline) generateParameters(task *jobs.PythonWheelTask) (string, error) {
if task.Parameters != nil && task.NamedParameters != nil {
return "", errors.New("not allowed to pass both paramaters and named_parameters")
return "", errors.New("not allowed to pass both parameters and named_parameters")
}
params := append([]string{task.PackageName}, task.Parameters...)
for k, v := range task.NamedParameters {
Expand Down
2 changes: 1 addition & 1 deletion bundle/trampoline/python_wheel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func TestGenerateBoth(t *testing.T) {
task := &jobs.PythonWheelTask{NamedParameters: map[string]string{"a": "1"}, Parameters: []string{"b"}}
_, err := trampoline.generateParameters(task)
require.Error(t, err)
require.ErrorContains(t, err, "not allowed to pass both paramaters and named_parameters")
require.ErrorContains(t, err, "not allowed to pass both parameters and named_parameters")
}

func TestTransformFiltersWheelTasksOnly(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion cmd/apps/run_local.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ func newRunLocal() *cobra.Command {

This command starts an app locally.`

cmd.Flags().IntVar(&port, "port", 8001, "Port on which to run the app app proxy")
cmd.Flags().IntVar(&port, "port", 8001, "Port on which to run the app proxy")
cmd.Flags().IntVar(&appPort, "app-port", runlocal.DEFAULT_PORT, "Port on which to run the app")
cmd.Flags().BoolVar(&debug, "debug", false, "Enable debug mode")
cmd.Flags().BoolVar(&prepareEnvironment, "prepare-environment", false, "Prepares the environment for running the app. Requires 'uv' to be installed.")
Expand Down
6 changes: 3 additions & 3 deletions cmd/auth/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func getAuthStatus(cmd *cobra.Command, args []string, showSensitive bool, fn try
cfg, isAccount, err := fn(cmd, args)
ctx := cmd.Context()
if err != nil {
return &authStatus{
return &authStatus{ //nolint:nilerr // error is returned in the authStatus struct
Status: "error",
Error: err,
Details: getAuthDetails(cmd, cfg, showSensitive),
Expand All @@ -93,7 +93,7 @@ func getAuthStatus(cmd *cobra.Command, args []string, showSensitive bool, fn try
// Doing a simple API call to check if the auth is valid
_, err := a.Workspaces.List(ctx)
if err != nil {
return &authStatus{
return &authStatus{ //nolint:nilerr // error is returned in the authStatus struct
Status: "error",
Error: err,
Details: getAuthDetails(cmd, cfg, showSensitive),
Expand All @@ -113,7 +113,7 @@ func getAuthStatus(cmd *cobra.Command, args []string, showSensitive bool, fn try
w := cmdctx.WorkspaceClient(ctx)
me, err := w.CurrentUser.Me(ctx)
if err != nil {
return &authStatus{
return &authStatus{ //nolint:nilerr // error is returned in the authStatus struct
Status: "error",
Error: err,
Details: getAuthDetails(cmd, cfg, showSensitive),
Expand Down
2 changes: 1 addition & 1 deletion cmd/root/user_agent_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/spf13/cobra"
)

// commandSeparator joins command names in a command hierachy.
// commandSeparator joins command names in a command hierarchy.
// We enforce no command name contains this character.
// See unit test [main.TestCommandsDontUseUnderscoreInName].
const commandSeparator = "_"
Expand Down
2 changes: 1 addition & 1 deletion integration/libs/locker/locker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func TestLock(t *testing.T) {
assert.ErrorContains(t, lockerErrs[i], "Use --force-lock to override")
}
}
assert.Equal(t, 1, countActive, "Exactly one locker should successfull acquire the lock")
assert.Equal(t, 1, countActive, "Exactly one locker should successfully acquire the lock")

// test remote lock matches active lock
remoteLocker, err := locker.GetActiveLockState(ctx)
Expand Down
2 changes: 1 addition & 1 deletion internal/testcli/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (r *Runner) SendText(text string) {
}
_, err := r.stdinW.Write([]byte(text + "\n"))
if err != nil {
panic("Failed to to write to t.stdinW")
panic("Failed to write to t.stdinW")
}
}

Expand Down
9 changes: 2 additions & 7 deletions libs/apps/initializer/initializer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,7 @@ func TestGetProjectInitializer(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
// Create temp directory
tmpDir, err := os.MkdirTemp("", "initializer-test-*")
require.NoError(t, err)
defer os.RemoveAll(tmpDir)
tmpDir := t.TempDir()

// Create test files
for name, content := range tt.files {
Expand Down Expand Up @@ -140,9 +137,7 @@ func TestDetectPythonCommand(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
tmpDir, err := os.MkdirTemp("", "python-cmd-test-*")
require.NoError(t, err)
defer os.RemoveAll(tmpDir)
tmpDir := t.TempDir()

for name, content := range tt.files {
err := os.WriteFile(filepath.Join(tmpDir, name), []byte(content), 0o644)
Expand Down
Loading
Loading