portainer/portainer

View on GitHub

Showing 3,440 of 3,440 total issues

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

      <FormControl
        inputId="edge_checkin_snapshot"
        label={fieldSettings.snapshot.label}
        tooltip={fieldSettings.snapshot.tooltip}
      >
Severity: Major
Found in app/react/edge/components/EdgeAsyncIntervalsForm.tsx and 2 other locations - About 3 hrs to fix
app/react/edge/components/EdgeAsyncIntervalsForm.tsx on lines 92..105
app/react/edge/components/EdgeAsyncIntervalsForm.tsx on lines 122..135

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

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

        helper.accessor('Image', {
          header: 'Image',
          cell: ({ row: { original: item } }) => (
            <>
              {truncate(item.Image, 64)}
app/react/kubernetes/components/IntegratedAppsDatatable/columns.tsx on lines 13..21
app/react/kubernetes/namespaces/ItemView/columns.tsx on lines 51..61

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

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

  helper.accessor('Image', {
    header: 'Image',
    cell: ({ row: { original: item } }) => (
      <>
        {truncate(item.Image, 64)}
app/react/kubernetes/cluster/NodeView/NodeApplicationsDatatable/columns.tsx on lines 42..52
app/react/kubernetes/namespaces/ItemView/columns.tsx on lines 51..61

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

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

export function useDeleteEdgeGroupsMutation() {
  const queryClient = useQueryClient();
  return useMutation(
    (edgeGroupIds: Array<EdgeGroup['Id']>) =>
      promiseSequence(
app/react/edge/edge-jobs/ListView/useDeleteEdgeJobsMutation.ts on lines 15..27
app/react/edge/edge-stacks/ListView/EdgeStacksDatatable/useDeleteEdgeStacksMutation.ts on lines 15..27
app/react/portainer/registries/ListView/RegistriesDatatable/useDeleteRegistriesMutation.ts on lines 15..27

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

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 Transport.decorateContainerCreationOperation has a Cognitive Complexity of 37 (exceeds 20 allowed). Consider refactoring.
Open

func (transport *Transport) decorateContainerCreationOperation(request *http.Request, resourceIdentifierAttribute string, resourceType portainer.ResourceControlType) (*http.Response, error) {
    type PartialContainer struct {
        HostConfig struct {
            Privileged bool                   `json:"Privileged"`
            PidMode    string                 `json:"PidMode"`
Severity: Minor
Found in api/http/proxy/factory/docker/containers.go - About 3 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function buildServer has a Cognitive Complexity of 37 (exceeds 20 allowed). Consider refactoring.
Open

func buildServer(flags *portainer.CLIFlags) portainer.Server {
    shutdownCtx, shutdownTrigger := context.WithCancel(context.Background())

    if flags.FeatureFlags != nil {
        featureflags.Parse(*flags.FeatureFlags, portainer.SupportedFeatureFlags)
Severity: Minor
Found in api/cmd/portainer/main.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 DbConnection.ExportJSON has a Cognitive Complexity of 37 (exceeds 20 allowed). Consider refactoring.
Open

func (c *DbConnection) ExportJSON(databasePath string, metadata bool) ([]byte, error) {
    log.Debug().Str("databasePath", databasePath).Msg("exportJson")

    connection, err := bolt.Open(databasePath, 0600, &bolt.Options{Timeout: 1 * time.Second, ReadOnly: true})
    if err != nil {
Severity: Minor
Found in api/database/boltdb/export.go - About 3 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function onFileLoadAsync has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

  async onFileLoadAsync(event) {
    // exit if the file is too big
    const maximumFileSizeBytes = 1024 * 1024; // 1MB
    if (event.target.result.byteLength > maximumFileSizeBytes) {
      this.Notifications.error('File size is too big', 'File size is too big', 'Select a file that is 1MB or smaller.');

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 AuthenticationFactory has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

  function AuthenticationFactory($async, $state, Auth, OAuth, LocalStorage, StateManager, EndpointProvider, ThemeManager) {
    'use strict';

    var user = {};
    if (process.env.NODE_ENV === 'development') {
Severity: Minor
Found in app/portainer/services/authentication.js - About 3 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function getAnnotationValidation has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

function getAnnotationValidation(): SchemaOf<Annotation> {
  return object({
    Key: string()
      .required('Key is required.')
      .test('is-valid', (value, { createError }) => {
Severity: Minor
Found in app/react/kubernetes/annotations/validation.ts - About 3 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function ApplicationSummaryWidget has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

export function ApplicationSummaryWidget() {
  const stateAndParams = useCurrentStateAndParams();
  const {
    params: {
      namespace,

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 VolumeServiceFactory has 77 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  function VolumeServiceFactory($q, Volume, VolumeHelper) {
    'use strict';
    var service = {};

    service.volumes = function (params) {
Severity: Major
Found in app/docker/services/volumeService.js - About 3 hrs to fix

    Function getApplicationEnvironmentVariables has 77 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function getApplicationEnvironmentVariables(
      app?: Application
    ): ContainerEnvVar[] {
      if (!app) {
        return [];

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

      export function ItemView() {
        const router = useRouter();
        const queryClient = useQueryClient();
      
        const {
      Severity: Major
      Found in app/react/docker/networks/ItemView/ItemView.tsx - About 3 hrs to fix

        File StaggerFieldset.tsx has 294 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import { number, string, object, SchemaOf } from 'yup';
        import { FormikErrors } from 'formik';
        import { useState, useEffect } from 'react';
        
        import { FormSection } from '@@/form-components/FormSection';
        Severity: Minor
        Found in app/react/edge/edge-stacks/components/StaggerFieldset.tsx - About 3 hrs to fix

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

                {isInitFieldVisible && (
                  <div className="form-group">
                    <div className="col-sm-12">
                      <SwitchField
                        labelClass="col-sm-2"
          app/react/docker/containers/CreateView/ResourcesTab/RuntimeSection.tsx on lines 28..40

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

          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

                {allowPrivilegedMode && (
                  <div className="form-group">
                    <div className="col-sm-12">
                      <SwitchField
                        labelClass="col-sm-2"
          app/react/docker/containers/CreateView/ResourcesTab/RuntimeSection.tsx on lines 42..54

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

          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 KubernetesIngressService has 76 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export function KubernetesIngressService($async, KubernetesIngresses) {
            return {
              get,
              create,
              patch,
          Severity: Major
          Found in app/kubernetes/ingress/service.js - About 3 hrs to fix

            Function useColumns has 76 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export function useColumns() {
              const hasAuthQuery = useAuthorizations(
                'K8sResourcePoolsAccessManagementRW',
                undefined,
                true
            Severity: Major
            Found in app/react/kubernetes/namespaces/ListView/columns/useColumns.tsx - About 3 hrs to fix

              StoreTx has 26 methods (exceeds 20 allowed). Consider refactoring.
              Open

              type StoreTx struct {
                  store *Store
                  tx    portainer.Transaction
              }
              Severity: Minor
              Found in api/datastore/services_tx.go - About 3 hrs to fix
                Severity
                Category
                Status
                Source
                Language