portainer/portainer

View on GitHub
app/portainer/views/stacks/create/createStackController.js

Summary

Maintainability
D
3 days
Test Coverage

File createStackController.js has 323 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import angular from 'angular';

import { AccessControlFormData } from '@/portainer/components/accessControlForm/porAccessControlFormModel';
import { STACK_NAME_VALIDATION_REGEX } from '@/react/constants';
import { RepositoryMechanismTypes } from '@/kubernetes/models/deploy';
Severity: Minor
Found in app/portainer/views/stacks/create/createStackController.js - About 3 hrs to fix

    Function deployStack has 38 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          $scope.deployStack = function () {
            var name = $scope.formValues.Name;
            var method = $scope.state.Method;
    
            var accessControlData = $scope.formValues.AccessControlData;
    Severity: Minor
    Found in app/portainer/views/stacks/create/createStackController.js - About 1 hr to fix

      Function buildAnalyticsProperties has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            function buildAnalyticsProperties() {
              const metadata = { type: methodLabel($scope.state.Method) };
      
              if ($scope.state.Method === 'repository') {
                metadata.automaticUpdates = 'off';
      Severity: Minor
      Found in app/portainer/views/stacks/create/createStackController.js - About 1 hr to fix

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

                } else if (method === 'repository') {
                  var repositoryOptions = {
                    AdditionalFiles: $scope.formValues.AdditionalFiles,
                    RepositoryURL: $scope.formValues.RepositoryURL,
                    RepositoryReferenceName: $scope.formValues.RepositoryReferenceName,
        Severity: Major
        Found in app/portainer/views/stacks/create/createStackController.js and 1 other location - About 6 hrs to fix
        app/portainer/views/stacks/create/createStackController.js on lines 174..188

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

        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

                if (method === 'repository') {
                  var repositoryOptions = {
                    AdditionalFiles: $scope.formValues.AdditionalFiles,
                    RepositoryURL: $scope.formValues.RepositoryURL,
                    RepositoryReferenceName: $scope.formValues.RepositoryReferenceName,
        Severity: Major
        Found in app/portainer/views/stacks/create/createStackController.js and 1 other location - About 6 hrs to fix
        app/portainer/views/stacks/create/createStackController.js on lines 201..215

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

        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

        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/portainer/views/stacks/create/createStackController.js and 3 other locations - About 2 hrs to fix
        app/docker/views/networks/create/createNetworkController.js on lines 220..230
        app/docker/views/secrets/create/createSecretController.js on lines 62..72
        app/docker/views/volumes/create/createVolumeController.js on lines 62..72

        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

              this.uiCanExit = async function () {
                if ($scope.state.Method === 'editor' && $scope.formValues.StackFileContent && $scope.state.isEditorDirty) {
                  return confirmWebEditorDiscard();
                }
              };
        Severity: Major
        Found in app/portainer/views/stacks/create/createStackController.js and 1 other location - About 1 hr to fix
        app/docker/views/images/build/buildImageController.js on lines 156..160

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

        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

              $window.onbeforeunload = () => {
                if ($scope.state.Method === 'editor' && $scope.formValues.StackFileContent && $scope.state.isEditorDirty) {
                  return '';
                }
              };
        Severity: Major
        Found in app/portainer/views/stacks/create/createStackController.js and 3 other locations - About 1 hr to fix
        app/docker/views/images/build/buildImageController.js on lines 28..32
        app/portainer/views/devices/profiles/add/addProfileController.js on lines 23..27
        app/portainer/views/devices/profiles/edit/editProfileController.js on lines 23..27

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

        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.onEnableWebhookChange = function (enable) {
                $scope.$evalAsync(() => {
                  $scope.formValues.EnableWebhook = enable;
                });
              };
        Severity: Major
        Found in app/portainer/views/stacks/create/createStackController.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/docker/views/networks/create/createNetworkController.js on lines 214..218
        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

        There are no issues that match your filters.

        Category
        Status