portainer/portainer

View on GitHub

Showing 3,384 of 3,384 total issues

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

export function UserTokenModel(data) {
  this.id = data.id;
  this.userId = data.userId;
  this.description = data.description;
  this.prefix = data.prefix;
Severity: Major
Found in app/portainer/models/user.js and 2 other locations - About 3 hrs to fix
app/portainer/models/settings.js on lines 47..54
app/portainer/models/status.js on lines 1..8

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 102.

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 3 locations. Consider refactoring.
Open

export function LDAPSettingsViewModel(data) {
  this.ReaderDN = data.ReaderDN;
  this.Password = data.Password;
  this.URL = data.URL;
  this.SearchSettings = data.SearchSettings;
Severity: Major
Found in app/portainer/models/settings.js and 2 other locations - About 3 hrs to fix
app/portainer/models/status.js on lines 1..8
app/portainer/models/user.js on lines 18..25

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 102.

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

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 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

      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

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

              <FormControl label="Note" inputId="template-note" errors={errors?.Note}>
                <Input
                  name="note"
                  data-cy="custom-templates-note-input"
                  id="template-note"
        app/react/portainer/custom-templates/components/CommonFields.tsx on lines 76..86

        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 101.

        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

              <FormControl label="Logo" inputId="template-logo" errors={errors?.Logo}>
                <Input
                  name="logo"
                  data-cy="custom-templates-logo-input"
                  id="template-logo"
        app/react/portainer/custom-templates/components/CommonFields.tsx on lines 64..74

        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 101.

        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

        func (transport *Transport) createAzureRequestContext(request *http.Request) (*azureRequestContext, error) {
            var err error
        
            tokenData, err := security.RetrieveTokenData(request)
            if err != nil {
        Severity: Major
        Found in api/http/proxy/factory/azure/access_control.go and 1 other location - About 3 hrs to fix
        api/http/proxy/factory/docker/transport.go on lines 731..766

        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 267.

        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

        func (transport *Transport) createOperationContext(request *http.Request) (*restrictedDockerOperationContext, error) {
            var err error
            tokenData, err := security.RetrieveTokenData(request)
            if err != nil {
                return nil, err
        Severity: Major
        Found in api/http/proxy/factory/docker/transport.go and 1 other location - About 3 hrs to fix
        api/http/proxy/factory/azure/access_control.go on lines 13..48

        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 267.

        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.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

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

          export async function getReplicaSetList(
            environmentId: EnvironmentId,
            namespace: string,
            labelSelector?: string
          ) {
          Severity: Major
          Found in app/react/kubernetes/applications/application.service.ts and 1 other location - About 3 hrs to fix
          app/react/kubernetes/applications/application.service.ts on lines 345..366

          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 100.

          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

          export async function getControllerRevisionList(
            environmentId: EnvironmentId,
            namespace: string,
            labelSelector?: string
          ) {
          Severity: Major
          Found in app/react/kubernetes/applications/application.service.ts and 1 other location - About 3 hrs to fix
          app/react/kubernetes/applications/application.service.ts on lines 325..343

          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 100.

          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.stackMigrate has 106 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

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

            Method Handler.fdoConfigureDevice has 105 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func (handler *Handler) fdoConfigureDevice(w http.ResponseWriter, r *http.Request) *httperror.HandlerError {
                guid, err := request.RetrieveRouteVariableValue(r, "guid")
                if err != nil {
                    log.Error().Err(err).Msg("fdoConfigureDevice: request.RetrieveRouteVariableValue()")
            
            
            Severity: Major
            Found in api/http/handler/hostmanagement/fdo/configure.go - About 3 hrs to fix

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

                const queries = useQueries({
                  queries: subscriptions.map((subscription) => ({
                    queryKey: queryKeys.provider(environmentId, subscription.subscriptionId),
              
                    queryFn: async () => {
              Severity: Major
              Found in app/react/azure/queries/useProvider.ts and 1 other location - About 3 hrs to fix
              app/react/azure/queries/useResourceGroups.ts on lines 18..35

              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 99.

              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

                        nodePort: number()
                          .test(
                            'node-port-is-unique-in-service',
                            'Node port is already used in this service.',
                            (nodePort, context) => {
              app/react/kubernetes/applications/CreateView/application-services/kubeServicesValidation.ts on lines 100..208

              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 99.

              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

                return (
                  <Button
                    as={Link}
                    props={{
                      to: 'portainer.endpoints.endpoint.access',
              app/react/portainer/environments/environment-groups/ListView/EnvironmentGroupsDatatable/columns.tsx on lines 23..37

              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 99.

              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

                return (
                  <Button
                    as={Link}
                    props={{
                      to: '.group.access',
              app/react/portainer/environments/ListView/columns/actions.tsx on lines 28..42

              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 99.

              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

              Severity
              Category
              Status
              Source
              Language