You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by lb...@apache.org on 2019/10/09 10:35:18 UTC

[camel-k] 02/03: chore: upgrade and tune lint, fix findings

This is an automated email from the ASF dual-hosted git repository.

lburgazzoli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit 8a577b360f5f6eaadd437dea76f16d12c5a3d01f
Author: lburgazzoli <lb...@gmail.com>
AuthorDate: Tue Oct 8 19:23:24 2019 +0200

    chore: upgrade and tune lint, fix findings
---
 .golangci.yml                                      |  5 ++
 .travis.yml                                        |  2 +-
 .../v1alpha1/integrationplatform_types_support.go  |  1 -
 pkg/builder/builder_steps_test.go                  | 55 +++++-----------------
 pkg/cmd/describe_kit.go                            |  1 -
 pkg/cmd/kit_get.go                                 |  1 -
 pkg/controller/integrationplatform/initialize.go   |  1 -
 .../integrationplatform_controller.go              |  1 -
 pkg/controller/integrationplatform/warm.go         |  3 --
 pkg/install/operator.go                            |  1 -
 pkg/trait/gc_test.go                               |  4 --
 pkg/trait/ingress_test.go                          | 11 -----
 pkg/trait/trait_types.go                           |  1 -
 pkg/util/envvar/envvar.go                          |  1 -
 pkg/util/kubernetes/log/annotation_scraper.go      |  1 -
 pkg/util/kubernetes/log/pod_scraper.go             |  2 -
 pkg/util/openshift/register.go                     |  1 -
 pkg/util/test/client.go                            |  1 -
 18 files changed, 17 insertions(+), 76 deletions(-)

diff --git a/.golangci.yml b/.golangci.yml
index a67fb8d..3cfed89 100644
--- a/.golangci.yml
+++ b/.golangci.yml
@@ -7,3 +7,8 @@ linters:
     - dupl
     - gochecknoinits
     - gochecknoglobals
+    - funlen
+    - godox
+    - whitespace
+    - gocognit
+    - wsl
diff --git a/.travis.yml b/.travis.yml
index d59ff53..492f211 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -40,7 +40,7 @@ services:
   - docker
 
 before_script:
-  - curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b . v1.17.1
+  - curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b . v1.20.0
   - ./golangci-lint config path
   - ./golangci-lint --version
 
diff --git a/pkg/apis/camel/v1alpha1/integrationplatform_types_support.go b/pkg/apis/camel/v1alpha1/integrationplatform_types_support.go
index e752347..5dda22e 100644
--- a/pkg/apis/camel/v1alpha1/integrationplatform_types_support.go
+++ b/pkg/apis/camel/v1alpha1/integrationplatform_types_support.go
@@ -91,7 +91,6 @@ func (in *IntegrationPlatformStatus) GetCondition(condType IntegrationPlatformCo
 		if c.Type == condType {
 			return &c
 		}
-
 	}
 	return nil
 }
diff --git a/pkg/builder/builder_steps_test.go b/pkg/builder/builder_steps_test.go
index e7da61a..d21564d 100644
--- a/pkg/builder/builder_steps_test.go
+++ b/pkg/builder/builder_steps_test.go
@@ -99,22 +99,10 @@ func TestGenerateJvmProject(t *testing.T) {
 		t,
 		ctx.Maven.Project.Dependencies,
 		[]maven.Dependency{
-			{
-				GroupID:    "org.apache.camel.k",
-				ArtifactID: "camel-k-runtime-main",
-			},
-			{
-				GroupID:    "org.apache.camel",
-				ArtifactID: "camel-core-engine",
-			},
-			{
-				GroupID:    "org.apache.camel",
-				ArtifactID: "camel-main",
-			},
-			{
-				GroupID:    "org.apache.camel",
-				ArtifactID: "camel-properties",
-			},
+			{GroupID: "org.apache.camel.k", ArtifactID: "camel-k-runtime-main"},
+			{GroupID: "org.apache.camel", ArtifactID: "camel-core-engine"},
+			{GroupID: "org.apache.camel", ArtifactID: "camel-main"},
+			{GroupID: "org.apache.camel", ArtifactID: "camel-properties"},
 		},
 	)
 }
@@ -273,34 +261,13 @@ func TestGenerateGroovyProject(t *testing.T) {
 		t,
 		ctx.Maven.Project.Dependencies,
 		[]maven.Dependency{
-			{
-				GroupID:    "org.apache.camel.k",
-				ArtifactID: "camel-k-runtime-main",
-			},
-			{
-				GroupID:    "org.apache.camel.k",
-				ArtifactID: "camel-k-loader-groovy",
-			},
-			{
-				GroupID:    "org.apache.camel",
-				ArtifactID: "camel-core-engine",
-			},
-			{
-				GroupID:    "org.apache.camel",
-				ArtifactID: "camel-main",
-			},
-			{
-				GroupID:    "org.apache.camel",
-				ArtifactID: "camel-groovy",
-			},
-			{
-				GroupID:    "org.apache.camel",
-				ArtifactID: "camel-properties",
-			},
-			{
-				GroupID:    "org.apache.camel",
-				ArtifactID: "camel-endpointdsl",
-			},
+			{GroupID: "org.apache.camel.k", ArtifactID: "camel-k-runtime-main"},
+			{GroupID: "org.apache.camel.k", ArtifactID: "camel-k-loader-groovy"},
+			{GroupID: "org.apache.camel", ArtifactID: "camel-core-engine"},
+			{GroupID: "org.apache.camel", ArtifactID: "camel-main"},
+			{GroupID: "org.apache.camel", ArtifactID: "camel-groovy"},
+			{GroupID: "org.apache.camel", ArtifactID: "camel-properties"},
+			{GroupID: "org.apache.camel", ArtifactID: "camel-endpointdsl"},
 		},
 	)
 }
diff --git a/pkg/cmd/describe_kit.go b/pkg/cmd/describe_kit.go
index d2afd7f..c182650 100644
--- a/pkg/cmd/describe_kit.go
+++ b/pkg/cmd/describe_kit.go
@@ -29,7 +29,6 @@ import (
 )
 
 func newDescribeKitCmd(rootCmdOptions *RootCmdOptions) *cobra.Command {
-
 	impl := &describeKitCommand{
 		rootCmdOptions,
 	}
diff --git a/pkg/cmd/kit_get.go b/pkg/cmd/kit_get.go
index 2cc5691..187cde2 100644
--- a/pkg/cmd/kit_get.go
+++ b/pkg/cmd/kit_get.go
@@ -65,7 +65,6 @@ type kitGetCommand struct {
 
 func (command *kitGetCommand) validate(cmd *cobra.Command, args []string) error {
 	return nil
-
 }
 
 func (command *kitGetCommand) run() error {
diff --git a/pkg/controller/integrationplatform/initialize.go b/pkg/controller/integrationplatform/initialize.go
index a2e4178..2e54ae0 100644
--- a/pkg/controller/integrationplatform/initialize.go
+++ b/pkg/controller/integrationplatform/initialize.go
@@ -149,7 +149,6 @@ func (action *initializeAction) Handle(ctx context.Context, platform *v1alpha1.I
 			// Skip the warmer pod creation
 			platform.Status.Phase = v1alpha1.IntegrationPlatformPhaseCreating
 		}
-
 	} else {
 		platform.Status.Phase = v1alpha1.IntegrationPlatformPhaseCreating
 	}
diff --git a/pkg/controller/integrationplatform/integrationplatform_controller.go b/pkg/controller/integrationplatform/integrationplatform_controller.go
index 21acde2..15a52f0 100644
--- a/pkg/controller/integrationplatform/integrationplatform_controller.go
+++ b/pkg/controller/integrationplatform/integrationplatform_controller.go
@@ -189,5 +189,4 @@ func (r *ReconcileIntegrationPlatform) Reconcile(request reconcile.Request) (rec
 	return reconcile.Result{
 		RequeueAfter: 5 * time.Second,
 	}, nil
-
 }
diff --git a/pkg/controller/integrationplatform/warm.go b/pkg/controller/integrationplatform/warm.go
index dceadb2..cc3d0ef 100644
--- a/pkg/controller/integrationplatform/warm.go
+++ b/pkg/controller/integrationplatform/warm.go
@@ -64,15 +64,12 @@ func (action *warmAction) Handle(ctx context.Context, platform *v1alpha1.Integra
 	}
 
 	switch pod.Status.Phase {
-
 	case corev1.PodSucceeded:
 		action.L.Info("Kaniko cache successfully warmed up")
 		platform.Status.Phase = v1alpha1.IntegrationPlatformPhaseCreating
 		return platform, nil
-
 	case corev1.PodFailed:
 		return nil, errors.New("failed to warm up Kaniko cache")
-
 	default:
 		action.L.Info("Waiting for Kaniko cache to warm up...")
 		// Requeue
diff --git a/pkg/install/operator.go b/pkg/install/operator.go
index 9acf70d..e5cfc64 100644
--- a/pkg/install/operator.go
+++ b/pkg/install/operator.go
@@ -171,7 +171,6 @@ func PlatformOrCollect(ctx context.Context, c client.Client, namespace string, r
 	pl := platformObject.(*v1alpha1.IntegrationPlatform)
 
 	if !isOpenshift {
-
 		pl.Spec.Build.Registry = registry
 
 		// Kubernetes only (Minikube)
diff --git a/pkg/trait/gc_test.go b/pkg/trait/gc_test.go
index 744db84..88086ab 100644
--- a/pkg/trait/gc_test.go
+++ b/pkg/trait/gc_test.go
@@ -28,9 +28,7 @@ import (
 )
 
 func TestConfigureGarbageCollectorTraitDoesSucceed(t *testing.T) {
-
 	gcTrait, environment := createNominalGarbageCollectorTest()
-
 	configured, err := gcTrait.Configure(environment)
 
 	assert.True(t, configured)
@@ -38,7 +36,6 @@ func TestConfigureGarbageCollectorTraitDoesSucceed(t *testing.T) {
 }
 
 func TestConfigureDisabledGarbageCollectorTraitDoesNotSucceed(t *testing.T) {
-
 	gcTrait, environment := createNominalGarbageCollectorTest()
 	gcTrait.Enabled = new(bool)
 
@@ -70,7 +67,6 @@ func TestApplyGarbageCollectorTraitDuringInitializationPhaseSkipPostActions(t *t
 }
 
 func createNominalGarbageCollectorTest() (*garbageCollectorTrait, *Environment) {
-
 	trait := newGarbageCollectorTrait()
 	enabled := true
 	trait.Enabled = &enabled
diff --git a/pkg/trait/ingress_test.go b/pkg/trait/ingress_test.go
index 339686e..30b018f 100644
--- a/pkg/trait/ingress_test.go
+++ b/pkg/trait/ingress_test.go
@@ -33,9 +33,7 @@ import (
 )
 
 func TestConfigureIngressTraitDoesSucceed(t *testing.T) {
-
 	ingressTrait, environment := createNominalIngressTest()
-
 	configured, err := ingressTrait.Configure(environment)
 
 	assert.True(t, configured)
@@ -44,7 +42,6 @@ func TestConfigureIngressTraitDoesSucceed(t *testing.T) {
 }
 
 func TestConfigureDisabledIngressTraitDoesNotSucceed(t *testing.T) {
-
 	ingressTrait, environment := createNominalIngressTest()
 	ingressTrait.Enabled = new(bool)
 
@@ -58,7 +55,6 @@ func TestConfigureDisabledIngressTraitDoesNotSucceed(t *testing.T) {
 }
 
 func TestConfigureIngressTraitInWrongPhaseDoesNotSucceed(t *testing.T) {
-
 	ingressTrait, environment := createNominalIngressTest()
 	environment.Integration.Status.Phase = v1alpha1.IntegrationPhaseError
 
@@ -70,7 +66,6 @@ func TestConfigureIngressTraitInWrongPhaseDoesNotSucceed(t *testing.T) {
 }
 
 func TestConfigureAutoIngressTraitWithoutUserServiceDoesNotSucceed(t *testing.T) {
-
 	ingressTrait, environment := createNominalIngressTest()
 	auto := true
 	ingressTrait.Auto = &auto
@@ -86,7 +81,6 @@ func TestConfigureAutoIngressTraitWithoutUserServiceDoesNotSucceed(t *testing.T)
 }
 
 func TestConfigureAutoIngressTraitWithEmptyHostDoesNotSucceed(t *testing.T) {
-
 	ingressTrait, environment := createNominalIngressTest()
 	ingressTrait.Auto = nil
 	ingressTrait.Host = ""
@@ -101,7 +95,6 @@ func TestConfigureAutoIngressTraitWithEmptyHostDoesNotSucceed(t *testing.T) {
 }
 
 func TestConfigureAutoIngressTraitWithUserServiceDoesSucceed(t *testing.T) {
-
 	ingressTrait, environment := createNominalIngressTest()
 	ingressTrait.Auto = nil
 
@@ -113,7 +106,6 @@ func TestConfigureAutoIngressTraitWithUserServiceDoesSucceed(t *testing.T) {
 }
 
 func TestConfigureIngressTraitWithoutHostDoesNotSucceed(t *testing.T) {
-
 	ingressTrait, environment := createNominalIngressTest()
 	ingressTrait.Host = ""
 
@@ -128,7 +120,6 @@ func TestConfigureIngressTraitWithoutHostDoesNotSucceed(t *testing.T) {
 }
 
 func TestApplyIngressTraitWithoutUserServiceDoesNotSucceed(t *testing.T) {
-
 	ingressTrait, environment := createNominalIngressTest()
 	environment.Resources = kubernetes.NewCollection()
 
@@ -140,7 +131,6 @@ func TestApplyIngressTraitWithoutUserServiceDoesNotSucceed(t *testing.T) {
 }
 
 func TestApplyIngressTraitDoesSucceed(t *testing.T) {
-
 	ingressTrait, environment := createNominalIngressTest()
 
 	err := ingressTrait.Apply(environment)
@@ -165,7 +155,6 @@ func TestApplyIngressTraitDoesSucceed(t *testing.T) {
 }
 
 func createNominalIngressTest() (*ingressTrait, *Environment) {
-
 	trait := newIngressTrait()
 	enabled := true
 	trait.Enabled = &enabled
diff --git a/pkg/trait/trait_types.go b/pkg/trait/trait_types.go
index 3399057..fabf049 100644
--- a/pkg/trait/trait_types.go
+++ b/pkg/trait/trait_types.go
@@ -410,7 +410,6 @@ func (e *Environment) ComputeSourcesURI() []string {
 
 // ConfigureVolumesAndMounts --
 func (e *Environment) ConfigureVolumesAndMounts(vols *[]corev1.Volume, mnts *[]corev1.VolumeMount) {
-
 	//
 	// Volumes :: Sources
 	//
diff --git a/pkg/util/envvar/envvar.go b/pkg/util/envvar/envvar.go
index 2c87ca1..806c818 100644
--- a/pkg/util/envvar/envvar.go
+++ b/pkg/util/envvar/envvar.go
@@ -69,7 +69,6 @@ func SetVar(vars *[]corev1.EnvVar, newEnvVar corev1.EnvVar) {
 			from := *newEnvVar.ValueFrom
 			envVar.ValueFrom = &from
 		}
-
 	} else {
 		*vars = append(*vars, newEnvVar)
 	}
diff --git a/pkg/util/kubernetes/log/annotation_scraper.go b/pkg/util/kubernetes/log/annotation_scraper.go
index 11c8e20..adc5f1a 100644
--- a/pkg/util/kubernetes/log/annotation_scraper.go
+++ b/pkg/util/kubernetes/log/annotation_scraper.go
@@ -159,7 +159,6 @@ func (s *SelectorScraper) addPodScraper(ctx context.Context, podName string, out
 			}
 		}
 	}()
-
 }
 
 func (s *SelectorScraper) listPods() (*corev1.PodList, error) {
diff --git a/pkg/util/kubernetes/log/pod_scraper.go b/pkg/util/kubernetes/log/pod_scraper.go
index 162e26c..1d1a583 100644
--- a/pkg/util/kubernetes/log/pod_scraper.go
+++ b/pkg/util/kubernetes/log/pod_scraper.go
@@ -178,7 +178,6 @@ func (s *PodScraper) waitForPodRunning(ctx context.Context, namespace string, po
 					if err := json.Unmarshal(jsondata, recvPod); err != nil {
 						return "", err
 					}
-
 				} else if gotPod, ok := e.Object.(*corev1.Pod); ok {
 					recvPod = gotPod
 				}
@@ -193,7 +192,6 @@ func (s *PodScraper) waitForPodRunning(ctx context.Context, namespace string, po
 			return "", errors.New("no state change after 30 seconds for pod " + s.podName)
 		}
 	}
-
 }
 
 func (s *PodScraper) chooseContainer(p *corev1.Pod, defaultContainerName string) string {
diff --git a/pkg/util/openshift/register.go b/pkg/util/openshift/register.go
index b347a5c..0dd244d 100644
--- a/pkg/util/openshift/register.go
+++ b/pkg/util/openshift/register.go
@@ -33,7 +33,6 @@ type registerFunction func(*runtime.Scheme) error
 
 // AddToScheme adds OpenShift types to the scheme
 func AddToScheme(scheme *runtime.Scheme) error {
-
 	var err error
 
 	// Standardized groups
diff --git a/pkg/util/test/client.go b/pkg/util/test/client.go
index a758844..97b7c13 100644
--- a/pkg/util/test/client.go
+++ b/pkg/util/test/client.go
@@ -45,7 +45,6 @@ func NewFakeClient(initObjs ...runtime.Object) (client.Client, error) {
 		Client:    c,
 		Interface: nil,
 	}, nil
-
 }
 
 // FakeClient ---