portainer/portainer

View on GitHub

Showing 1,516 of 3,440 total issues

File ApplicationSummaryWidget.tsx has 316 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { User, Clock, Info } from 'lucide-react';
import moment from 'moment';
import { useEffect, useState } from 'react';
import { Pod } from 'kubernetes-types/core/v1';
import { useCurrentStateAndParams } from '@uirouter/react';

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

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

    Method Handler.updateSettings has 114 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (handler *Handler) updateSettings(tx dataservices.DataStoreTx, payload settingsUpdatePayload) (*portainer.Settings, error) {
        settings, err := tx.Settings().Settings()
        if err != nil {
            return nil, httperror.InternalServerError("Unable to retrieve the settings from the database", err)
        }
    Severity: Major
    Found in api/http/handler/settings/settings_update.go - About 3 hrs to fix

      Method Handler.updateEdgeSchedule has 113 lines of code (exceeds 50 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: Major
      Found in api/http/handler/edgejobs/edgejob_update.go - About 3 hrs to fix

        Function AccessServiceFactory has 87 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          function AccessServiceFactory($q, $async, UserService, TeamService) {
            'use strict';
            return {
              accesses,
              generateAccessPolicies,
        Severity: Major
        Found in app/portainer/services/api/accessService.js - About 3 hrs to fix

          File authorizations.go has 560 lines of code (exceeds 500 allowed). Consider refactoring.
          Open

          package authorization
          
          import (
              portainer "github.com/portainer/portainer/api"
              "github.com/portainer/portainer/api/dataservices"
          Severity: Minor
          Found in api/internal/authorization/authorizations.go - About 3 hrs to fix

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

            func (handler *Handler) updateKubernetesIngressControllersByNamespace(w http.ResponseWriter, r *http.Request) *httperror.HandlerError {
                endpoint, err := middlewares.FetchEndpoint(r)
                if err != nil {
                    return httperror.NotFound("Unable to find an environment on request context", err)
                }
            Severity: Minor
            Found in api/http/handler/kubernetes/ingresses.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 ContainerStatsViewModel has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
            Open

            export function ContainerStatsViewModel(data) {
              this.read = data.read;
              this.preread = data.preread;
              if (data.memory_stats.privateworkingset !== undefined) {
                // Windows
            Severity: Minor
            Found in app/docker/models/container.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 AccessServiceFactory has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
            Open

              function AccessServiceFactory($q, $async, UserService, TeamService) {
                'use strict';
                return {
                  accesses,
                  generateAccessPolicies,
            Severity: Minor
            Found in app/portainer/services/api/accessService.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 DeploymentSyncOptions has 85 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export function DeploymentSyncOptions() {
              const settingsQuery = useSettings();
              const settingsMutation = useUpdateSettingsMutation();
              const [formKey, resetForm] = useReducer((state) => state + 1, 0);
            
            

              Function HomeView has 85 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export function HomeView() {
                const localEnvironmentAdded = useConnectLocalEnvironment();
                const { trackEvent } = useAnalytics();
                return (
                  <>
              Severity: Major
              Found in app/react/portainer/environments/wizard/HomeView/HomeView.tsx - About 3 hrs to fix

                Method Handler.stackUpdateGit has 109 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

                func (handler *Handler) stackUpdateGit(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.go - About 3 hrs to fix

                  Function PublishingExplaination has 84 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export function PublishingExplaination() {
                    return (
                      <FormSection title="Explanation" isFoldable titleSize="sm">
                        <div className="mb-4 flex flex-col items-start lg:flex-row">
                          <img

                    Store has 28 methods (exceeds 20 allowed). Consider refactoring.
                    Open

                    type Store struct {
                        connection portainer.Connection
                    
                        fileService               portainer.FileService
                        CustomTemplateService     *customtemplate.Service
                    Severity: Minor
                    Found in api/datastore/services.go - About 3 hrs to fix

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

                      function config($stateRegistryProvider: StateRegistry) {
                        $stateRegistryProvider.register({
                          name: 'docker.containers',
                          url: '/containers',
                          views: {
                      Severity: Major
                      Found in app/docker/react/views/containers.ts - About 3 hrs to fix

                        Function CreateNamespaceForm has 83 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        export function CreateNamespaceForm() {
                          const router = useRouter();
                          const environmentId = useEnvironmentId();
                          const { data: environment, ...environmentQuery } = useCurrentEnvironment();
                          const resourceLimitsQuery = useClusterResourceLimitsQuery(environmentId);
                        Severity: Major
                        Found in app/react/kubernetes/namespaces/CreateView/CreateNamespaceForm.tsx - About 3 hrs to fix

                          File useCreateMutation.tsx has 304 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          import { useMutation, useQueryClient } from '@tanstack/react-query';
                          
                          import axios, { parseAxiosError } from '@/portainer/services/axios';
                          import {
                            Environment,
                          Severity: Minor
                          Found in app/react/docker/containers/CreateView/useCreateMutation.tsx - About 3 hrs to fix

                            Method Handler.deleteEndpoint has 107 lines of code (exceeds 50 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: Major
                            Found in api/http/handler/endpoints/endpoint_delete.go - About 3 hrs to fix

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

                              func (handler *Handler) updateRelations(w http.ResponseWriter, r *http.Request) *httperror.HandlerError {
                              
                                  payload, err := request.GetPayload[endpointUpdateRelationsPayload](r)
                                  if err != nil {
                                      return httperror.BadRequest("Invalid request payload", err)
                              Severity: Minor
                              Found in api/http/handler/endpoints/endpoint_update_relations.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

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

                              func (handler *Handler) stackUpdateGit(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: Minor
                              Found in api/http/handler/stacks/stack_update_git.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

                              Severity
                              Category
                              Status
                              Source
                              Language