Simplify if statement for single bool judgment GO-R1004
Anti-pattern
Minor
4 months ago2 years old
IfStmt with single bool judgement could be simplified
1019		failpoint.Inject("concurrentBucketHeartbeat", func() {
1020			time.Sleep(500 * time.Millisecond)
1021		})
1022		if ok := region.UpdateBuckets(buckets, old); ok {1023			return nil
1024		}
1025	}
IfStmt with single bool judgement could be simplified
1877	storeLabel := strconv.FormatUint(storeID, 10)
1878
1879	progress := encodePreparingProgressKey(storeID)
1880	if exist := c.progressManager.RemoveProgress(progress); exist {1881		storesProgressGauge.DeleteLabelValues(storeAddress, storeLabel, preparingAction)
1882		storesSpeedGauge.DeleteLabelValues(storeAddress, storeLabel, preparingAction)
1883		storesETAGauge.DeleteLabelValues(storeAddress, storeLabel, preparingAction)
IfStmt with single bool judgement could be simplified
1883		storesETAGauge.DeleteLabelValues(storeAddress, storeLabel, preparingAction)
1884	}
1885	progress = encodeRemovingProgressKey(storeID)
1886	if exist := c.progressManager.RemoveProgress(progress); exist {1887		storesProgressGauge.DeleteLabelValues(storeAddress, storeLabel, removingAction)
1888		storesSpeedGauge.DeleteLabelValues(storeAddress, storeLabel, removingAction)
1889		storesETAGauge.DeleteLabelValues(storeAddress, storeLabel, removingAction)
IfStmt with single bool judgement could be simplified
240	defer cancel()
241	var options []clientv3.OpOption
242	key := string(req.GetKey())
243	if prevKv := req.GetPrevKv(); prevKv {244		options = append(options, clientv3.WithPrevKV())
245	}
246
IfStmt with single bool judgement could be simplified
208	if lease := clientv3.LeaseID(req.GetLease()); lease != 0 {
209		options = append(options, clientv3.WithLease(lease))
210	}
211	if prevKv := req.GetPrevKv(); prevKv {212		options = append(options, clientv3.WithPrevKV())
213	}
214