portainer/portainer

View on GitHub
app/kubernetes/views/cluster/node/nodeController.js

Summary

Maintainability
F
3 days
Test Coverage

KubernetesNodeController has 41 functions (exceeds 20 allowed). Consider refactoring.
Open

class KubernetesNodeController {
  /* @ngInject */
  constructor(
    $async,
    $state,
Severity: Minor
Found in app/kubernetes/views/cluster/node/nodeController.js - About 5 hrs to fix

    File nodeController.js has 354 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import angular from 'angular';
    import _ from 'lodash-es';
    import KubernetesResourceReservationHelper from 'Kubernetes/helpers/resourceReservationHelper';
    import { KubernetesResourceReservation } from 'Kubernetes/models/resource-reservation/models';
    import KubernetesEventHelper from 'Kubernetes/helpers/eventHelper';
    Severity: Minor
    Found in app/kubernetes/views/cluster/node/nodeController.js - About 4 hrs to fix

      Function onInit has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        async onInit() {
          this.availabilities = KubernetesNodeAvailabilities;
      
          this.state = {
            isAdmin: this.Authentication.isAdmin(),
      Severity: Minor
      Found in app/kubernetes/views/cluster/node/nodeController.js - About 1 hr to fix

        Function getApplicationsAsync has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          async getApplicationsAsync() {
            try {
              this.state.applicationsLoading = true;
              this.applications = await this.KubernetesApplicationService.get();
        
        
        Severity: Minor
        Found in app/kubernetes/views/cluster/node/nodeController.js - About 1 hr to fix

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

            onChangeTaintKey(index) {
              this.state.duplicateTaintKeys = KubernetesFormValidationHelper.getDuplicates(
                _.map(this.formValues.Taints, (taint) => {
                  if (taint.NeedsDeletion) {
                    return undefined;
          Severity: Major
          Found in app/kubernetes/views/cluster/node/nodeController.js and 1 other location - About 4 hrs to fix
          app/kubernetes/views/cluster/node/nodeController.js on lines 108..119

          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 121.

          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 2 locations. Consider refactoring.
          Open

            onChangeLabelKey(index) {
              this.state.duplicateLabelKeys = KubernetesFormValidationHelper.getDuplicates(
                _.map(this.formValues.Labels, (label) => {
                  if (label.NeedsDeletion) {
                    return undefined;
          Severity: Major
          Found in app/kubernetes/views/cluster/node/nodeController.js and 1 other location - About 4 hrs to fix
          app/kubernetes/views/cluster/node/nodeController.js on lines 57..68

          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 121.

          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 2 locations. Consider refactoring.
          Open

            removeLabel(index) {
              const label = this.formValues.Labels[index];
              if (label.IsNew) {
                this.formValues.Labels.splice(index, 1);
              } else {
          Severity: Major
          Found in app/kubernetes/views/cluster/node/nodeController.js and 1 other location - About 2 hrs to fix
          app/kubernetes/views/cluster/node/nodeController.js on lines 83..91

          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 84.

          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 2 locations. Consider refactoring.
          Open

            removeTaint(index) {
              const taint = this.formValues.Taints[index];
              if (taint.IsNew) {
                this.formValues.Taints.splice(index, 1);
              } else {
          Severity: Major
          Found in app/kubernetes/views/cluster/node/nodeController.js and 1 other location - About 2 hrs to fix
          app/kubernetes/views/cluster/node/nodeController.js on lines 133..141

          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 84.

          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 4 locations. Consider refactoring.
          Open

            $onDestroy() {
              if (this.state.currentName !== this.$state.$current.name) {
                this.LocalStorage.storeActiveTab('node', 0);
              }
            }
          Severity: Major
          Found in app/kubernetes/views/cluster/node/nodeController.js and 3 other locations - About 1 hr to fix
          app/kubernetes/views/applications/applicationsController.js on lines 217..221
          app/kubernetes/views/volumes/edit/volumeController.js on lines 208..212
          app/kubernetes/views/volumes/volumesController.js on lines 105..109

          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 55.

          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 2 locations. Consider refactoring.
          Open

            onChangeTaint(index) {
              if (this.formValues.Taints[index]) {
                this.formValues.Taints[index].IsChanged = true;
              }
            }
          Severity: Minor
          Found in app/kubernetes/views/cluster/node/nodeController.js and 1 other location - About 50 mins to fix
          app/kubernetes/views/cluster/node/nodeController.js on lines 121..125

          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 51.

          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 2 locations. Consider refactoring.
          Open

            onChangeLabel(index) {
              if (this.formValues.Labels[index]) {
                this.formValues.Labels[index].IsChanged = true;
              }
            }
          Severity: Minor
          Found in app/kubernetes/views/cluster/node/nodeController.js and 1 other location - About 50 mins to fix
          app/kubernetes/views/cluster/node/nodeController.js on lines 70..74

          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 51.

          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

          There are no issues that match your filters.

          Category
          Status