portainer/portainer

View on GitHub
app/react/kubernetes/cluster/ConfigureView/ConfigureForm/ConfigureForm.tsx

Summary

Maintainability
D
2 days
Test Coverage

File ConfigureForm.tsx has 413 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { Formik, Form, FormikProps, FormikHelpers } from 'formik';
import { useCallback, useEffect, useMemo } from 'react';
import _ from 'lodash';
import { useTransitionHook } from '@uirouter/react';

    Function ConfigureForm has 46 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function ConfigureForm() {
      const { trackEvent } = useAnalytics();
      const configureClusterMutation = useConfigureClusterMutation();
      // get the initial values
      const { data: environment } = useCurrentEnvironment();

      Function useInitialValues has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function useInitialValues(
        environment?: Environment | null,
        storageClassFormValues?: StorageClassFormValues[],
        ingressClasses?: IngressControllerClassMap[]
      ): ConfigureFormValues | undefined {

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

                  <div className="form-group">
                    <div className="col-sm-12">
                      <SwitchField
                        name="changeWindow.Enabled"
                        data-cy="kubeSetup-changeWindowEnabledToggle"
        app/react/kubernetes/cluster/ConfigureView/ConfigureForm/ConfigureForm.tsx on lines 286..299

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

        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">
                      <SwitchField
                        name="restrictSecrets"
                        data-cy="kubeSetup-restrictSecretsToggle"
        app/react/kubernetes/cluster/ConfigureView/ConfigureForm/ConfigureForm.tsx on lines 249..262

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

        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

                  <div className="form-group">
                    <div className="col-sm-12">
                      <SwitchField
                        name="useLoadBalancer"
                        data-cy="kubeSetup-loadBalancerToggle"
        app/react/kubernetes/cluster/ConfigureView/ConfigureForm/ConfigureForm.tsx on lines 272..285
        app/react/portainer/settings/SettingsView/BackupSettingsView/BackupS3Form.tsx on lines 63..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 90.

        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

                  <div className="form-group">
                    <div className="col-sm-12">
                      <SwitchField
                        name="restrictDefaultNamespace"
                        data-cy="kubeSetup-restrictDefaultNsToggle"
        app/react/kubernetes/cluster/ConfigureView/ConfigureForm/ConfigureForm.tsx on lines 161..174
        app/react/portainer/settings/SettingsView/BackupSettingsView/BackupS3Form.tsx on lines 63..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 90.

        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

                      <TextTip color="blue">
                        <p>
                          Select which storage options will be available for use when
                          deploying applications. Have a look at your storage driver
                          documentation to figure out which access policy to configure
        app/react/kubernetes/applications/components/EditYamlFormSection.tsx on lines 83..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 75.

        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

        There are no issues that match your filters.

        Category
        Status