cloudfoundry-incubator/eirini

View on GitHub

Showing 59 of 59 total issues

Method APIConverter.ConvertLRP has 52 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (c *APIConverter) ConvertLRP(request cf.DesireLRPRequest) (api.LRP, error) {
    env := map[string]string{
        "LANG": "en_US.UTF-8",
    }

Severity: Minor
Found in bifrost/convert.go - About 1 hr to fix

    Function NewLRPClient has 8 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        logger lager.Logger,
        secrets SecretsClient,
        statefulSets StatefulSetClient,
        pods PodClient,
        pdbClient PodDisruptionBudgetClient,
    Severity: Major
    Found in k8s/lrp_client.go - About 1 hr to fix

      Function NewReconciler has 8 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          logger lager.Logger,
          podClient client.Client,
          jobsClient JobsClient,
          podUpdater PodsClient,
          reporter Reporter,
      Severity: Major
      Found in k8s/informers/task/reconciler.go - About 1 hr to fix

        Method Reconciler.Reconcile has 10 return statements (exceeds 4 allowed).
        Open

        func (r Reconciler) Reconcile(ctx context.Context, request reconcile.Request) (reconcile.Result, error) {
            logger := r.logger.Session("task-completion-reconciler", lager.Data{"namespace": request.Namespace, "pod-name": request.Name})
        
            pod := &corev1.Pod{}
            if err := r.runtimeClient.Get(ctx, request.NamespacedName, pod); err != nil {
        Severity: Major
        Found in k8s/informers/task/reconciler.go - About 1 hr to fix

          Method Desirer.Desire has 9 return statements (exceeds 4 allowed).
          Open

          func (d *Desirer) Desire(ctx context.Context, namespace string, lrp *api.LRP, opts ...shared.Option) error {
              logger := d.logger.Session("desire", lager.Data{"guid": lrp.GUID, "version": lrp.Version, "namespace": namespace})
          
              statefulSetName, err := utils.GetStatefulsetName(lrp)
              if err != nil {
          Severity: Major
          Found in k8s/stset/desire.go - About 55 mins to fix

            Function NewLRPToStatefulSetConverter has 7 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                applicationServiceAccount string,
                registrySecretName string,
                allowAutomountServiceAccountToken bool,
                allowRunImageAsRoot bool,
                latestMigration int,
            Severity: Major
            Found in k8s/stset/lrp_to_statefulset.go - About 50 mins to fix

              Function GetPodState has 8 return statements (exceeds 4 allowed).
              Open

              func GetPodState(pod corev1.Pod) string {
                  if len(pod.Status.ContainerStatuses) == 0 || pod.Status.Phase == corev1.PodUnknown {
                      return api.UnknownState
                  }
              
              
              Severity: Major
              Found in k8s/utils/pod_state.go - About 50 mins to fix

                Similar blocks of code found in 8 locations. Consider refactoring.
                Open

                func (c *PodDisruptionBudget) Create(ctx context.Context, namespace string, podDisruptionBudget *policyv1beta1.PodDisruptionBudget) (*policyv1beta1.PodDisruptionBudget, error) {
                    ctx, cancel := context.WithTimeout(ctx, k8sTimeout)
                    defer cancel()
                
                    return c.clientSet.PolicyV1beta1().PodDisruptionBudgets(namespace).Create(ctx, podDisruptionBudget, metav1.CreateOptions{})
                Severity: Major
                Found in k8s/client/pod_disruption_budget_client.go and 7 other locations - About 50 mins to fix
                k8s/client/event_client.go on lines 42..47
                k8s/client/event_client.go on lines 49..54
                k8s/client/job_client.go on lines 31..36
                k8s/client/secret_client.go on lines 30..35
                k8s/client/secret_client.go on lines 37..42
                k8s/client/statefulset_client.go on lines 29..34
                k8s/client/statefulset_client.go on lines 75..80

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 118.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 8 locations. Consider refactoring.
                Open

                func (c *StatefulSet) Update(ctx context.Context, namespace string, statefulSet *appsv1.StatefulSet) (*appsv1.StatefulSet, error) {
                    ctx, cancel := context.WithTimeout(ctx, k8sTimeout)
                    defer cancel()
                
                    return c.clientSet.AppsV1().StatefulSets(namespace).Update(ctx, statefulSet, metav1.UpdateOptions{})
                Severity: Major
                Found in k8s/client/statefulset_client.go and 7 other locations - About 50 mins to fix
                k8s/client/event_client.go on lines 42..47
                k8s/client/event_client.go on lines 49..54
                k8s/client/job_client.go on lines 31..36
                k8s/client/pod_disruption_budget_client.go on lines 31..36
                k8s/client/secret_client.go on lines 30..35
                k8s/client/secret_client.go on lines 37..42
                k8s/client/statefulset_client.go on lines 29..34

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 118.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 8 locations. Consider refactoring.
                Open

                func (c *Event) Create(ctx context.Context, namespace string, event *corev1.Event) (*corev1.Event, error) {
                    ctx, cancel := context.WithTimeout(ctx, k8sTimeout)
                    defer cancel()
                
                    return c.clientSet.CoreV1().Events(namespace).Create(ctx, event, metav1.CreateOptions{})
                Severity: Major
                Found in k8s/client/event_client.go and 7 other locations - About 50 mins to fix
                k8s/client/event_client.go on lines 49..54
                k8s/client/job_client.go on lines 31..36
                k8s/client/pod_disruption_budget_client.go on lines 31..36
                k8s/client/secret_client.go on lines 30..35
                k8s/client/secret_client.go on lines 37..42
                k8s/client/statefulset_client.go on lines 29..34
                k8s/client/statefulset_client.go on lines 75..80

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 118.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 8 locations. Consider refactoring.
                Open

                func (c *Job) Create(ctx context.Context, namespace string, job *batchv1.Job) (*batchv1.Job, error) {
                    ctx, cancel := context.WithTimeout(ctx, k8sTimeout)
                    defer cancel()
                
                    return c.clientSet.BatchV1().Jobs(namespace).Create(ctx, job, metav1.CreateOptions{})
                Severity: Major
                Found in k8s/client/job_client.go and 7 other locations - About 50 mins to fix
                k8s/client/event_client.go on lines 42..47
                k8s/client/event_client.go on lines 49..54
                k8s/client/pod_disruption_budget_client.go on lines 31..36
                k8s/client/secret_client.go on lines 30..35
                k8s/client/secret_client.go on lines 37..42
                k8s/client/statefulset_client.go on lines 29..34
                k8s/client/statefulset_client.go on lines 75..80

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 118.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 8 locations. Consider refactoring.
                Open

                func (c *Secret) Create(ctx context.Context, namespace string, secret *corev1.Secret) (*corev1.Secret, error) {
                    ctx, cancel := context.WithTimeout(ctx, k8sTimeout)
                    defer cancel()
                
                    return c.clientSet.CoreV1().Secrets(namespace).Create(ctx, secret, metav1.CreateOptions{})
                Severity: Major
                Found in k8s/client/secret_client.go and 7 other locations - About 50 mins to fix
                k8s/client/event_client.go on lines 42..47
                k8s/client/event_client.go on lines 49..54
                k8s/client/job_client.go on lines 31..36
                k8s/client/pod_disruption_budget_client.go on lines 31..36
                k8s/client/secret_client.go on lines 37..42
                k8s/client/statefulset_client.go on lines 29..34
                k8s/client/statefulset_client.go on lines 75..80

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 118.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 8 locations. Consider refactoring.
                Open

                func (c *Secret) Update(ctx context.Context, namespace string, secret *corev1.Secret) (*corev1.Secret, error) {
                    ctx, cancel := context.WithTimeout(ctx, k8sTimeout)
                    defer cancel()
                
                    return c.clientSet.CoreV1().Secrets(namespace).Update(ctx, secret, metav1.UpdateOptions{})
                Severity: Major
                Found in k8s/client/secret_client.go and 7 other locations - About 50 mins to fix
                k8s/client/event_client.go on lines 42..47
                k8s/client/event_client.go on lines 49..54
                k8s/client/job_client.go on lines 31..36
                k8s/client/pod_disruption_budget_client.go on lines 31..36
                k8s/client/secret_client.go on lines 30..35
                k8s/client/statefulset_client.go on lines 29..34
                k8s/client/statefulset_client.go on lines 75..80

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 118.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 8 locations. Consider refactoring.
                Open

                func (c *StatefulSet) Create(ctx context.Context, namespace string, statefulSet *appsv1.StatefulSet) (*appsv1.StatefulSet, error) {
                    ctx, cancel := context.WithTimeout(ctx, k8sTimeout)
                    defer cancel()
                
                    return c.clientSet.AppsV1().StatefulSets(namespace).Create(ctx, statefulSet, metav1.CreateOptions{})
                Severity: Major
                Found in k8s/client/statefulset_client.go and 7 other locations - About 50 mins to fix
                k8s/client/event_client.go on lines 42..47
                k8s/client/event_client.go on lines 49..54
                k8s/client/job_client.go on lines 31..36
                k8s/client/pod_disruption_budget_client.go on lines 31..36
                k8s/client/secret_client.go on lines 30..35
                k8s/client/secret_client.go on lines 37..42
                k8s/client/statefulset_client.go on lines 75..80

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 118.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 8 locations. Consider refactoring.
                Open

                func (c *Event) Update(ctx context.Context, namespace string, event *corev1.Event) (*corev1.Event, error) {
                    ctx, cancel := context.WithTimeout(ctx, k8sTimeout)
                    defer cancel()
                
                    return c.clientSet.CoreV1().Events(namespace).Update(ctx, event, metav1.UpdateOptions{})
                Severity: Major
                Found in k8s/client/event_client.go and 7 other locations - About 50 mins to fix
                k8s/client/event_client.go on lines 42..47
                k8s/client/job_client.go on lines 31..36
                k8s/client/pod_disruption_budget_client.go on lines 31..36
                k8s/client/secret_client.go on lines 30..35
                k8s/client/secret_client.go on lines 37..42
                k8s/client/statefulset_client.go on lines 29..34
                k8s/client/statefulset_client.go on lines 75..80

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 118.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Function generateReport has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    pod *v1.Pod,
                    reason string,
                    exitStatus int,
                    exitDescription string,
                    crashTimestamp int64,
                Severity: Minor
                Found in k8s/informers/event/crash_event_generator.go - About 45 mins to fix

                  Method CrashReconciler.Reconcile has 6 return statements (exceeds 4 allowed).
                  Open

                  func (c *CrashReconciler) Reconcile(ctx context.Context, request reconcile.Request) (reconcile.Result, error) {
                      logger := c.logger.Session("reconcile-pod-crash",
                          lager.Data{
                              "name":      request.NamespacedName.Name,
                              "namespace": request.NamespacedName.Namespace,
                  Severity: Major
                  Found in k8s/informers/event/crash.go - About 40 mins to fix

                    Method DefaultCrashEventGenerator.Generate has 6 return statements (exceeds 4 allowed).
                    Open

                    func (g DefaultCrashEventGenerator) Generate(ctx context.Context, pod *v1.Pod, logger lager.Logger) (events.CrashEvent, bool) {
                        logger = logger.Session("generate-crash-event",
                            lager.Data{
                                "pod-name": pod.Name,
                                "guid":     pod.Annotations[stset.AnnotationProcessGUID],
                    Severity: Major
                    Found in k8s/informers/event/crash_event_generator.go - About 40 mins to fix

                      Method Reconciler.reportIfRequired has 6 return statements (exceeds 4 allowed).
                      Open

                      func (r *Reconciler) reportIfRequired(ctx context.Context, pod *corev1.Pod) error {
                          if pod.Annotations[jobs.AnnotationCCAckedTaskCompletion] == jobs.TaskCompletedTrue {
                              return nil
                          }
                      
                      
                      Severity: Major
                      Found in k8s/informers/task/reconciler.go - About 40 mins to fix

                        Similar blocks of code found in 3 locations. Consider refactoring.
                        Open

                        func (c *Secret) Get(ctx context.Context, namespace, name string) (*corev1.Secret, error) {
                            ctx, cancel := context.WithTimeout(ctx, k8sTimeout)
                            defer cancel()
                        
                            return c.clientSet.CoreV1().Secrets(namespace).Get(ctx, name, metav1.GetOptions{})
                        Severity: Minor
                        Found in k8s/client/secret_client.go and 2 other locations - About 40 mins to fix
                        k8s/client/pod_disruption_budget_client.go on lines 24..29
                        k8s/client/statefulset_client.go on lines 36..41

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 108.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Severity
                        Category
                        Status
                        Source
                        Language