portainer/portainer

View on GitHub

Showing 1,497 of 3,384 total issues

Function applicationCommon has a Cognitive Complexity of 57 (exceeds 5 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: Minor
Found in app/kubernetes/converters/application.js - 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

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

func (handler *Handler) updateEndpointGroup(tx dataservices.DataStoreTx, endpointGroupID portainer.EndpointGroupID, payload endpointGroupUpdatePayload) (*portainer.EndpointGroup, error) {
    endpointGroup, err := tx.EndpointGroup().Read(portainer.EndpointGroupID(endpointGroupID))
    if tx.IsErrObjectNotFound(err) {
        return nil, httperror.NotFound("Unable to find an environment group with the specified identifier inside the database", err)
    } else if err != nil {
Severity: Minor
Found in api/http/handler/endpointgroups/endpointgroup_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

Function BackupS3Form has 208 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function BackupS3Form() {
  const limitedToBE = isLimitedToBE(FeatureId.S3_BACKUP_SETTING);

  const exportS3Mutate = useExportS3BackupMutation();

    Function SettingsAuthenticationController has 205 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

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

      Function FileUploadFactory has 205 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        function FileUploadFactory($q, Upload, EndpointProvider) {
          'use strict';
      
          var service = {};
      
      
      Severity: Major
      Found in app/portainer/services/fileUpload.js - About 1 day to fix

        Service has 57 methods (exceeds 20 allowed). Consider refactoring.
        Open

        type Service struct {
            dataStorePath string
            fileStorePath string
        }
        Severity: Major
        Found in api/filesystem/filesystem.go - About 1 day to fix

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

          import { ApplicationFormValues } from '../../types';
          
          import { Summary } from './types';
          import { getAppResourceSummaries } from './utils';
          
          

            File filesystem.go has 746 lines of code (exceeds 500 allowed). Consider refactoring.
            Open

            package filesystem
            
            import (
                "bytes"
                "encoding/pem"
            Severity: Minor
            Found in api/filesystem/filesystem.go - About 7 hrs to fix

              File index.js has 485 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import _ from 'lodash-es';
              import { KubernetesPortMapping, KubernetesPortMappingPort } from 'Kubernetes/models/port/models';
              import { KubernetesService, KubernetesServicePort, KubernetesServiceTypes } from 'Kubernetes/models/service/models';
              import { KubernetesConfigurationKinds } from 'Kubernetes/models/configuration/models';
              import {
              Severity: Minor
              Found in app/kubernetes/helpers/application/index.js - About 7 hrs to fix

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

                import featureFlagModule from '@/react/portainer/feature-flags';
                
                import './rbac';
                
                import componentsModule from './components';
                Severity: Minor
                Found in app/portainer/__module.js - About 7 hrs to fix

                  Method Server.Start has 212 lines of code (exceeds 50 allowed). Consider refactoring.
                  Open

                  func (server *Server) Start() error {
                      kubernetesTokenCacheManager := server.KubernetesTokenCacheManager
                  
                      requestBouncer := security.NewRequestBouncer(server.DataStore, server.JWTService, server.APIKeyService)
                  
                  
                  Severity: Major
                  Found in api/http/server.go - About 7 hrs to fix

                    Function StateManagerFactory has 186 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function StateManagerFactory(
                      $async,
                      $q,
                      SystemService,
                      InfoHelper,
                    Severity: Major
                    Found in app/portainer/services/stateManager.js - About 7 hrs to fix

                      Function config has 181 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        .config(function config($stateRegistryProvider) {
                          const edge = {
                            name: 'edge',
                            url: '/edge',
                            parent: 'root',
                      Severity: Major
                      Found in app/edge/__module.js - About 7 hrs to fix

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

                        func (handler *Handler) updateEdgeSchedule(tx dataservices.DataStoreTx, edgeJob *portainer.EdgeJob, payload *edgeJobUpdatePayload) error {
                            if payload.Name != nil {
                                edgeJob.Name = *payload.Name
                            }
                        
                        
                        Severity: Minor
                        Found in api/http/handler/edgejobs/edgejob_update.go - About 7 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 ServiceHelperFactory has 174 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

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

                          Function CreateContainerInstanceForm has 174 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          export function CreateContainerInstanceForm() {
                            const environmentId = useEnvironmentId();
                            const { isPureAdmin } = useCurrentUser();
                          
                            const { providers, subscriptions, resourceGroups, isLoading } =

                            Function ConsoleView has 169 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            export function ConsoleView() {
                              const {
                                params: {
                                  endpointId: environmentId,
                                  container,
                            Severity: Major
                            Found in app/react/kubernetes/applications/ConsoleView/ConsoleView.tsx - About 6 hrs to fix

                              Function buildServer has 188 lines of code (exceeds 50 allowed). Consider refactoring.
                              Open

                              func buildServer(flags *portainer.CLIFlags) portainer.Server {
                                  shutdownCtx, shutdownTrigger := context.WithCancel(context.Background())
                              
                                  if flags.FeatureFlags != nil {
                                      featureflags.Parse(*flags.FeatureFlags, portainer.SupportedFeatureFlags)
                              Severity: Major
                              Found in api/cmd/portainer/main.go - About 6 hrs to fix

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

                                func (handler *Handler) edgeGroupUpdate(w http.ResponseWriter, r *http.Request) *httperror.HandlerError {
                                    edgeGroupID, err := request.RetrieveNumericRouteVariableValue(r, "id")
                                    if err != nil {
                                        return httperror.BadRequest("Invalid Edge group identifier route variable", err)
                                    }
                                Severity: Minor
                                Found in api/http/handler/edgegroups/edgegroup_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

                                Method Handler.endpointUpdate has 183 lines of code (exceeds 50 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: Major
                                Found in api/http/handler/endpoints/endpoint_update.go - About 6 hrs to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language