diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 000000000..4f4f9e4e2 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,11 @@ +issues: + exclude-use-default: false + +linters: + disable-all: true + enable: + - golint + +linters-settings: + golint: + min-confidence: 0.85 diff --git a/internal/apiresource/deployment.go b/internal/apiresource/deployment.go index 4ec5b8808..845fffd4f 100644 --- a/internal/apiresource/deployment.go +++ b/internal/apiresource/deployment.go @@ -137,9 +137,8 @@ func (d *Deployment) ConvertToClusterSupportedKinds(obj runtime.Object, supporte } else if d1, ok := obj.(*corev1.Pod); ok { var replicas int32 = 2 return []runtime.Object{d.toDeployment(d1.ObjectMeta, d1.Spec, replicas)}, true - } else { - return []runtime.Object{obj}, true } + return []runtime.Object{obj}, true } if common.IsStringPresent(supportedKinds, replicationControllerKind) { if d1, ok := obj.(*okdappsv1.DeploymentConfig); ok { @@ -149,9 +148,8 @@ func (d *Deployment) ConvertToClusterSupportedKinds(obj runtime.Object, supporte } else if d1, ok := obj.(*corev1.Pod); ok { var replicas int32 = 2 return []runtime.Object{d.toReplicationController(d1.ObjectMeta, d1.Spec, replicas)}, true - } else { - return []runtime.Object{obj}, true } + return []runtime.Object{obj}, true } if common.IsStringPresent(supportedKinds, podKind) { if d1, ok := obj.(*okdappsv1.DeploymentConfig); ok { @@ -160,9 +158,8 @@ func (d *Deployment) ConvertToClusterSupportedKinds(obj runtime.Object, supporte return []runtime.Object{d.toPod(d1.ObjectMeta, d1.Spec.Template.Spec, corev1.RestartPolicyAlways)}, true } else if d1, ok := obj.(*corev1.ReplicationController); ok { return []runtime.Object{d.toPod(d1.ObjectMeta, d1.Spec.Template.Spec, corev1.RestartPolicyAlways)}, true - } else { - return []runtime.Object{obj}, true } + return []runtime.Object{obj}, true } return nil, false } diff --git a/internal/common/utils_test.go b/internal/common/utils_test.go index 2bd9e4fdb..5376aa34c 100644 --- a/internal/common/utils_test.go +++ b/internal/common/utils_test.go @@ -208,7 +208,7 @@ func TestGetImageNameAndTag(t *testing.T) { type givesYamlError struct{} -func (_ *givesYamlError) MarshalYAML() (interface{}, error) { +func (*givesYamlError) MarshalYAML() (interface{}, error) { return nil, fmt.Errorf("Can't marshal this type to yaml.") } @@ -325,7 +325,7 @@ func TestReadYaml(t *testing.T) { type givesJSONError struct{} -func (_ *givesJSONError) MarshalJSON() ([]byte, error) { +func (*givesJSONError) MarshalJSON() ([]byte, error) { return nil, fmt.Errorf("Can't marshal this type to json.") } diff --git a/internal/qaengine/cliengine.go b/internal/qaengine/cliengine.go index cc09405be..47e9a7672 100644 --- a/internal/qaengine/cliengine.go +++ b/internal/qaengine/cliengine.go @@ -63,8 +63,7 @@ func (c *CliEngine) FetchAnswer(prob qatypes.Problem) (answer qatypes.Problem, e } func (c *CliEngine) fetchSelectAnswer(prob qatypes.Problem) (answer qatypes.Problem, err error) { - var ans string = "" - d := "" + var ans, d string if len(prob.Solution.Default) > 0 { d = prob.Solution.Default[0] } else { diff --git a/types/plan/plan_test.go b/types/plan/plan_test.go index 3b5ee02b5..228bd981d 100644 --- a/types/plan/plan_test.go +++ b/types/plan/plan_test.go @@ -432,11 +432,11 @@ func TestNewPlan(t *testing.T) { } func TestNewService(t *testing.T) { - svc_name := "foo" - var trans_type plan.TranslationTypeValue = "bar" - s := plan.NewService(svc_name, trans_type) - if s.ServiceName != svc_name || s.TranslationType != trans_type { - t.Error("Service name and translation type have not been set correctly. Expected:", svc_name, trans_type, "Actual:", s.ServiceName, s.TranslationType) + svcName := "foo" + var transType plan.TranslationTypeValue = "bar" + s := plan.NewService(svcName, transType) + if s.ServiceName != svcName || s.TranslationType != transType { + t.Error("Service name and translation type have not been set correctly. Expected:", svcName, transType, "Actual:", s.ServiceName, s.TranslationType) } if s.SourceTypes == nil || s.BuildArtifacts == nil || s.SourceArtifacts == nil { t.Error("Failed to instantiate the service fields properly. Actual:", s)