switch
with single case can be rewritten as if
or if-else
CRT-A001451
52func describeRedisPlan(ctx context.Context, p plan.RedisPlan, org *fly.Organization) (string, error) {
53
54 switch provider := p.Provider().(type) {55 case *plan.UpstashRedisPlan:
56 return describeUpstashRedisPlan(ctx, provider, org)
57 }
92 }
93
94 toks, err := macaroon.Parse(token)
95 switch { 96 case errors.Is(err, macaroon.ErrUnrecognizedToken):
97 return nil, fmt.Errorf("unable to parse token: %w", err)
98 }
7
8func containsCommonSecretSubstring(s string) bool {
9 // Allowlist for strings which contain a substring but are not secrets.
10 switch s {11 case "AWS_ACCESS_KEY_ID":
12 return false
13 }
switch
statements with a single case
can be rewritten as if-else
or if
.
Single case
switch
can be replaced by if-else
as it appears to be more
readable. This does not apply to type switch
.
switch ok {
case true:
// body
}
if ok {
// body
}