From 7d105143fc991fe255b4b0ea812f71411e796b65 Mon Sep 17 00:00:00 2001 From: Rakshith R Date: Sun, 4 Apr 2021 12:18:03 +0530 Subject: [PATCH] cleanup: refactor deeply nested if statement in cephcsi.go Refactored deeply nested if statement in cephcsi.go to reduce cognitive complexity. Signed-off-by: Rakshith R --- cmd/cephcsi.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/cmd/cephcsi.go b/cmd/cephcsi.go index c3983456c..78342e714 100644 --- a/cmd/cephcsi.go +++ b/cmd/cephcsi.go @@ -148,14 +148,13 @@ func main() { } else { util.DefaultLog("Initial PID limit is set to %d", currentLimit) err = util.SetPIDLimit(conf.PidLimit) - if err != nil { + switch { + case err != nil: klog.Errorf("Failed to set new PID limit to %d: %v", conf.PidLimit, err) - } else { - s := "" - if conf.PidLimit == -1 { - s = " (max)" - } - util.DefaultLog("Reconfigured PID limit to %d%s", conf.PidLimit, s) + case conf.PidLimit == -1: + util.DefaultLog("Reconfigured PID limit to %d (max)", conf.PidLimit) + default: + util.DefaultLog("Reconfigured PID limit to %d", conf.PidLimit) } } }