portainer/portainer

View on GitHub

Showing 1,516 of 3,440 total issues

Function constructor has 113 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  constructor(data: Service & { Portainer?: PortainerMetadata }) {
    this.Model = data;
    this.Id = data.ID || '';
    this.Tasks = [];
    this.Name = data.Spec?.Name || '';
Severity: Major
Found in app/docker/models/service.ts - About 4 hrs to fix

    Function SSLSettingsPanel has 113 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function SSLSettingsPanel() {
      const settingsQuery = useSSLSettings();
      const [reloadingPage, setReloadingPage] = useState(false);
      const mutation = useUpdateSSLConfigMutation();
    
    

      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

        File application.service.ts has 354 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import {
          DaemonSetList,
          StatefulSetList,
          DeploymentList,
          Deployment,
        Severity: Minor
        Found in app/react/kubernetes/applications/application.service.ts - About 4 hrs to fix

          Function ImageServiceFactory has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
          Open

            function ImageServiceFactory($q, Image, ImageHelper, RegistryService, HttpRequestHelper, ContainerService, FileUploadService) {
              'use strict';
              var service = {};
          
              service.image = function (imageId) {
          Severity: Minor
          Found in app/docker/services/imageService.js - About 4 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 ImportDeviceController has 108 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              function ImportDeviceController($async, $q, $scope, $state, EndpointService, GroupService, TagService, Notifications, Authentication, FileUploadService) {
                $scope.state = {
                  actionInProgress: false,
                  vouchersUploading: false,
                  vouchersUploaded: false,
          Severity: Major
          Found in app/portainer/views/devices/import/importDeviceController.js - About 4 hrs to fix

            Function DefaultEndpointAuthorizationsForEndpointAdministratorRole has 132 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func DefaultEndpointAuthorizationsForEndpointAdministratorRole() portainer.Authorizations {
                return map[portainer.Authorization]bool{
                    portainer.OperationDockerContainerArchiveInfo:         true,
                    portainer.OperationDockerContainerList:                true,
                    portainer.OperationDockerContainerExport:              true,
            Severity: Major
            Found in api/internal/authorization/authorizations.go - About 4 hrs to fix

              Function constructor has 107 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                constructor(
                  $scope,
                  $async,
                  $state,
                  $timeout,

                File application.queries.ts has 345 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import { UseQueryResult, useMutation, useQuery } from '@tanstack/react-query';
                import { Pod } from 'kubernetes-types/core/v1';
                
                import { queryClient, withError } from '@/react-tools/react-query';
                import { EnvironmentId } from '@/react/portainer/environments/types';
                Severity: Minor
                Found in app/react/kubernetes/applications/application.queries.ts - About 4 hrs to fix

                  File deployController.js has 344 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  import angular from 'angular';
                  import _ from 'lodash-es';
                  import stripAnsi from 'strip-ansi';
                  
                  import PortainerError from '@/portainer/error';
                  Severity: Minor
                  Found in app/kubernetes/views/deploy/deployController.js - About 4 hrs to fix

                    Method ClientFactory.MigrateEndpointIngresses has a Cognitive Complexity of 44 (exceeds 20 allowed). Consider refactoring.
                    Open

                    func (factory *ClientFactory) MigrateEndpointIngresses(e *portainer.Endpoint, datastore dataservices.DataStore, cli *KubeClient) error {
                        return datastore.UpdateTx(func(tx dataservices.DataStoreTx) error {
                            environment, err := tx.Endpoint().Endpoint(e.ID)
                            if err != nil {
                                log.Error().Err(err).Msgf("Error retrieving environment %d", e.ID)
                    Severity: Minor
                    Found in api/kubernetes/cli/client.go - About 4 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 initView has 106 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        function initView() {
                          var apiVersion = $scope.applicationState.endpoint.apiVersion;
                          var agentProxy = $scope.applicationState.endpoint.mode.agentProxy;
                    
                          var service = null;
                    Severity: Major
                    Found in app/docker/views/services/edit/serviceController.js - About 4 hrs to fix

                      File transport.go has 593 lines of code (exceeds 500 allowed). Consider refactoring.
                      Open

                      package docker
                      
                      import (
                          "bytes"
                          "encoding/base64"
                      Severity: Minor
                      Found in api/http/proxy/factory/docker/transport.go - About 4 hrs to fix

                        File resourcePoolController.js has 342 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        import angular from 'angular';
                        import _ from 'lodash-es';
                        import filesizeParser from 'filesize-parser';
                        import { KubernetesResourceQuotaDefaults } from 'Kubernetes/models/resource-quota/models';
                        import KubernetesResourceReservationHelper from 'Kubernetes/helpers/resourceReservationHelper';
                        Severity: Minor
                        Found in app/kubernetes/views/resource-pools/edit/resourcePoolController.js - About 4 hrs to fix

                          File utils.ts has 342 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          import { Ingress } from '@/react/kubernetes/ingresses/types';
                          
                          import { ServiceFormValues } from '../../CreateView/application-services/types';
                          import { ApplicationFormValues } from '../../types';
                          import {

                            Function NotificationsMenu has 105 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            export function NotificationsMenu() {
                              const notificationsStoreState = useStore(notificationsStore);
                              const { removeNotification } = notificationsStoreState;
                              const { clearUserNotifications } = notificationsStoreState;
                            
                            
                            Severity: Major
                            Found in app/react/components/PageHeader/NotificationsMenu.tsx - About 4 hrs to fix

                              Function IngressDatatable has 103 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              export function IngressDatatable() {
                                const tableState = useTableState(settingsStore, storageKey);
                                const environmentId = useEnvironmentId();
                              
                                const { authorized: canAccessSystemResources } = useAuthorizations(
                              Severity: Major
                              Found in app/react/kubernetes/ingresses/IngressDatatable/IngressDatatable.tsx - About 4 hrs to fix

                                Function BuildImageController has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
                                Open

                                function BuildImageController($scope, $async, $window, BuildService, Notifications, HttpRequestHelper, endpoint) {
                                  $scope.endpoint = endpoint;
                                  $scope.options = [editor, upload, url];
                                
                                  $scope.state = {
                                Severity: Minor
                                Found in app/docker/views/images/build/buildImageController.js - About 4 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 constructor has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
                                Open

                                  constructor(data: Service & { Portainer?: PortainerMetadata }) {
                                    this.Model = data;
                                    this.Id = data.ID || '';
                                    this.Tasks = [];
                                    this.Name = data.Spec?.Name || '';
                                Severity: Minor
                                Found in app/docker/models/service.ts - About 4 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 DefaultEndpointAuthorizationsForStandardUserRole has 127 lines of code (exceeds 50 allowed). Consider refactoring.
                                Open

                                func DefaultEndpointAuthorizationsForStandardUserRole(volumeBrowsingAuthorizations bool) portainer.Authorizations {
                                    authorizations := map[portainer.Authorization]bool{
                                        portainer.OperationDockerContainerArchiveInfo:         true,
                                        portainer.OperationDockerContainerList:                true,
                                        portainer.OperationDockerContainerExport:              true,
                                Severity: Major
                                Found in api/internal/authorization/authorizations.go - About 4 hrs to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language