portainer/portainer

View on GitHub

Showing 1,497 of 3,384 total issues

Function createEventDetails has 158 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function createEventDetails(event) {
  var eventAttr = event.Actor.Attributes;
  var details = '';

  var action = event.Action;
Severity: Major
Found in app/docker/models/event.js - About 6 hrs to fix

    Function ContainerHelperFactory has 157 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      function ContainerHelperFactory() {
        'use strict';
        var helper = {};
    
        helper.configFromContainer = function (container) {
    Severity: Major
    Found in app/docker/helpers/containerHelper.js - About 6 hrs to fix

      Function ItemView has 157 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function ItemView() {
        const {
          params: { id },
        } = useCurrentStateAndParams();
        const { subscriptionId, resourceGroupId, containerGroupId } = parseId(id);
      Severity: Major
      Found in app/react/azure/container-instances/ItemView/ItemView.tsx - About 6 hrs to fix

        Method Handler.registryUpdate has a Cognitive Complexity of 56 (exceeds 20 allowed). Consider refactoring.
        Open

        func (handler *Handler) registryUpdate(w http.ResponseWriter, r *http.Request) *httperror.HandlerError {
            securityContext, err := security.RetrieveRestrictedRequestContext(r)
            if err != nil {
                return httperror.InternalServerError("Unable to retrieve info from request context", err)
            }
        Severity: Minor
        Found in api/http/handler/registries/registry_update.go - About 6 hrs to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        File stackController.js has 426 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import { ResourceControlType } from '@/react/portainer/access-control/types';
        import { AccessControlFormData } from 'Portainer/components/accessControlForm/porAccessControlFormModel';
        import { FeatureId } from '@/react/portainer/feature-flags/enums';
        import { getEnvironments } from '@/react/portainer/environments/environment.service';
        import { StackStatus, StackType } from '@/react/common/stacks/types';
        Severity: Minor
        Found in app/portainer/views/stacks/edit/stackController.js - About 6 hrs to fix

          Method Store.Export has 178 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func (store *Store) Export(filename string) (err error) {
          
              backup := storeExport{}
          
              if c, err := store.CustomTemplate().ReadAll(); err != nil {
          Severity: Major
          Found in api/datastore/services.go - About 6 hrs to fix

            Function snapshotContainers has a Cognitive Complexity of 55 (exceeds 20 allowed). Consider refactoring.
            Open

            func snapshotContainers(snapshot *portainer.DockerSnapshot, cli *client.Client) error {
                containers, err := cli.ContainerList(context.Background(), container.ListOptions{All: true})
                if err != nil {
                    return err
                }
            Severity: Minor
            Found in api/docker/snapshot.go - About 6 hrs to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            Function StackServiceFactory has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
            Open

              function StackServiceFactory($q, $async, Stack, StackByName, FileUploadService, StackHelper, ServiceService, ContainerService, SwarmService) {
                'use strict';
                var service = {
                  updateGit,
                  updateKubeGit,
            Severity: Minor
            Found in app/portainer/services/api/stackService.js - About 6 hrs to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            Function validate has 151 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                (
                  ingressRule: Rule,
                  ingressNames: string[],
                  groupedServiceOptions: GroupedServiceOptions,
                  existingIngressClass?: IngressController

              File stackService.js has 417 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import _ from 'lodash-es';
              import { transformAutoUpdateViewModel } from '@/react/portainer/gitops/AutoUpdateFieldset/utils';
              import { StackViewModel } from '@/react/docker/stacks/view-models/stack';
              
              angular.module('portainer.app').factory('StackService', [
              Severity: Minor
              Found in app/portainer/services/api/stackService.js - About 6 hrs to fix

                Function applicationCommon has 149 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  static applicationCommon(res, data, pods, service, ingresses) {
                    const containers = data.spec.template ? _.without(_.concat(data.spec.template.spec.containers, data.spec.template.spec.initContainers), undefined) : data.spec.containers;
                    res.Id = data.metadata.uid;
                    res.Name = data.metadata.name;
                    res.Metadata = data.metadata;
                Severity: Major
                Found in app/kubernetes/converters/application.js - About 5 hrs to fix

                  File ConfigureForm.tsx has 413 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  import { Formik, Form, FormikProps, FormikHelpers } from 'formik';
                  import { useCallback, useEffect, useMemo } from 'react';
                  import _ from 'lodash';
                  import { useTransitionHook } from '@uirouter/react';
                  
                  

                    Function RegistryServiceFactory has 146 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      function RegistryServiceFactory($q, $async, EndpointService, Registries, ImageHelper, FileUploadService) {
                        return {
                          registries,
                          registry,
                          encodedCredentials,
                    Severity: Major
                    Found in app/portainer/services/api/registryService.js - About 5 hrs to fix

                      Function ImageServiceFactory has 141 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        function ImageServiceFactory($q, Image, ImageHelper, RegistryService, HttpRequestHelper, ContainerService, FileUploadService) {
                          'use strict';
                          var service = {};
                      
                          service.image = function (imageId) {
                      Severity: Major
                      Found in app/docker/services/imageService.js - About 5 hrs to fix

                        Function ContainerServiceFactory has 139 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        function ContainerServiceFactory($q, Container, $timeout) {
                          const service = {
                            killContainer,
                            pauseContainer,
                            renameContainer,
                        Severity: Major
                        Found in app/docker/services/containerService.js - About 5 hrs to fix

                          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

                            Function EndpointServiceFactory has 136 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              function EndpointServiceFactory($q, Endpoints, FileUploadService) {
                                'use strict';
                                var service = {
                                  updateSecuritySettings,
                                  registries,
                            Severity: Major
                            Found in app/portainer/services/api/endpointService.js - About 5 hrs to fix

                              Function ItemView has 136 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              function ItemView() {
                                const {
                                  params: { id: idParam },
                                } = useCurrentStateAndParams();
                              
                              

                                File InputList.tsx has 391 lines of code (exceeds 250 allowed). Consider refactoring.
                                Open

                                import { ComponentType, useRef } from 'react';
                                import { FormikErrors } from 'formik';
                                import { ArrowDown, ArrowUp, Plus, RotateCw, Trash2 } from 'lucide-react';
                                import clsx from 'clsx';
                                
                                
                                Severity: Minor
                                Found in app/react/components/form-components/InputList/InputList.tsx - About 5 hrs to fix

                                  Function BuildImageController has 134 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                  function BuildImageController($scope, $async, $window, BuildService, Notifications, HttpRequestHelper, endpoint) {
                                    $scope.endpoint = endpoint;
                                    $scope.options = [editor, upload, url];
                                  
                                    $scope.state = {
                                  Severity: Major
                                  Found in app/docker/views/images/build/buildImageController.js - About 5 hrs to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language