portainer/portainer

View on GitHub

Showing 1,516 of 3,440 total issues

Function KubernetesResourcePoolService has 100 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function KubernetesResourcePoolService(
  $async,
  EndpointService,
  KubernetesNamespaceService,
  KubernetesResourceQuotaService,
Severity: Major
Found in app/kubernetes/services/resourcePoolService.js - About 4 hrs to fix

    Function buildChanges has 99 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        function buildChanges(service) {
          var config = convertServiceToConfig(service.Model);
          config.Name = service.Name;
          config.Labels = LabelHelper.fromKeyValueToLabelHash(service.ServiceLabels);
          config.TaskTemplate.ContainerSpec.Env = envVarsUtils.convertToArrayOfStrings(service.EnvironmentVariables);
    Severity: Major
    Found in app/docker/views/services/edit/serviceController.js - About 3 hrs to fix

      Function toViewModel has 99 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function toViewModel(portBindings: PortMap): Values {
        const parsedPorts = parsePorts(portBindings);
        const sortedPorts = sortPorts(parsedPorts);
      
        return [

        Function CreateView has 99 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function CreateView() {
          const initialValues = useMemo<FormValues>(
            () => ({
              name: '',
              groupIds: [],

          Function EnvironmentCreationView has 99 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export function EnvironmentCreationView() {
            const {
              params: { localEndpointId: localEndpointIdParam, referrer },
            } = useCurrentStateAndParams();
          
          

            Function getUpdatedApplicationResources has 96 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function getUpdatedApplicationResources(
              newFormValues: ApplicationFormValues,
              oldFormValues: ApplicationFormValues
            ) {
              // app summaries

              Transport has 31 methods (exceeds 20 allowed). Consider refactoring.
              Open

                  Transport struct {
                      HTTPTransport        *http.Transport
                      endpoint             *portainer.Endpoint
                      dataStore            dataservices.DataStore
                      signatureService     portainer.DigitalSignatureService
              Severity: Minor
              Found in api/http/proxy/factory/docker/transport.go - About 3 hrs to fix

                Function ApplicationDetailsView has 95 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export function ApplicationDetailsView() {
                  const stateAndParams = useCurrentStateAndParams();
                  const {
                    params: { namespace, name },
                  } = stateAndParams;

                  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

                    Method PluginWrapper.WaitForStatus has a Cognitive Complexity of 41 (exceeds 20 allowed). Consider refactoring.
                    Open

                    func (wrapper *PluginWrapper) WaitForStatus(ctx context.Context, name string, status libstack.Status) <-chan libstack.WaitResult {
                        waitResultCh := make(chan libstack.WaitResult)
                        waitResult := libstack.WaitResult{
                            Status: status,
                        }
                    Severity: Minor
                    Found in pkg/libstack/compose/internal/composeplugin/status.go - About 3 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 patchAsync has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
                    Open

                      async patchAsync(oldFormValues, newFormValues, originalServicePorts) {
                        const [oldApp, oldHeadlessService, oldServices, , oldClaims] = KubernetesApplicationConverter.applicationFormValuesToApplication(oldFormValues);
                        const [newApp, newHeadlessService, newServices, , newClaims] = KubernetesApplicationConverter.applicationFormValuesToApplication(newFormValues);
                        const oldApiService = this._getApplicationApiService(oldApp);
                        const newApiService = this._getApplicationApiService(newApp);
                    Severity: Minor
                    Found in app/kubernetes/services/applicationService.js - About 3 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 staggerConfigValidation has 93 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    export function staggerConfigValidation(): SchemaOf<StaggerConfig> {
                      return object({
                        StaggerOption: number()
                          .oneOf([StaggerOption.AllAtOnce, StaggerOption.Parallel])
                          .required('Stagger option is required'),
                    Severity: Major
                    Found in app/react/edge/edge-stacks/components/StaggerFieldset.tsx - About 3 hrs to fix

                      File application.js has 321 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      import _ from 'lodash-es';
                      import filesizeParser from 'filesize-parser';
                      
                      import { KubernetesApplicationDataAccessPolicies, KubernetesApplicationDeploymentTypes, KubernetesApplicationTypes } from 'Kubernetes/models/application/models/appConstants';
                      import {
                      Severity: Minor
                      Found in app/kubernetes/converters/application.js - About 3 hrs to fix

                        File containerController.js has 320 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        import moment from 'moment';
                        import _ from 'lodash-es';
                        import { PorImageRegistryModel } from 'Docker/models/porImageRegistry';
                        import { confirmContainerDeletion } from '@/react/docker/containers/common/confirm-container-delete-modal';
                        import { FeatureId } from '@/react/portainer/feature-flags/enums';
                        Severity: Minor
                        Found in app/docker/views/containers/edit/containerController.js - About 3 hrs to fix

                          Function patchAsync has 92 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            async patchAsync(oldFormValues, newFormValues, originalServicePorts) {
                              const [oldApp, oldHeadlessService, oldServices, , oldClaims] = KubernetesApplicationConverter.applicationFormValuesToApplication(oldFormValues);
                              const [newApp, newHeadlessService, newServices, , newClaims] = KubernetesApplicationConverter.applicationFormValuesToApplication(newFormValues);
                              const oldApiService = this._getApplicationApiService(oldApp);
                              const newApiService = this._getApplicationApiService(newApp);
                          Severity: Major
                          Found in app/kubernetes/services/applicationService.js - About 3 hrs to fix

                            Function DeploymentOptionsSection has 92 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            export function DeploymentOptionsSection() {
                              const {
                                values: { globalDeploymentOptions: values },
                                setFieldValue,
                              } = useFormikContext<FormValues>();

                              DbConnection has 30 methods (exceeds 20 allowed). Consider refactoring.
                              Open

                              type DbConnection struct {
                                  Path            string
                                  MaxBatchSize    int
                                  MaxBatchDelay   time.Duration
                                  InitialMmapSize int
                              Severity: Minor
                              Found in api/database/boltdb/db.go - About 3 hrs to fix

                                Method Handler.stackGitRedeploy has 116 lines of code (exceeds 50 allowed). Consider refactoring.
                                Open

                                func (handler *Handler) stackGitRedeploy(w http.ResponseWriter, r *http.Request) *httperror.HandlerError {
                                    stackID, err := request.RetrieveNumericRouteVariableValue(r, "id")
                                    if err != nil {
                                        return httperror.BadRequest("Invalid stack identifier route variable", err)
                                    }
                                Severity: Major
                                Found in api/http/handler/stacks/stack_update_git_redeploy.go - About 3 hrs to fix

                                  File services.go has 568 lines of code (exceeds 500 allowed). Consider refactoring.
                                  Open

                                  package datastore
                                  
                                  import (
                                      "fmt"
                                      "os"
                                  Severity: Minor
                                  Found in api/datastore/services.go - About 3 hrs to fix

                                    File endpointController.js has 318 lines of code (exceeds 250 allowed). Consider refactoring.
                                    Open

                                    import _ from 'lodash-es';
                                    import uuidv4 from 'uuid/v4';
                                    
                                    import { PortainerEndpointTypes } from '@/portainer/models/endpoint/models';
                                    import EndpointHelper from '@/portainer/helpers/endpointHelper';
                                    Severity: Minor
                                    Found in app/portainer/views/endpoints/edit/endpointController.js - About 3 hrs to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language