Skip to content

Commit 90121a6

Browse files
authored
Drop testifylint empty/len/equal-values exceptions (#5329)
Removes three `testifylint.disable` entries from `.golangci.yaml`: - `empty` — flagged ~171 sites of `assert.Equal(t, "", x)` / `assert.Len(t, x, 0)` that should be `assert.Empty`. - `len` — flagged ~11 sites of `assert.Equal(t, N, len(x))` that should be `assert.Len`. - `equal-values` — flagged 7 sites of `assert.EqualValues` where types already match. All 189 sites were fixed mechanically by `golangci-lint --fix`; no hand edits, and `./task test` passes. The remaining two disables (`require-error`, `encoded-compare`) are untouched.
1 parent ff8ab80 commit 90121a6

53 files changed

Lines changed: 189 additions & 192 deletions

Some content is hidden

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

.golangci.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,6 @@ linters:
156156
enable-all: true
157157
disable:
158158
- require-error # good check, but we have too many assert.(No)?Errorf? so excluding for now
159-
- empty
160-
- len
161-
- equal-values
162159
- encoded-compare # Always replaces Equal() with JSONEq, but sometimes exact string match is wanted for JSON
163160
exhaustive:
164161
default-signifies-exhaustive: true

bundle/config/mutator/python/python_mutator_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ workspace: { current_user: { userName: test }}`)
158158
assert.Equal(t, int64(2), b.Metrics.PythonAddedResourcesCount)
159159
assert.Equal(t, int64(0), b.Metrics.PythonUpdatedResourcesCount)
160160

161-
assert.Equal(t, 1, len(diags))
161+
assert.Len(t, diags, 1)
162162
assert.Equal(t, "job doesn't have any tasks", diags[0].Summary)
163163
assert.Equal(t, []dyn.Location{
164164
{

bundle/config/mutator/resourcemutator/capture_uc_dependencies_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ func TestCaptureUCDependenciesQualityMonitorEdgeCases(t *testing.T) {
220220

221221
assert.Equal(t, "${resources.catalogs.my_catalog.name}.other", b.Config.Resources.QualityMonitors["catalog_only"].OutputSchemaName)
222222
assert.Equal(t, "other.other", b.Config.Resources.QualityMonitors["no_match"].OutputSchemaName)
223-
assert.Equal(t, "", b.Config.Resources.QualityMonitors["empty"].OutputSchemaName)
223+
assert.Empty(t, b.Config.Resources.QualityMonitors["empty"].OutputSchemaName)
224224
assert.Equal(t, "nodot", b.Config.Resources.QualityMonitors["no_dot"].OutputSchemaName)
225225
assert.Nil(t, b.Config.Resources.QualityMonitors["nil_monitor"])
226226
}

bundle/config/mutator/resourcemutator/fix_permissions_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func TestGetMaxLevel(t *testing.T) {
2323
assert.Equal(t, "CAN_MANAGE", resources.GetMaxLevel("CAN_MANAGE", "CAN_MANAGE"))
2424
assert.Equal(t, "CAN_READ", resources.GetMaxLevel("CAN_READ", ""))
2525
assert.Equal(t, "CAN_READ", resources.GetMaxLevel("", "CAN_READ"))
26-
assert.Equal(t, "", resources.GetMaxLevel("", ""))
26+
assert.Empty(t, resources.GetMaxLevel("", ""))
2727

2828
assert.Equal(t, "UNKNOWN_B", resources.GetMaxLevel("UNKNOWN_A", "UNKNOWN_B"))
2929
assert.Equal(t, "UNKNOWN_B", resources.GetMaxLevel("UNKNOWN_B", "UNKNOWN_A"))

bundle/config/mutator/resourcemutator/secret_scope_fixups_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,9 @@ func TestAddManageForCurrentUser(t *testing.T) {
245245
assert.ElementsMatch(t, tt.expectedPerms, scope.Permissions)
246246

247247
if tt.shouldAddNewPerm {
248-
assert.Equal(t, initialCount+1, len(scope.Permissions))
248+
assert.Len(t, scope.Permissions, initialCount+1)
249249
} else {
250-
assert.Equal(t, initialCount, len(scope.Permissions))
250+
assert.Len(t, scope.Permissions, initialCount)
251251
}
252252
})
253253
}

bundle/deploy/terraform/init_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ func TestInheritOIDCTokenEnv(t *testing.T) {
279279
err := inheritEnvVars(ctx, env)
280280
require.NoError(t, err)
281281
assert.Equal(t, "foobar", env["DATABRICKS_OIDC_TOKEN"])
282-
assert.Equal(t, "", env["DATABRICKS_OIDC_TOKEN_ENV"])
282+
assert.Empty(t, env["DATABRICKS_OIDC_TOKEN_ENV"])
283283
}
284284

285285
func TestInheritAzureDevOpsSystemVariablesIndividual(t *testing.T) {

bundle/deploy/terraform/tfdyn/convert_secret_scope_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func TestConvertSecretScopeNoPermissions(t *testing.T) {
9494
require.NoError(t, err)
9595

9696
// No ACLs should be created
97-
assert.Len(t, out.SecretAcl, 0)
97+
assert.Empty(t, out.SecretAcl)
9898

9999
// But the scope should still be created
100100
assert.Contains(t, out.SecretScope, "no_permissions_scope")

bundle/direct/dstate/state_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,6 @@ func TestDeleteState(t *testing.T) {
7171
var db3 DeploymentState
7272
require.NoError(t, db3.Open(t.Context(), path, WithRecovery(false), WithWrite(false)))
7373
assert.Equal(t, 2, db3.Data.Serial)
74-
assert.Equal(t, "", db3.GetResourceID("jobs.my_job"))
74+
assert.Empty(t, db3.GetResourceID("jobs.my_job"))
7575
mustFinalize(t, &db3)
7676
}

bundle/env/env_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func TestGetWithRealEnvSingleVariable(t *testing.T) {
1919
// Not set.
2020
v, ok = get(t.Context(), []string{"v2"})
2121
require.False(t, ok)
22-
assert.Equal(t, "", v)
22+
assert.Empty(t, v)
2323
}
2424

2525
func TestGetWithRealEnvMultipleVariables(t *testing.T) {
@@ -39,5 +39,5 @@ func TestGetWithRealEnvMultipleVariables(t *testing.T) {
3939
// Not set.
4040
v, ok := get(t.Context(), []string{"v2", "v3", "v4"})
4141
require.False(t, ok)
42-
assert.Equal(t, "", v)
42+
assert.Empty(t, v)
4343
}

bundle/env/root_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@ func TestRoot(t *testing.T) {
3737
t.Run("not set", func(t *testing.T) {
3838
root, ok := Root(ctx)
3939
assert.False(t, ok)
40-
assert.Equal(t, "", root)
40+
assert.Empty(t, root)
4141
})
4242
}

0 commit comments

Comments
 (0)