portainer/portainer

View on GitHub

Showing 1,519 of 3,462 total issues

File NonGitStackForm.tsx has 385 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { Form, Formik, useFormikContext } from 'formik';
import { useState, useEffect } from 'react';
import { array, boolean, number, object, SchemaOf, string } from 'yup';
import { useRouter } from '@uirouter/react';
import _ from 'lodash';

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

    func (handler *Handler) deleteEndpoint(tx dataservices.DataStoreTx, endpointID portainer.EndpointID, deleteCluster bool) error {
        endpoint, err := tx.Endpoint().Endpoint(portainer.EndpointID(endpointID))
        if tx.IsErrObjectNotFound(err) {
            return httperror.NotFound("Unable to find an environment with the specified identifier inside the database", err)
        } else if err != nil {
    Severity: Minor
    Found in api/http/handler/endpoints/endpoint_delete.go - About 5 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 snapshotContainers has a Cognitive Complexity of 49 (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 5 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 LocalStorageFactory has 126 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      function LocalStorageFactory(localStorageService) {
        return {
          storeLoginStateUUID: function (uuid) {
            localStorageService.set('LOGIN_STATE_UUID', uuid);
          },
    Severity: Major
    Found in app/portainer/services/localStorage.js - About 5 hrs to fix

      Function CreateForm has 126 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function CreateForm() {
        const environmentId = useEnvironmentId();
        const router = useRouter();
        const isWindows = useIsWindows(environmentId);
        const { trackEvent } = useAnalytics();
      Severity: Major
      Found in app/react/docker/containers/CreateView/CreateView.tsx - About 5 hrs to fix

        testDatastore has 38 methods (exceeds 20 allowed). Consider refactoring.
        Open

        type testDatastore struct {
            customTemplate          dataservices.CustomTemplateService
            edgeGroup               dataservices.EdgeGroupService
            edgeJob                 dataservices.EdgeJobService
            edgeStack               dataservices.EdgeStackService
        Severity: Minor
        Found in api/internal/testhelpers/datastore.go - About 5 hrs to fix

          File applicationService.js has 374 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import _ from 'lodash-es';
          import angular from 'angular';
          import PortainerError from 'Portainer/error';
          
          import { KubernetesApplicationDeploymentTypes, KubernetesApplicationTypes } from 'Kubernetes/models/application/models/appConstants';
          Severity: Minor
          Found in app/kubernetes/services/applicationService.js - About 5 hrs to fix

            Function AuthenticationFactory has 122 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              function AuthenticationFactory($async, $state, Auth, OAuth, LocalStorage, StateManager, EndpointProvider, ThemeManager) {
                'use strict';
            
                var user = {};
                if (process.env.NODE_ENV === 'development') {
            Severity: Major
            Found in app/portainer/services/authentication.js - About 4 hrs to fix

              File index.ts has 366 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import angular from 'angular';
              
              import { r2a } from '@/react-tools/react2angular';
              import { IngressClassDatatableAngular } from '@/react/kubernetes/cluster/ingressClass/IngressClassDatatable/IngressClassDatatableAngular';
              import { NamespacesSelector } from '@/react/kubernetes/cluster/RegistryAccessView/NamespacesSelector';
              Severity: Minor
              Found in app/kubernetes/react/components/index.ts - About 4 hrs to fix

                Function $onInit has 119 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  $onInit() {
                    return this.$async(async () => {
                      try {
                        this.endpoint = await this.EndpointService.endpoint(this.endpoint.Id);
                        await this.StateManager.updateEndpointState(this.endpoint);

                  Function getUpdatedApplicationResources has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
                  Open

                  export function getUpdatedApplicationResources(oldFormValues, newFormValues) {
                    const resources = [];
                  
                    const [oldApp, oldHeadlessService, oldServices, oldService, oldClaims] = KubernetesApplicationConverter.applicationFormValuesToApplication(oldFormValues);
                    const [newApp, newHeadlessService, newServices, newService, newClaims] = KubernetesApplicationConverter.applicationFormValuesToApplication(newFormValues);
                  Severity: Minor
                  Found in app/kubernetes/views/summary/resources/applicationResources.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 isConfigurationFormValid has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
                  Open

                  export function isConfigurationFormValid(alreadyExist, isDataValid, formValues) {
                    const uniqueCheck = !alreadyExist && isDataValid;
                    let secretWarningMessage = '';
                    let isFormValid = false;
                  
                  
                  Severity: Minor
                  Found in app/kubernetes/views/configurations/validation.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 UserService has 118 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export function UserService($q, Users, TeamService, TeamMembershipService) {
                    'use strict';
                    var service = {};
                  
                    service.users = async function (includeAdministrators, environmentId) {
                  Severity: Major
                  Found in app/portainer/services/api/userService.js - About 4 hrs to fix

                    Method Store.initServices has 142 lines of code (exceeds 50 allowed). Consider refactoring.
                    Open

                    func (store *Store) initServices() error {
                        authorizationsetService, err := role.NewService(store.connection)
                        if err != nil {
                            return err
                        }
                    Severity: Major
                    Found in api/datastore/services.go - About 4 hrs to fix

                      Consider simplifying this complex logical expression.
                      Open

                                if (
                                  (matchExpression.operator === 'Exists' && exists) ||
                                  (matchExpression.operator === 'DoesNotExist' && !exists) ||
                                  (matchExpression.operator === 'In' && isIn) ||
                                  (matchExpression.operator === 'NotIn' && !isIn) ||

                        File EnvironmentList.tsx has 358 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        import { ReactNode, useEffect, useState } from 'react';
                        import { HardDrive, RefreshCcw } from 'lucide-react';
                        import _ from 'lodash';
                        import { useStore } from 'zustand';
                        
                        
                        Severity: Minor
                        Found in app/react/portainer/HomeView/EnvironmentList/EnvironmentList.tsx - About 4 hrs to fix

                          Function ServiceHelperFactory has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
                          Open

                            function ServiceHelperFactory() {
                              'use strict';
                          
                              var helper = {};
                          
                          
                          Severity: Minor
                          Found in app/docker/helpers/serviceHelper.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 ApplicationDetailsWidget has 113 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

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

                            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();
                            
                            

                              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
                                Severity
                                Category
                                Status
                                Source
                                Language