portainer/portainer

View on GitHub
app/docker/views/networks/create/createNetworkController.js

Summary

Maintainability
D
2 days
Test Coverage

File createNetworkController.js has 289 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import _ from 'lodash-es';
import { AccessControlFormData } from '../../../../portainer/components/accessControlForm/porAccessControlFormModel';
import { MacvlanFormData } from '../../../components/network-macvlan-form/networkMacvlanFormModel';

angular.module('portainer.docker').controller('CreateNetworkController', [
Severity: Minor
Found in app/docker/views/networks/create/createNetworkController.js - About 2 hrs to fix

    Function create has 42 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        $scope.create = function () {
          var networkConfiguration = prepareConfiguration();
          var accessControlData = $scope.formValues.AccessControlData;
          var userDetails = Authentication.getUserDetails();
          var isAdmin = Authentication.isAdmin();
    Severity: Minor
    Found in app/docker/views/networks/create/createNetworkController.js - About 1 hr to fix

      Function prepareIPAMConfiguration has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function prepareIPAMConfiguration(config) {
            if ($scope.formValues.IPV4.Subnet) {
              let ipamConfig = {};
              ipamConfig.Subnet = $scope.formValues.IPV4.Subnet;
              if ($scope.formValues.IPV4.Gateway) {
      Severity: Minor
      Found in app/docker/views/networks/create/createNetworkController.js - About 1 hr to fix

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

            function createNetwork(context) {
              HttpRequestHelper.setPortainerAgentTargetHeader(context.nodeName);
              HttpRequestHelper.setPortainerAgentManagerOperation(context.managerOperation);
        
              $scope.state.actionInProgress = true;
        Severity: Minor
        Found in app/docker/views/networks/create/createNetworkController.js - About 1 hr to fix

          Identical blocks of code found in 4 locations. Consider refactoring.
          Open

              function validateForm(accessControlData, isAdmin) {
                $scope.state.formValidationError = '';
                var error = '';
                error = FormValidator.validateAccessControl(accessControlData, isAdmin);
          
          
          Severity: Major
          Found in app/docker/views/networks/create/createNetworkController.js and 3 other locations - About 2 hrs to fix
          app/docker/views/secrets/create/createSecretController.js on lines 62..72
          app/docker/views/volumes/create/createVolumeController.js on lines 62..72
          app/portainer/views/stacks/create/createStackController.js on lines 148..158

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

          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

              $scope.checkIPV4AuxiliaryAddress = function (index) {
                $scope.state.IPV4AuxiliaryAddressesError[index] = checkAuxiliaryAddress($scope.formValues.IPV4.AuxiliaryAddresses[index], $scope.formValues.IPV4.Gateway);
              };
          Severity: Major
          Found in app/docker/views/networks/create/createNetworkController.js and 1 other location - About 1 hr to fix
          app/docker/views/networks/create/createNetworkController.js on lines 116..118

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

          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

              $scope.checkIPV6AuxiliaryAddress = function (index) {
                $scope.state.IPV6AuxiliaryAddressesError[index] = checkAuxiliaryAddress($scope.formValues.IPV6.AuxiliaryAddresses[index], $scope.formValues.IPV6.Gateway);
              };
          Severity: Major
          Found in app/docker/views/networks/create/createNetworkController.js and 1 other location - About 1 hr to fix
          app/docker/views/networks/create/createNetworkController.js on lines 112..114

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

          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

              $scope.removeIPV4AuxAddress = function (index) {
                $scope.formValues.IPV4.AuxiliaryAddresses.splice(index, 1);
                $scope.state.IPV4AuxiliaryAddressesError.splice(index, 1);
              };
          Severity: Major
          Found in app/docker/views/networks/create/createNetworkController.js and 1 other location - About 1 hr to fix
          app/docker/views/networks/create/createNetworkController.js on lines 98..101

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

          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

              $scope.removeIPV6AuxAddress = function (index) {
                $scope.formValues.IPV6.AuxiliaryAddresses.splice(index, 1);
                $scope.state.IPV6AuxiliaryAddressesError.splice(index, 1);
              };
          Severity: Major
          Found in app/docker/views/networks/create/createNetworkController.js and 1 other location - About 1 hr to fix
          app/docker/views/networks/create/createNetworkController.js on lines 93..96

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

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

              $scope.onChangeAttachable = function (enable) {
                $scope.$evalAsync(() => {
                  $scope.config.Attachable = enable;
                });
              };
          Severity: Major
          Found in app/docker/views/networks/create/createNetworkController.js and 6 other locations - About 40 mins to fix
          app/docker/views/containers/console/containerConsoleController.js on lines 255..259
          app/docker/views/images/build/buildImageController.js on lines 38..42
          app/docker/views/networks/create/createNetworkController.js on lines 208..212
          app/portainer/views/stacks/create/createStackController.js on lines 101..105
          app/portainer/views/stacks/edit/stackController.js on lines 99..103
          app/portainer/views/stacks/edit/stackController.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 48.

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

              $scope.onChangeInternal = function (enable) {
                $scope.$evalAsync(() => {
                  $scope.config.Internal = enable;
                });
              };
          Severity: Major
          Found in app/docker/views/networks/create/createNetworkController.js and 6 other locations - About 40 mins to fix
          app/docker/views/containers/console/containerConsoleController.js on lines 255..259
          app/docker/views/images/build/buildImageController.js on lines 38..42
          app/docker/views/networks/create/createNetworkController.js on lines 214..218
          app/portainer/views/stacks/create/createStackController.js on lines 101..105
          app/portainer/views/stacks/edit/stackController.js on lines 99..103
          app/portainer/views/stacks/edit/stackController.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 48.

          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

              $scope.addDriverOption = function () {
                $scope.formValues.DriverOptions.push({
                  name: '',
                  value: '',
                });
          Severity: Major
          Found in app/docker/views/networks/create/createNetworkController.js and 7 other locations - About 35 mins to fix
          app/docker/views/networks/create/createNetworkController.js on lines 74..79
          app/docker/views/secrets/create/createSecretController.js on lines 34..36
          app/docker/views/services/create/createServiceController.js on lines 196..198
          app/docker/views/services/create/createServiceController.js on lines 204..206
          app/docker/views/services/create/createServiceController.js on lines 212..214
          app/docker/views/services/create/createServiceController.js on lines 220..222
          app/docker/views/volumes/create/createVolumeController.js on lines 36..38

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

          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

              $scope.addLabel = function () {
                $scope.formValues.Labels.push({
                  key: '',
                  value: '',
                });
          Severity: Major
          Found in app/docker/views/networks/create/createNetworkController.js and 7 other locations - About 35 mins to fix
          app/docker/views/networks/create/createNetworkController.js on lines 63..68
          app/docker/views/secrets/create/createSecretController.js on lines 34..36
          app/docker/views/services/create/createServiceController.js on lines 196..198
          app/docker/views/services/create/createServiceController.js on lines 204..206
          app/docker/views/services/create/createServiceController.js on lines 212..214
          app/docker/views/services/create/createServiceController.js on lines 220..222
          app/docker/views/volumes/create/createVolumeController.js on lines 36..38

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

          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