should omit comparison to bool constant, can be simplified to size
244 var found bool
245 var sizeInMB int
246 var err error
247 if size == true {248 liveVolume, found, sizeInMB, err = repo.filesystem.LookupVolumeWithSize(handle)
249 if err != nil {
250 logger.Error("failed-to-lookup-volume", err)
Description
Prefer using good name for boolean variable and omit comparison with boolean constant.
If the boolean variable being compared is named correctly (e.g., isUserHere
instead of userIsHere
), this would make the code more readable and avoid
redundancy issues. Also, omit comparison with boolean constant as
if x == true { }
is same as if x { }
but the latter is more idiomatic.
Bad practice
if isUserLoggedIn == true {}
if unnecessaryComparison {}
Recommended
After:
if isUserLoggedIn {}
if isComparisonUnnecessary {}