Merge pull request #99288 from supriya-premkumar/ineffassign

Adds ineffassign to GO linter script.
This commit is contained in:
Kubernetes Prow Robot 2021-03-03 14:40:46 -08:00 committed by GitHub
commit 7b0ad65d4d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 13 additions and 16 deletions

View File

@ -49,4 +49,5 @@ golangci-lint run \
--disable-all \
-E deadcode \
-E unused \
-E varcheck
-E varcheck \
-E ineffassign

View File

@ -362,6 +362,7 @@ func Convert_autoscaling_HorizontalPodAutoscaler_To_v1_HorizontalPodAutoscaler(i
}
// copy before mutating
if !copiedAnnotations {
//nolint:ineffassign
copiedAnnotations = true
out.Annotations = autoscaling.DeepCopyStringMap(out.Annotations)
}

View File

@ -299,6 +299,7 @@ func Convert_autoscaling_HorizontalPodAutoscaler_To_v2beta1_HorizontalPodAutosca
}
// copy before mutating
if !copiedAnnotations {
//nolint:ineffassign
copiedAnnotations = true
out.Annotations = autoscaling.DeepCopyStringMap(out.Annotations)
}

View File

@ -1125,7 +1125,11 @@ func TestDeleteControllerAndExpectations(t *testing.T) {
manager.deleteRS(rs)
manager.syncReplicaSet(GetKey(rs, t))
if _, exists, err = manager.expectations.GetExpectations(rsKey); exists {
_, exists, err = manager.expectations.GetExpectations(rsKey)
if err != nil {
t.Errorf("Failed to get controllee expectations: %v", err)
}
if exists {
t.Errorf("Found expectations, expected none since the ReplicaSet has been deleted.")
}

View File

@ -70,8 +70,8 @@ func NewGenericREST(optsGetter generic.RESTOptionsGetter, serviceCIDR net.IPNet,
ipv4 := api.IPv4Protocol
ipv6 := api.IPv6Protocol
var primaryIPFamily *api.IPFamily = nil
var secondaryFamily *api.IPFamily = nil
var primaryIPFamily *api.IPFamily
var secondaryFamily *api.IPFamily
if netutil.IsIPv6CIDR(&serviceCIDR) {
primaryIPFamily = &ipv6
if hasSecondary {

View File

@ -192,7 +192,7 @@ func deleteTaints(taintsToRemove []v1.Taint, newTaints *[]v1.Taint) ([]error, bo
allErrs := []error{}
var removed bool
for _, taintToRemove := range taintsToRemove {
removed = false
removed = false // nolint:ineffassign
if len(taintToRemove.Effect) > 0 {
*newTaints, removed = DeleteTaint(*newTaints, &taintToRemove)
} else {

View File

@ -102,7 +102,6 @@ func (m *azureDiskMounter) SetUpAt(dir string, mounterArgs volume.MounterArgs) e
klog.Errorf("azureDisk - Unmount directory %s failed with %v", dir, err)
return err
}
mountPoint = true
}
if runtime.GOOS != "windows" {

View File

@ -321,15 +321,12 @@ func dialHandler(w http.ResponseWriter, r *http.Request) {
var dialer func(string, net.Addr) (string, error)
switch strings.ToLower(protocol) {
case "", "http":
protocol = "http"
dialer = dialHTTP
addr, err = net.ResolveTCPAddr("tcp", hostPort)
case "udp":
protocol = "udp"
dialer = dialUDP
addr, err = net.ResolveUDPAddr("udp", hostPort)
case "sctp":
protocol = "sctp"
dialer = dialSCTP
addr, err = sctp.ResolveSCTPAddr("sctp", hostPort)
default:

View File

@ -1299,11 +1299,6 @@ func TestAPICRDProtobuf(t *testing.T) {
t.Fatal(err)
}
rv, _ := strconv.Atoi(obj.GetResourceVersion())
if rv < 1 {
rv = 1
}
w, err := client.Get().
Resource(resource).NamespaceIfScoped(obj.GetNamespace(), len(obj.GetNamespace()) > 0).Name(obj.GetName()).SubResource(tc.subresource).
SetHeader("Accept", tc.accept).

View File

@ -224,12 +224,11 @@ func TestDeploymentSelectorImmutability(t *testing.T) {
}
// test to ensure apps/v1 selector is immutable
newSelectorLabels := map[string]string{"name_apps_v1beta1": "test_apps_v1beta1"}
deploymentAppsV1, err := c.AppsV1().Deployments(ns.Name).Get(context.TODO(), name, metav1.GetOptions{})
if err != nil {
t.Fatalf("failed to get apps/v1 deployment %s: %v", name, err)
}
newSelectorLabels = map[string]string{"name_apps_v1": "test_apps_v1"}
newSelectorLabels := map[string]string{"name_apps_v1": "test_apps_v1"}
deploymentAppsV1.Spec.Selector.MatchLabels = newSelectorLabels
deploymentAppsV1.Spec.Template.Labels = newSelectorLabels
_, err = c.AppsV1().Deployments(ns.Name).Update(context.TODO(), deploymentAppsV1, metav1.UpdateOptions{})