portainer/portainer

View on GitHub

Showing 3,440 of 3,440 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

func (kcl *KubeClient) UpdateService(namespace string, info models.K8sServiceInfo) error {
    ServiceClient := kcl.cli.CoreV1().Services(namespace)
    var service v1.Service

    service.Name = info.Name
Severity: Major
Found in api/kubernetes/cli/service.go and 1 other location - About 6 hrs to fix
api/kubernetes/cli/service.go on lines 71..107

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 454.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        } else if (method === 'repository') {
          var repositoryOptions = {
            AdditionalFiles: $scope.formValues.AdditionalFiles,
            RepositoryURL: $scope.formValues.RepositoryURL,
            RepositoryReferenceName: $scope.formValues.RepositoryReferenceName,
Severity: Major
Found in app/portainer/views/stacks/create/createStackController.js and 1 other location - About 6 hrs to fix
app/portainer/views/stacks/create/createStackController.js on lines 174..188

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 163.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        if (method === 'repository') {
          var repositoryOptions = {
            AdditionalFiles: $scope.formValues.AdditionalFiles,
            RepositoryURL: $scope.formValues.RepositoryURL,
            RepositoryReferenceName: $scope.formValues.RepositoryReferenceName,
Severity: Major
Found in app/portainer/views/stacks/create/createStackController.js and 1 other location - About 6 hrs to fix
app/portainer/views/stacks/create/createStackController.js on lines 201..215

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 163.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Function createEventDetails has 158 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function createEventDetails(event) {
  var eventAttr = event.Actor.Attributes;
  var details = '';

  var action = event.Action;
Severity: Major
Found in app/docker/models/event.js - About 6 hrs to fix

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

                  <div className="form-group">
                    <div className="col-sm-12">
                      <FormControl label="Device matching rule">
                        <Select
                          value={value.PerDeviceConfigsMatchType}
    app/react/portainer/gitops/RelativePathFieldset/RelativePathFieldset.tsx on lines 239..269

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 161.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

                  <div className="form-group">
                    <div className="col-sm-12">
                      <FormControl label="Group matching rule">
                        <Select
                          value={value.PerDeviceConfigsGroupMatchType}
    app/react/portainer/gitops/RelativePathFieldset/RelativePathFieldset.tsx on lines 206..237

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 161.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Function ContainerHelperFactory has 157 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

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

      Function ItemView has 157 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function ItemView() {
        const {
          params: { id },
        } = useCurrentStateAndParams();
        const { subscriptionId, resourceGroupId, containerGroupId } = parseId(id);
      Severity: Major
      Found in app/react/azure/container-instances/ItemView/ItemView.tsx - About 6 hrs to fix

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

        func (handler *Handler) registryUpdate(w http.ResponseWriter, r *http.Request) *httperror.HandlerError {
            securityContext, err := security.RetrieveRestrictedRequestContext(r)
            if err != nil {
                return httperror.InternalServerError("Unable to retrieve info from request context", err)
            }
        Severity: Minor
        Found in api/http/handler/registries/registry_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

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

          async confirmDeleteAsync(templateId) {
            const confirmed = await confirmDelete('Are you sure that you want to delete this template?');
            if (!confirmed) {
              return;
            }
        app/kubernetes/custom-templates/kube-custom-templates-view/kube-custom-templates-view.controller.js on lines 59..73

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 160.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

            return this.$async(async () => {
              const confirmed = await confirmDelete('Are you sure that you want to delete this template?');
              if (!confirmed) {
                return;
              }
        app/portainer/views/custom-templates/custom-templates-view/customTemplatesViewController.js on lines 254..268

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 160.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        File stackController.js has 426 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import { ResourceControlType } from '@/react/portainer/access-control/types';
        import { AccessControlFormData } from 'Portainer/components/accessControlForm/porAccessControlFormModel';
        import { FeatureId } from '@/react/portainer/feature-flags/enums';
        import { getEnvironments } from '@/react/portainer/environments/environment.service';
        import { StackStatus, StackType } from '@/react/common/stacks/types';
        Severity: Minor
        Found in app/portainer/views/stacks/edit/stackController.js - About 6 hrs to fix

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              service.tasks = function (filters) {
                var deferred = $q.defer();
          
                Task.query({ filters: filters ? filters : {} })
                  .$promise.then(function success(data) {
          Severity: Major
          Found in app/docker/services/taskService.js and 1 other location - About 6 hrs to fix
          app/docker/services/serviceService.js on lines 11..26

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 159.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              service.services = function (filters) {
                var deferred = $q.defer();
          
                Service.query({ filters: filters ? filters : {} })
                  .$promise.then(function success(data) {
          Severity: Major
          Found in app/docker/services/serviceService.js and 1 other location - About 6 hrs to fix
          app/docker/services/taskService.js on lines 26..41

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 159.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Method Handler.endpointUpdate has 179 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

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                res.Requests = _.reduce(
                  containers,
                  (acc, item) => {
                    if (item.resources.requests && item.resources.requests.cpu) {
                      acc.Cpu += KubernetesResourceReservationHelper.parseCPU(item.resources.requests.cpu);
            Severity: Major
            Found in app/kubernetes/converters/application.js and 1 other location - About 6 hrs to fix
            app/kubernetes/converters/application.js on lines 87..99

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 158.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                res.Limits = _.reduce(
                  containers,
                  (acc, item) => {
                    if (item.resources.limits && item.resources.limits.cpu) {
                      acc.Cpu += KubernetesResourceReservationHelper.parseCPU(item.resources.limits.cpu);
            Severity: Major
            Found in app/kubernetes/converters/application.js and 1 other location - About 6 hrs to fix
            app/kubernetes/converters/application.js on lines 105..117

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 158.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Method Store.Export has 178 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func (store *Store) Export(filename string) (err error) {
            
                backup := storeExport{}
            
                if c, err := store.CustomTemplate().ReadAll(); err != nil {
            Severity: Major
            Found in api/datastore/services.go - About 6 hrs to fix

              Function snapshotContainers has a Cognitive Complexity of 55 (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 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

              Function StackServiceFactory has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
              Open

                function StackServiceFactory($q, $async, Stack, StackByName, FileUploadService, StackHelper, ServiceService, ContainerService, SwarmService) {
                  'use strict';
                  var service = {
                    updateGit,
                    updateKubeGit,
              Severity: Minor
              Found in app/portainer/services/api/stackService.js - 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

              Severity
              Category
              Status
              Source
              Language