Cleanup bool checks (#14102)

* clean up == true cases

* cleanup == false where it didn't seem to hurt readability
This commit is contained in:
swayne275 2022-02-18 07:35:53 -07:00 committed by GitHub
parent 2a937fe717
commit 24d512f0d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 18 additions and 19 deletions

View File

@ -193,7 +193,7 @@ func testAccStepConfig(t *testing.T, d map[string]interface{}, expectError bool)
func testAccStepRole(t *testing.T, wildCard bool) logicaltest.TestStep {
pathData := make(map[string]interface{})
if wildCard == true {
if wildCard {
pathData = map[string]interface{}{
"sql": testRoleWildCard,
}

View File

@ -140,7 +140,7 @@ func (b *backend) secretCredsRevoke(ctx context.Context, req *logical.Request, d
return nil, err
}
if exists == false {
if !exists {
return resp, nil
}

View File

@ -608,7 +608,7 @@ func testAccStepReadPolicyWithVersions(t *testing.T, name string, expectNone, de
if d.MinEncryptionVersion != minEncryptionVersion {
return fmt.Errorf("bad: %#v", d)
}
if d.DeletionAllowed == true {
if d.DeletionAllowed {
return fmt.Errorf("bad: %#v", d)
}
if d.Derived != derived {

View File

@ -147,7 +147,7 @@ func testAccStepwiseReadPolicyWithVersions(t *testing.T, name string, expectNone
if d.MinEncryptionVersion != minEncryptionVersion {
return fmt.Errorf("minimum encryption version mismatch, expected (%#v), found (%#v)", minEncryptionVersion, d.MinDecryptionVersion)
}
if d.DeletionAllowed == true {
if d.DeletionAllowed {
return fmt.Errorf("expected DeletionAllowed to be false, but got true")
}
if d.Derived != derived {

View File

@ -164,7 +164,7 @@ func Handler(props *vault.HandlerProperties) http.Handler {
}
mux.Handle("/v1/sys/", handleRequestForwarding(core, handleLogical(core)))
mux.Handle("/v1/", handleRequestForwarding(core, handleLogical(core)))
if core.UIEnabled() == true {
if core.UIEnabled() {
if uiBuiltIn {
mux.Handle("/ui/", http.StripPrefix("/ui/", gziphandler.GzipHandler(handleUIHeaders(core, handleUI(http.FileServer(&UIAssetWrapper{FileSystem: assetFS()}))))))
mux.Handle("/robots.txt", gziphandler.GzipHandler(handleUIHeaders(core, handleUI(http.FileServer(&UIAssetWrapper{FileSystem: assetFS()})))))

View File

@ -49,8 +49,8 @@ func TestSysMountConfig(t *testing.T) {
expectedMaxTTL, mountConfig.MaxLeaseTTL)
}
if mountConfig.ForceNoCache == true {
t.Fatalf("did not expect force cache")
if mountConfig.ForceNoCache {
t.Fatal("did not expect force cache")
}
}

View File

@ -257,7 +257,7 @@ func isUserAdmin(cli influx.Client, user string) (bool, error) {
for _, res := range response.Results {
for _, serie := range res.Series {
for _, val := range serie.Values {
if val[0].(string) == user && val[1].(bool) == true {
if val[0].(string) == user && val[1].(bool) {
return true, nil
}
}

View File

@ -318,7 +318,7 @@ func TestConsul_newConsulServiceRegistration(t *testing.T) {
}
c.disableRegistration = true
if c.disableRegistration == false {
if !c.disableRegistration {
addr := os.Getenv("CONSUL_HTTP_ADDR")
if addr == "" {
continue

View File

@ -1716,7 +1716,7 @@ func (a *ActivityLog) precomputedQueryWorker(ctx context.Context) error {
walkEntities := func(l *activity.EntityActivityLog) {
for _, e := range l.Clients {
createNs(e.NamespaceID)
if e.NonEntity == true {
if e.NonEntity {
byNamespace[e.NamespaceID].NonEntities[e.ClientID] = struct{}{}
} else {
byNamespace[e.NamespaceID].Entities[e.ClientID] = struct{}{}
@ -1994,7 +1994,7 @@ func createClientCountTable(entityMap map[string]uint64, nonEntityMap map[string
func (ct *ClientTracker) addClient(e *activity.EntityRecord) {
if _, ok := ct.activeClients[e.ClientID]; !ok {
ct.activeClients[e.ClientID] = struct{}{}
if e.NonEntity == true {
if e.NonEntity {
ct.nonEntityCountByNamespaceID[e.NamespaceID] += 1
} else {
ct.entityCountByNamespaceID[e.NamespaceID] += 1

View File

@ -398,13 +398,12 @@ func TestActivityLog_SaveTokensToStorageDoesNotUpdateTokenCount(t *testing.T) {
nonEntityTokenFlag := false
entityTokenFlag := false
for _, client := range out.Clients {
if client.NonEntity == true {
if client.NonEntity {
nonEntityTokenFlag = true
if client.ClientID != idNonEntity {
t.Fatalf("expected a client ID of %s, but saved instead %s", idNonEntity, client.ClientID)
}
}
if client.NonEntity == false {
} else {
entityTokenFlag = true
if client.ClientID != idEntity {
t.Fatalf("expected a client ID of %s, but saved instead %s", idEntity, client.ClientID)
@ -1806,7 +1805,7 @@ func TestActivityLog_DeleteWorker(t *testing.T) {
func checkAPIWarnings(t *testing.T, originalEnabled, newEnabled bool, resp *logical.Response) {
t.Helper()
expectWarning := originalEnabled == true && newEnabled == false
expectWarning := originalEnabled && !newEnabled
switch {
case !expectWarning && resp != nil:

View File

@ -474,7 +474,7 @@ func TestEncrypt_Unique(t *testing.T) {
t.Fatal(err)
}
if bytes.Equal(first, second) == true {
if bytes.Equal(first, second) {
t.Fatalf("improper random seeding detected")
}
}

View File

@ -333,13 +333,13 @@ func (c *Core) checkToken(ctx context.Context, req *logical.Request, unauth bool
}
switch {
case checkExists == false:
case !checkExists:
// No existence check, so always treat it as an update operation, which is how it is pre 0.5
req.Operation = logical.UpdateOperation
case resourceExists == true:
case resourceExists:
// It exists, so force an update operation
req.Operation = logical.UpdateOperation
case resourceExists == false:
case !resourceExists:
// It doesn't exist, force a create operation
req.Operation = logical.CreateOperation
default: