FarmBot/Farmbot-Web-App

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

Summary

Maintainability
F
6 days
Test Coverage

Function Motors has 219 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 283 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.accelerateForTowardHome}>
              <Row>
                <Col xs={8} className={"z-param-label"}>
                  <label>
                    {t(DeviceSetting.accelerateForTowardHome)}
      Severity: Major
      Found in frontend/settings/hardware_settings/motors.tsx and 2 other locations - About 7 hrs to fix
      frontend/settings/hardware_settings/motors.tsx on lines 75..92
      frontend/settings/hardware_settings/motors.tsx on lines 112..129

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

      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.minimumSpeedTowardHome}>
              <Row>
                <Col xs={8} className={"z-param-label"}>
                  <label>
                    {t(DeviceSetting.minimumSpeedTowardHome)}
      Severity: Major
      Found in frontend/settings/hardware_settings/motors.tsx and 2 other locations - About 7 hrs to fix
      frontend/settings/hardware_settings/motors.tsx on lines 75..92
      frontend/settings/hardware_settings/motors.tsx on lines 139..156

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

      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>
                <Col xs={8} className={"z-param-label"}>
                  <label>
                    {t(DeviceSetting.maxSpeedTowardHome)}
      Severity: Major
      Found in frontend/settings/hardware_settings/motors.tsx and 2 other locations - About 7 hrs to fix
      frontend/settings/hardware_settings/motors.tsx on lines 112..129
      frontend/settings/hardware_settings/motors.tsx on lines 139..156

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

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

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

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

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

      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 103..111
      frontend/settings/hardware_settings/motors.tsx on lines 130..138

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

      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 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 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 265..268
      frontend/settings/hardware_settings/motors.tsx on lines 269..272

      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

        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 261..264
      frontend/settings/hardware_settings/motors.tsx on lines 269..272

      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 261..264
      frontend/settings/hardware_settings/motors.tsx on lines 265..268

      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