portainer/portainer

View on GitHub

Showing 1,519 of 3,462 total issues

Method Migrator.updateVolumeResourceControlToDB32 has 5 return statements (exceeds 4 allowed).
Open

func (m *Migrator) updateVolumeResourceControlToDB32() error {
    log.Info().Msg("updating resource controls")

    endpoints, err := m.endpointService.Endpoints()
    if err != nil {
Severity: Major
Found in api/datastore/migrator/migrate_dbversion31.go - About 35 mins to fix

    Method HandlerDeleteK8sRegistrySecrets.Execute has 5 return statements (exceeds 4 allowed).
    Open

    func (h *HandlerDeleteK8sRegistrySecrets) Execute(pa portainer.PendingAction, endpoint *portainer.Endpoint) error {
        if endpoint == nil || pa.ActionData == nil {
            return nil
        }
    
    
    Severity: Major
    Found in api/pendingactions/handlers/delete_k8s_registry_secrets.go - About 35 mins to fix

      Method Service.ListFiles has 5 return statements (exceeds 4 allowed).
      Open

      func (service *Service) ListFiles(repositoryURL, referenceName, username, password string, dirOnly, hardRefresh bool, includedExts []string, tlsSkipVerify bool) ([]string, error) {
          repoKey := generateCacheKey(repositoryURL, referenceName, username, password, strconv.FormatBool(tlsSkipVerify), strconv.FormatBool(dirOnly))
      
          if service.cacheEnabled && hardRefresh {
              // Should remove the cache explicitly, so that the following normal list can show the correct result
      Severity: Major
      Found in api/git/service.go - About 35 mins to fix

        Method PostInitMigrator.MigrateEnvironment has 5 return statements (exceeds 4 allowed).
        Open

        func (migrator *PostInitMigrator) MigrateEnvironment(environment *portainer.Endpoint) error {
            log.Info().Msgf("Executing post init migration for environment %d", environment.ID)
        
            switch {
            case endpointutils.IsKubernetesEndpoint(environment):
        Severity: Major
        Found in api/datastore/postinit/migrate_post_init.go - About 35 mins to fix

          Function ParseLocalImage has 5 return statements (exceeds 4 allowed).
          Open

          func ParseLocalImage(inspect types.ImageInspect) (*Image, error) {
              if IsLocalImage(inspect) || IsDanglingImage(inspect) {
                  return nil, errors.New("the image is not regular")
              }
          
          
          Severity: Major
          Found in api/docker/images/digest.go - About 35 mins to fix

            Method Store.Import has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
            Open

            func (store *Store) Import(filename string) (err error) {
                backup := storeExport{}
            
                s, err := os.ReadFile(filename)
                if err != nil {
            Severity: Minor
            Found in api/datastore/services.go - About 35 mins 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 ClientFactory.buildEdgeConfig has 5 return statements (exceeds 4 allowed).
            Open

            func (factory *ClientFactory) buildEdgeConfig(endpoint *portainer.Endpoint) (*rest.Config, error) {
                tunnelAddr, err := factory.reverseTunnelService.TunnelAddr(endpoint)
                if err != nil {
                    return nil, errors.Wrap(err, "failed activating tunnel")
                }
            Severity: Major
            Found in api/kubernetes/cli/client.go - About 35 mins to fix

              Function createStatus has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

              export function createStatus(statusText) {
                var status = _.toLower(statusText);
              
                if (status.indexOf('paused') > -1) {
                  return 'paused';
              Severity: Minor
              Found in app/docker/models/container.js - About 35 mins 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 removeStacksActionAsync has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                async removeStacksActionAsync(selectedItems) {
                  let actionCount = selectedItems.length;
                  for (const stack of selectedItems) {
                    try {
                      const isAppFormCreated = stack.Applications.some((x) => !x.ApplicationKind);
              Severity: Minor
              Found in app/kubernetes/views/applications/applicationsController.js - About 35 mins 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 ImageViewModel has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

              export function ImageViewModel(data) {
                this.Id = data.Id;
                this.Tag = data.Tag;
                this.Repository = data.Repository;
                this.Created = data.Created;
              Severity: Minor
              Found in app/docker/models/image.js - About 35 mins 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 updateSliders has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                updateSliders(namespaceWithQuota) {
                  const quota = namespaceWithQuota.Quota;
                  let minCpu = 0,
                    minMemory = 0,
                    maxCpu = this.state.namespaceLimits.cpu,
              Severity: Minor
              Found in app/kubernetes/views/applications/create/createApplicationController.js - About 35 mins 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 createPayload has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                static createPayload(daemonSet) {
                  const payload = new KubernetesDaemonSetCreatePayload();
                  payload.metadata.name = daemonSet.Name;
                  payload.metadata.namespace = daemonSet.Namespace;
                  if (daemonSet.StackName) {
              Severity: Minor
              Found in app/kubernetes/converters/daemonSet.js - About 35 mins 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 _getApplicationApiService has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                _getApplicationApiService(app) {
                  let apiService;
                  if (app.ApplicationType === KubernetesApplicationTypes.Deployment) {
                    apiService = this.KubernetesDeploymentService;
                  } else if (app.ApplicationType === KubernetesApplicationTypes.DaemonSet) {
              Severity: Minor
              Found in app/kubernetes/services/applicationService.js - About 35 mins 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 generatePublishedPortsFormValuesFromPublishedPorts has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                static generatePublishedPortsFormValuesFromPublishedPorts(serviceType, publishedPorts, ingress) {
                  const generatePort = (port, rule) => {
                    const res = new KubernetesApplicationPublishedPortFormValue();
                    res.IsNew = false;
                    if (rule) {
              Severity: Minor
              Found in app/kubernetes/helpers/application/index.js - About 35 mins 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 onInit has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                async onInit() {
                  try {
                    const settings = await this.SettingsService.publicSettings();
                    this.state.showOAuthLogin = settings.AuthenticationMethod === 3;
                    this.state.showStandardLogin = !this.state.showOAuthLogin;
              Severity: Minor
              Found in app/portainer/views/auth/authController.js - About 35 mins 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 react2angular has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

              export function react2angular<T, U extends PropNames<T>[]>(
                Component: React.ComponentType<T & JSX.IntrinsicAttributes>,
                propNames: U & ([PropNames<T>] extends [U[number]] ? unknown : PropNames<T>)
              ): IComponentOptions & { name: string } {
                const bindings = Object.fromEntries(propNames.map((key) => [key, '<']));
              Severity: Minor
              Found in app/react-tools/react2angular.tsx - About 35 mins 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 teamMemberUsers has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                async teamMemberUsers(users, teamMemberships) {
                  if (this.isAdmin) {
                    return users;
                  }
              
              
              Severity: Minor
              Found in app/portainer/rbac/components/access-viewer/access-viewer.controller.js - About 35 mins 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 useCopy has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

              export function useCopy(
                copyText: CopyTextType,
                fadeDelay = 1000,
                context: HTMLElement = document.body
              ) {
              Severity: Minor
              Found in app/react/components/buttons/CopyButton/useCopy.ts - About 35 mins 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 calculatePageNumber has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

              export function calculatePageNumber(
                position: number,
                currentPage: number,
                paginationRange: number,
                totalPages: number
              Severity: Minor
              Found in app/react/components/PaginationControls/calculatePageNumber.ts - About 35 mins 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 FormValidatorFactory has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                function FormValidatorFactory() {
                  'use strict';
              
                  var validator = {};
              
              
              Severity: Minor
              Found in app/portainer/services/formValidator.js - About 35 mins 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