cleanup: address ifshort linter issues

This commit addresses ifshort linter issues which
checks if short syntax for if-statements is possible.

updates: #1586

Signed-off-by: Rakshith R <rar@redhat.com>
This commit is contained in:
Rakshith R
2021-05-06 15:19:27 +05:30
committed by mergify[bot]
parent 6618e2012d
commit b891e5585d
9 changed files with 10 additions and 19 deletions

View File

@ -156,8 +156,7 @@ func (cp *ConnPool) Get(monitors, user, keyfile string) (*rados.Conn, error) {
cp.lock.Lock()
defer cp.lock.Unlock()
oldConn := cp.getConn(unique)
if oldConn != nil {
if oldConn := cp.getConn(unique); oldConn != nil {
// there was a race, oldConn already exists
ce.destroy()
return oldConn, nil

View File

@ -62,8 +62,7 @@ func (cp *ConnPool) fakeGet(monitors, user, keyfile string) (*rados.Conn, string
cp.lock.Lock()
defer cp.lock.Unlock()
oldConn := cp.getConn(unique)
if oldConn != nil {
if oldConn := cp.getConn(unique); oldConn != nil {
// there was a race, oldConn already exists
ce.destroy()
return oldConn, unique, nil

View File

@ -64,8 +64,7 @@ func TestJoinErrors(t *testing.T) {
assertErrorIs(x, errFoo, false)
assertErrorIs(x, errBar, true)
s1 := "w{w{w{x}}: w{w{foo: bar}}}"
s2 := w1w2Xw2FooBar.Error()
if s1 != s2 {
if s2 := w1w2Xw2FooBar.Error(); s1 != s2 {
t.Errorf("%s != %s", s1, s2)
}
}

View File

@ -47,9 +47,8 @@ func RoundOffVolSize(size int64) int64 {
// size less than 1MiB will be round off to 1MiB.
func RoundOffBytes(bytes int64) int64 {
var num int64
floatBytes := float64(bytes)
// round off the value if its in decimal
if floatBytes < helpers.GiB {
if floatBytes := float64(bytes); floatBytes < helpers.GiB {
num = int64(math.Ceil(floatBytes / helpers.MiB))
num *= helpers.MiB
} else {
@ -142,8 +141,7 @@ func ValidateDriverName(driverName string) error {
// 'utsname' structs 'release' component.
func GetKernelVersion() (string, error) {
utsname := unix.Utsname{}
err := unix.Uname(&utsname)
if err != nil {
if err := unix.Uname(&utsname); err != nil {
return "", err
}
return strings.TrimRight(string(utsname.Release[:]), "\x00"), nil

View File

@ -188,8 +188,7 @@ func initVaultTokensKMS(args KMSInitializerArgs) (EncryptionKMS, error) {
var err error
config := args.Config
_, ok := config[kmsProviderKey]
if ok {
if _, ok := config[kmsProviderKey]; ok {
// configuration comes from the ConfigMap, needs to be
// converted to vaultTokenConf type
config, err = transformConfig(config)