FarmBot/Farmbot-Web-App

View on GitHub
frontend/settings/hardware_settings/motors.tsx

Summary

Maintainability
F
6 days
Test Coverage

Function Motors has 213 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function Motors(props: MotorsProps) {
  const {
    dispatch, settingsPanelState, sourceFwConfig, firmwareHardware, arduinoBusy,
    showAdvanced,
  } = props;
Severity: Major
Found in frontend/settings/hardware_settings/motors.tsx - About 1 day to fix

    File motors.tsx has 277 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import React from "react";
    import { BooleanMCUInputGroup } from "./boolean_mcu_input_group";
    import { ToolTips, DeviceSetting } from "../../constants";
    import { settingToggle } from "../../devices/actions";
    import { NumericMCUInputGroup } from "./numeric_mcu_input_group";
    Severity: Minor
    Found in frontend/settings/hardware_settings/motors.tsx - About 2 hrs to fix

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

            <Highlight settingName={DeviceSetting.minimumSpeedTowardHome}>
              <Row className="z-setting-grid">
                <div>
                  <label>
                    {t(DeviceSetting.minimumSpeedTowardHome)}
      Severity: Major
      Found in frontend/settings/hardware_settings/motors.tsx and 2 other locations - About 5 hrs to fix
      frontend/settings/hardware_settings/motors.tsx on lines 75..90
      frontend/settings/hardware_settings/motors.tsx on lines 135..150

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

      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

            <Highlight settingName={DeviceSetting.accelerateForTowardHome}>
              <Row className="z-setting-grid">
                <div>
                  <label>
                    {t(DeviceSetting.accelerateForTowardHome)}
      Severity: Major
      Found in frontend/settings/hardware_settings/motors.tsx and 2 other locations - About 5 hrs to fix
      frontend/settings/hardware_settings/motors.tsx on lines 75..90
      frontend/settings/hardware_settings/motors.tsx on lines 110..125

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

      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

            <Highlight settingName={DeviceSetting.maxSpeedTowardHome}>
              <Row className="z-setting-grid">
                <div>
                  <label>
                    {t(DeviceSetting.maxSpeedTowardHome)}
      Severity: Major
      Found in frontend/settings/hardware_settings/motors.tsx and 2 other locations - About 5 hrs to fix
      frontend/settings/hardware_settings/motors.tsx on lines 110..125
      frontend/settings/hardware_settings/motors.tsx on lines 135..150

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

      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

            <SingleSettingRow settingType="button"
              label={DeviceSetting.enable2ndXMotor}
              advanced={true}
              showAdvanced={showAdvanced}
              modified={
      Severity: Major
      Found in frontend/settings/hardware_settings/motors.tsx and 1 other location - About 2 hrs to fix
      frontend/settings/hardware_settings/motors.tsx on lines 225..249

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

      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

            <SingleSettingRow settingType="button"
              label={DeviceSetting.invert2ndXMotor}
              advanced={true}
              showAdvanced={showAdvanced}
              modified={
      Severity: Major
      Found in frontend/settings/hardware_settings/motors.tsx and 1 other location - About 2 hrs to fix
      frontend/settings/hardware_settings/motors.tsx on lines 201..224

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

      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

            <NumericMCUInputGroup {...commonProps}
              label={DeviceSetting.homingSpeed}
              tooltip={ToolTips.HOME_SPEED}
              advanced={true}
              x={"movement_home_spd_x"}
      Severity: Major
      Found in frontend/settings/hardware_settings/motors.tsx and 1 other location - About 2 hrs to fix
      frontend/settings/hardware_settings/error_handling.tsx on lines 95..104

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

      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

            <NumericMCUInputGroup {...commonProps}
              label={DeviceSetting.accelerateFor}
              tooltip={ToolTips.ACCELERATE_FOR}
              x={"movement_steps_acc_dec_x"}
              y={"movement_steps_acc_dec_y"}
      Severity: Major
      Found in frontend/settings/hardware_settings/motors.tsx and 2 other locations - About 2 hrs to fix
      frontend/settings/hardware_settings/motors.tsx on lines 66..74
      frontend/settings/hardware_settings/motors.tsx on lines 101..109

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

      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

            <NumericMCUInputGroup {...commonProps}
              label={DeviceSetting.maxSpeed}
              tooltip={ToolTips.MAX_SPEED}
              x={"movement_max_spd_x"}
              y={"movement_max_spd_y"}
      Severity: Major
      Found in frontend/settings/hardware_settings/motors.tsx and 2 other locations - About 2 hrs to fix
      frontend/settings/hardware_settings/motors.tsx on lines 101..109
      frontend/settings/hardware_settings/motors.tsx on lines 126..134

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

      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

            <NumericMCUInputGroup {...commonProps}
              label={DeviceSetting.minimumSpeed}
              tooltip={ToolTips.MIN_SPEED}
              x={"movement_min_spd_x"}
              y={"movement_min_spd_y"}
      Severity: Major
      Found in frontend/settings/hardware_settings/motors.tsx and 2 other locations - About 2 hrs to fix
      frontend/settings/hardware_settings/motors.tsx on lines 66..74
      frontend/settings/hardware_settings/motors.tsx on lines 126..134

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

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

              <BooleanMCUInputGroup {...commonProps}
                label={DeviceSetting.quietMode}
                tooltip={ToolTips.QUIET_MODE}
                advanced={true}
                x={"movement_axis_stealth_x"}
      Severity: Major
      Found in frontend/settings/hardware_settings/motors.tsx and 4 other locations - About 1 hr to fix
      frontend/settings/hardware_settings/axis_settings.tsx on lines 102..108
      frontend/settings/hardware_settings/axis_settings.tsx on lines 118..124
      frontend/settings/hardware_settings/error_handling.tsx on lines 75..81
      frontend/settings/hardware_settings/error_handling.tsx on lines 88..94

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

      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

            <BooleanMCUInputGroup {...commonProps}
              label={DeviceSetting.alwaysPowerMotors}
              tooltip={ToolTips.ALWAYS_POWER_MOTORS}
              x={"movement_keep_active_x"}
              y={"movement_keep_active_y"}
      Severity: Major
      Found in frontend/settings/hardware_settings/motors.tsx and 3 other locations - About 55 mins to fix
      frontend/settings/hardware_settings/error_handling.tsx on lines 82..87
      frontend/settings/hardware_settings/limit_switches.tsx on lines 50..55
      frontend/settings/hardware_settings/motors.tsx on lines 176..181

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

      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

            <BooleanMCUInputGroup {...commonProps}
              label={DeviceSetting.invertMotors}
              tooltip={ToolTips.INVERT_MOTORS}
              x={"movement_invert_motor_x"}
              y={"movement_invert_motor_y"}
      Severity: Major
      Found in frontend/settings/hardware_settings/motors.tsx and 3 other locations - About 55 mins to fix
      frontend/settings/hardware_settings/error_handling.tsx on lines 82..87
      frontend/settings/hardware_settings/limit_switches.tsx on lines 50..55
      frontend/settings/hardware_settings/motors.tsx on lines 170..175

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

      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

        y: !!sourceFwConfig("movement_axis_stealth_y").value &&
          sourceFwConfig("movement_microsteps_y").value != 1
          ? t(ToolTips.MICROSTEP_WARNING)
          : undefined,
      Severity: Minor
      Found in frontend/settings/hardware_settings/motors.tsx and 2 other locations - About 35 mins to fix
      frontend/settings/hardware_settings/motors.tsx on lines 255..258
      frontend/settings/hardware_settings/motors.tsx on lines 263..266

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

      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

        x: !!sourceFwConfig("movement_axis_stealth_x").value &&
          sourceFwConfig("movement_microsteps_x").value != 1
          ? t(ToolTips.MICROSTEP_WARNING)
          : undefined,
      Severity: Minor
      Found in frontend/settings/hardware_settings/motors.tsx and 2 other locations - About 35 mins to fix
      frontend/settings/hardware_settings/motors.tsx on lines 259..262
      frontend/settings/hardware_settings/motors.tsx on lines 263..266

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

      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

        z: !!sourceFwConfig("movement_axis_stealth_z").value &&
          sourceFwConfig("movement_microsteps_z").value != 1
          ? t(ToolTips.MICROSTEP_WARNING)
          : undefined,
      Severity: Minor
      Found in frontend/settings/hardware_settings/motors.tsx and 2 other locations - About 35 mins to fix
      frontend/settings/hardware_settings/motors.tsx on lines 255..258
      frontend/settings/hardware_settings/motors.tsx on lines 259..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 47.

      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