portainer/portainer

View on GitHub

Showing 1,589 of 3,820 total issues

Function CreateIngressView has 723 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function CreateIngressView() {
  const environmentId = useEnvironmentId();
  const { params } = useCurrentStateAndParams();
  const { authorized: isAuthorizedToAddEdit } = useAuthorizations([
    'K8sIngressesW',
Severity: Major
Found in app/react/kubernetes/ingresses/CreateIngressView/CreateIngressView.tsx - About 3 days to fix

    File portainer.go has 1472 lines of code (exceeds 500 allowed). Consider refactoring.
    Open

    package portainer
    
    import (
        "context"
        "fmt"
    Severity: Major
    Found in api/portainer.go - About 3 days to fix

      File docker-compose-schema.ts has 1066 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      // based on https://github.com/compose-spec/compose-spec/blob/master/schema/compose-spec.json
      // with added descriptions from https://github.com/microsoft/compose-language-service/blob/7a74283ddb866988fed86241f461a657f0aee6d0/src/service/providers/KeyHoverProvider.ts#L57-L184
      // hopefully https://github.com/compose-spec/compose-spec/pull/581 will apply these same changes
      export const dockerComposeSchema = {
        $schema: 'https://json-schema.org/draft-07/schema',
      Severity: Major
      Found in app/react/hooks/useDockerComposeSchema/docker-compose-schema.ts - About 2 days to fix

        File createApplicationController.js has 960 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import angular from 'angular';
        import _ from 'lodash-es';
        import filesizeParser from 'filesize-parser';
        import * as JsonPatch from 'fast-json-patch';
        import { RegistryTypes } from '@/portainer/models/registryTypes';

          Function StackServiceFactory has 400 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

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

            File serviceController.js has 796 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            require('./includes/configs.html');
            require('./includes/constraints.html');
            require('./includes/container-specs.html');
            require('./includes/containerlabels.html');
            require('./includes/environmentvariables.html');
            Severity: Major
            Found in app/docker/views/services/edit/serviceController.js - About 1 day to fix

              File IngressForm.tsx has 770 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import { ChangeEvent, useEffect } from 'react';
              import { Plus, RefreshCw, Trash2 } from 'lucide-react';
              
              import Route from '@/assets/ico/route.svg?c';
              
              
              Severity: Major
              Found in app/react/kubernetes/ingresses/CreateIngressView/IngressForm.tsx - About 1 day to fix

                File CreateIngressView.tsx has 762 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import { useState, useEffect, useMemo, useCallback, ReactNode } from 'react';
                import { useCurrentStateAndParams, useRouter } from '@uirouter/react';
                import { v4 as uuidv4 } from 'uuid';
                import { debounce } from 'lodash';
                
                

                  Method Store.Export has a Cognitive Complexity of 98 (exceeds 20 allowed). Consider refactoring.
                  Open

                  func (store *Store) Export(filename string) (err error) {
                      backup := storeExport{}
                  
                      if c, err := store.CustomTemplate().ReadAll(); err != nil {
                          if !store.IsErrObjectNotFound(err) {
                  Severity: Minor
                  Found in api/datastore/services.go - About 1 day 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 SettingsAuthenticationController has a Cognitive Complexity of 75 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function SettingsAuthenticationController($q, $scope, $state, Notifications, SettingsService, FileUploadService, TeamService, LDAPService) {
                    $scope.authMethod = 1;
                  
                    $scope.state = {
                      uploadInProgress: false,

                  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 EndpointController has 292 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function EndpointController(
                    $async,
                    $scope,
                    $state,
                    $transition$,
                  Severity: Major
                  Found in app/portainer/views/endpoints/edit/endpointController.js - About 1 day to fix

                    Function CreateIngressView has a Cognitive Complexity of 72 (exceeds 5 allowed). Consider refactoring.
                    Open

                    export function CreateIngressView() {
                      const environmentId = useEnvironmentId();
                      const { params } = useCurrentStateAndParams();
                      const { authorized: isAuthorizedToAddEdit } = useAuthorizations([
                        'K8sIngressesW',

                    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 __module.js has 630 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    import angular from 'angular';
                    
                    import { PortainerEndpointTypes } from 'Portainer/models/endpoint/models';
                    
                    import { EnvironmentStatus } from '@/react/portainer/environments/types';
                    Severity: Major
                    Found in app/docker/__module.js - About 1 day to fix

                      KubernetesCreateApplicationController has 73 functions (exceeds 20 allowed). Consider refactoring.
                      Open

                      class KubernetesCreateApplicationController {
                        /* #region  CONSTRUCTOR */
                      
                        /* @ngInject */
                        constructor(

                        Function ApplicationSummaryWidget has 267 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        export function ApplicationSummaryWidget() {
                          const stateAndParams = useCurrentStateAndParams();
                          const {
                            params: {
                              namespace,

                          File __module.js has 611 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          import { EnvironmentStatus } from '@/react/portainer/environments/types';
                          
                          import { updateAxiosAdapter } from '@/portainer/services/axios';
                          import { PortainerEndpointTypes } from 'Portainer/models/endpoint/models';
                          import { CACHE_REFRESH_EVENT, CACHE_DURATION } from '../portainer/services/http-request.helper';
                          Severity: Major
                          Found in app/kubernetes/__module.js - About 1 day to fix

                            Function ChartService has 241 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              function ChartService() {
                                'use strict';
                            
                                // Max. number of items to display on a chart
                                var CHART_LIMIT = 600;
                            Severity: Major
                            Found in app/portainer/services/chartService.js - About 1 day to fix

                              File createServiceController.js has 560 lines of code (exceeds 250 allowed). Consider refactoring.
                              Open

                              import _ from 'lodash-es';
                              
                              import * as envVarsUtils from '@/react/components/form-components/EnvironmentVariablesFieldset/utils';
                              import { PorImageRegistryModel } from 'Docker/models/porImageRegistry';
                              import { AccessControlFormData } from '../../../../portainer/components/accessControlForm/porAccessControlFormModel';
                              Severity: Major
                              Found in app/docker/views/services/create/createServiceController.js - About 1 day to fix

                                Function kubeServicesValidation has 232 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                export function kubeServicesValidation(
                                  validationData?: AppServicesValidationData
                                ): SchemaOf<ServiceFormValues[]> {
                                  return array(
                                    object({

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

                                  func (handler *Handler) endpointUpdate(w http.ResponseWriter, r *http.Request) *httperror.HandlerError {
                                      endpointID, err := request.RetrieveNumericRouteVariableValue(r, "id")
                                      if err != nil {
                                          return httperror.BadRequest("Invalid environment identifier route variable", err)
                                      }
                                  Severity: Minor
                                  Found in api/http/handler/endpoints/endpoint_update.go - About 1 day 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

                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language