portainer/portainer

View on GitHub

Showing 1,516 of 3,440 total issues

Avoid too many return statements within this function.
Open

        return 0;

    Avoid too many return statements within this function.
    Open

          return $state.target('portainer.home');
    Severity: Major
    Found in app/portainer/authorization-guard.ts - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

              return undefined;
      Severity: Major
      Found in app/portainer/authorization-guard.ts - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

            return $state.target('portainer.home');
        Severity: Major
        Found in app/portainer/authorization-guard.ts - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

            return undefined;
          Severity: Major
          Found in app/portainer/authorization-guard.ts - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                  return $state.target('portainer.home');
            Severity: Major
            Found in app/portainer/authorization-guard.ts - About 30 mins to fix

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

              func (handler *Handler) createEndpointGroup(tx dataservices.DataStoreTx, payload endpointGroupCreatePayload) (*portainer.EndpointGroup, error) {
                  endpointGroup := &portainer.EndpointGroup{
                      Name:               payload.Name,
                      Description:        payload.Description,
                      UserAccessPolicies: portainer.UserAccessPolicies{},
              Severity: Minor
              Found in api/http/handler/endpointgroups/endpointgroup_create.go - About 25 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 Handler.stackAssociate has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring.
              Open

              func (handler *Handler) stackAssociate(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_associate.go - About 25 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 Handler.stackStop has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring.
              Open

              func (handler *Handler) stackStop(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_stop.go - About 25 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 Handler.addAndPersistEdgeJob has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring.
              Open

              func (handler *Handler) addAndPersistEdgeJob(tx dataservices.DataStoreTx, edgeJob *portainer.EdgeJob, file []byte, endpointsFromGroups []portainer.EndpointID) error {
                  edgeCronExpression := strings.Split(edgeJob.CronExpression, " ")
                  if len(edgeCronExpression) == 6 {
                      edgeCronExpression = edgeCronExpression[1:]
                  }
              Severity: Minor
              Found in api/http/handler/edgejobs/edgejob_create.go - About 25 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 AuthorizedResourceControlUpdate has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring.
              Open

              func AuthorizedResourceControlUpdate(resourceControl *portainer.ResourceControl, context *RestrictedRequestContext) bool {
                  if context.IsAdmin || resourceControl.Public {
                      return true
                  }
              
              
              Severity: Minor
              Found in api/http/security/authorization.go - About 25 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 PostInitMigrator.MigrateGPUs has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring.
              Open

              func (migrator *PostInitMigrator) MigrateGPUs(e portainer.Endpoint, dockerClient *client.Client) error {
                  return migrator.dataStore.UpdateTx(func(tx dataservices.DataStoreTx) error {
                      environment, err := tx.Endpoint().Endpoint(e.ID)
                      if err != nil {
                          log.Error().Err(err).Msgf("Error getting environment %d", environment.ID)
              Severity: Minor
              Found in api/datastore/postinit/migrate_post_init.go - About 25 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 EdgeJobService has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              function EdgeJobService(EdgeJobs, EdgeJobResults, FileUploadService) {
                var service = {};
              
                service.edgeJob = edgeJob;
                async function edgeJob(edgeJobId) {
              Severity: Minor
              Found in app/edge/services/edge-job.js - About 25 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 6 (exceeds 5 allowed). Consider refactoring.
              Open

                async onInit() {
                  this.state = {
                    activeTab: this.LocalStorage.getActiveTab('applications'),
                    currentName: this.$state.$current.name,
                    isAdmin: this.Authentication.isAdmin(),
              Severity: Minor
              Found in app/kubernetes/views/applications/applicationsController.js - About 25 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 ContainerServiceFactory has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              function ContainerServiceFactory($q, Container, $timeout) {
                const service = {
                  killContainer,
                  pauseContainer,
                  renameContainer,
              Severity: Minor
              Found in app/docker/services/containerService.js - About 25 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 KubernetesIngressService has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              export function KubernetesIngressService($async, KubernetesIngresses) {
                return {
                  get,
                  create,
                  patch,
              Severity: Minor
              Found in app/kubernetes/ingress/service.js - About 25 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 updateApplicationAsync has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                async updateApplicationAsync(ingressesToUpdate) {
                  if (ingressesToUpdate.length) {
                    try {
                      await Promise.all(ingressesToUpdate.map((ing) => updateIngress(this.endpoint.Id, ing)));
                      this.Notifications.success('Success', `Ingress ${ingressesToUpdate.length > 1 ? 'rules' : 'rule'} successfully updated`);
              Severity: Minor
              Found in app/kubernetes/views/applications/create/createApplicationController.js - About 25 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 ImageDetailsViewModel has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              export function ImageDetailsViewModel(data) {
                this.Id = data.Id;
                this.Tag = data.Tag;
                this.Parent = data.Parent;
                this.Repository = data.Repository;
              Severity: Minor
              Found in app/docker/models/imageDetails.js - About 25 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 SecretHelperFactory has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                function SecretHelperFactory() {
                  'use strict';
                  return {
                    flattenSecret: function (secret) {
                      if (secret) {
              Severity: Minor
              Found in app/docker/helpers/secretHelper.js - About 25 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 ingressClassesToFormValues has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                static ingressClassesToFormValues(ics, ingresses) {
                  const res = _.map(ics, (ic) => {
                    const fv = new KubernetesResourcePoolIngressClassFormValue(ic);
                    const ingress = _.find(ingresses, { Name: ic.Name });
                    if (ingress) {
              Severity: Minor
              Found in app/kubernetes/ingress/converter.js - About 25 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