FarmBot/Farmbot-Web-App

View on GitHub
frontend/wizard/checks.tsx

Summary

Maintainability
F
3 days
Test Coverage

File checks.tsx has 749 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import React from "react";
import { TakePhotoButton } from "../controls/move/take_photo_button";
import { mapStateToProps } from "../controls/state_to_props";
import { store } from "../redux/store";
import { MoveControls } from "../controls/move/move_controls";
Severity: Major
Found in frontend/wizard/checks.tsx - About 1 day to fix

    Function CameraCheckBase has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const CameraCheckBase = (props: CameraCheckBaseProps) => {
      const images = selectAllImages(props.resources);
      const getLastImageId = () => last(images)?.body.id;
      const [prevImageId, setPrevImageId] = React.useState(getLastImageId());
      const newImageUrls = images
    Severity: Minor
    Found in frontend/wizard/checks.tsx - About 1 hr to fix

      Function CameraCheckBase has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      const CameraCheckBase = (props: CameraCheckBaseProps) => {
        const images = selectAllImages(props.resources);
        const getLastImageId = () => last(images)?.body.id;
        const [prevImageId, setPrevImageId] = React.useState(getLastImageId());
        const newImageUrls = images
      Severity: Minor
      Found in frontend/wizard/checks.tsx - About 25 mins 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 3 locations. Consider refactoring.
      Open

      export const SwapJogButton = (props: WizardOutcomeComponentProps) =>
        <fieldset>
          <label>
            {t("Swap jog buttons: x and y axes")}
          </label>
      Severity: Major
      Found in frontend/wizard/checks.tsx and 2 other locations - About 3 hrs to fix
      frontend/wizard/checks.tsx on lines 551..559
      frontend/wizard/checks.tsx on lines 561..570

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

      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 const DynamicMapToggle = (props: WizardOutcomeComponentProps) =>
        <fieldset>
          <label>
            {t("Dynamic map size")}
          </label>
      Severity: Major
      Found in frontend/wizard/checks.tsx and 2 other locations - About 3 hrs to fix
      frontend/wizard/checks.tsx on lines 541..549
      frontend/wizard/checks.tsx on lines 551..559

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

      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 const RotateMapToggle = (props: WizardOutcomeComponentProps) =>
        <fieldset>
          <label>
            {t("Rotate map")}
          </label>
      Severity: Major
      Found in frontend/wizard/checks.tsx and 2 other locations - About 3 hrs to fix
      frontend/wizard/checks.tsx on lines 541..549
      frontend/wizard/checks.tsx on lines 561..570

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

      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

          onCommit={e => {
            props.dispatch(edit(
              user,
              { language: e.currentTarget.value }));
            props.dispatch(save(user.uuid));
      Severity: Major
      Found in frontend/wizard/checks.tsx and 2 other locations - About 1 hr to fix
      frontend/saved_gardens/garden_edit.tsx on lines 140..145
      frontend/zones/edit_zone.tsx on lines 54..57

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

      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 const MapOrientation = (props: WizardOutcomeComponentProps) =>
        <div className={"map-orientation"}>
          <RotateMapToggle {...props} />
          <SelectMapOrigin {...props} />
        </div>;
      Severity: Major
      Found in frontend/wizard/checks.tsx and 1 other location - About 1 hr to fix
      frontend/photos/images/image_show_menu.tsx on lines 24..28

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

        <a className={"download-imager-link"} href={ExternalUrl.rpiImager}
          target={"_blank"} rel={"noreferrer"}>
          {t("Download Raspberry Pi Imager")}
        </a>;
      Severity: Minor
      Found in frontend/wizard/checks.tsx and 1 other location - About 50 mins to fix
      frontend/help/support.tsx on lines 75..78

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

      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

            saveEnvVar={(key, value) =>
              props.dispatch(saveOrEditFarmwareEnv(props.resources)(
                key, JSON.stringify(formatEnvKey(key, value))))} />;
      Severity: Minor
      Found in frontend/wizard/checks.tsx and 1 other location - About 35 mins to fix
      frontend/wizard/checks.tsx on lines 737..739

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

      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

            onChange={(key, value) =>
              props.dispatch(saveOrEditFarmwareEnv(props.resources)(
                key, JSON.stringify(formatEnvKey(key, value))))}
      Severity: Minor
      Found in frontend/wizard/checks.tsx and 1 other location - About 35 mins to fix
      frontend/wizard/checks.tsx on lines 196..198

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

      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