FarmBot/Farmbot-Web-App

View on GitHub
frontend/settings/pin_bindings/box_top_gpio_diagram.tsx

Summary

Maintainability
D
1 day
Test Coverage

Function render has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  render() {
    const {
      firmwareHardware, botOnline, resources, dispatch, bot,
    } = this.props;
    const { locked, sync_status } = bot.hardware.informational_settings;
Severity: Major
Found in frontend/settings/pin_bindings/box_top_gpio_diagram.tsx - About 2 hrs to fix

    Function CIRCLES has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    const CIRCLES = ({ firmwareHardware, clean }: CirclesProps) => [
      ...(hasExtraButtons(firmwareHardware)
        ? [{ cx: 20, cy: 20, r: 7, pin: 20, label: t("Button 5"), color: Color.white }]
        : []),
      ...(hasExtraButtons(firmwareHardware)
    Severity: Minor
    Found in frontend/settings/pin_bindings/box_top_gpio_diagram.tsx - About 1 hr 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 Button has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    const Button = (props: ButtonProps) => {
      const { pin, color, cx, cy, r } = props;
      const hovered = props.hovered && !props.bound;
      return <g id={"button"} style={{ cursor: "pointer" }}
        onMouseEnter={props.hover(pin)}
    Severity: Minor
    Found in frontend/settings/pin_bindings/box_top_gpio_diagram.tsx - About 45 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

      ...(hasExtraButtons(firmwareHardware) || !clean
        ? [{ cx: 70, cy: 38, r: 4, pin: 0, label: t("Connection"), color: Color.blue }]
        : []),
    Severity: Major
    Found in frontend/settings/pin_bindings/box_top_gpio_diagram.tsx and 2 other locations - About 1 hr to fix
    frontend/settings/pin_bindings/box_top_gpio_diagram.tsx on lines 37..39
    frontend/settings/pin_bindings/box_top_gpio_diagram.tsx on lines 50..52

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

    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

      ...(hasExtraButtons(firmwareHardware) || !clean
        ? [{ cx: 90, cy: 38, r: 4, pin: 0, label: t("Sync LED"), color: Color.green }]
        : []),
    Severity: Major
    Found in frontend/settings/pin_bindings/box_top_gpio_diagram.tsx and 2 other locations - About 1 hr to fix
    frontend/settings/pin_bindings/box_top_gpio_diagram.tsx on lines 37..39
    frontend/settings/pin_bindings/box_top_gpio_diagram.tsx on lines 47..49

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

    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

      ...(hasExtraButtons(firmwareHardware) || !clean
        ? [{ cx: 80, cy: 20, r: 7, pin: 22, label: t("Button 2"), color: Color.yellow }]
        : []),
    Severity: Major
    Found in frontend/settings/pin_bindings/box_top_gpio_diagram.tsx and 2 other locations - About 1 hr to fix
    frontend/settings/pin_bindings/box_top_gpio_diagram.tsx on lines 47..49
    frontend/settings/pin_bindings/box_top_gpio_diagram.tsx on lines 50..52

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

    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

      ...(hasExtraButtons(firmwareHardware)
        ? [{ cx: 30, cy: 38, r: 4, pin: 0, label: t("LED 4"), color: Color.white }]
        : []),
    Severity: Major
    Found in frontend/settings/pin_bindings/box_top_gpio_diagram.tsx and 4 other locations - About 1 hr to fix
    frontend/settings/pin_bindings/box_top_gpio_diagram.tsx on lines 28..30
    frontend/settings/pin_bindings/box_top_gpio_diagram.tsx on lines 31..33
    frontend/settings/pin_bindings/box_top_gpio_diagram.tsx on lines 34..36
    frontend/settings/pin_bindings/box_top_gpio_diagram.tsx on lines 44..46

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

    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

      ...(hasExtraButtons(firmwareHardware)
        ? [{ cx: 20, cy: 20, r: 7, pin: 20, label: t("Button 5"), color: Color.white }]
        : []),
    Severity: Major
    Found in frontend/settings/pin_bindings/box_top_gpio_diagram.tsx and 4 other locations - About 1 hr to fix
    frontend/settings/pin_bindings/box_top_gpio_diagram.tsx on lines 31..33
    frontend/settings/pin_bindings/box_top_gpio_diagram.tsx on lines 34..36
    frontend/settings/pin_bindings/box_top_gpio_diagram.tsx on lines 41..43
    frontend/settings/pin_bindings/box_top_gpio_diagram.tsx on lines 44..46

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

    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

      ...(hasExtraButtons(firmwareHardware)
        ? [{ cx: 60, cy: 20, r: 7, pin: 26, label: t("Button 3"), color: Color.white }]
        : []),
    Severity: Major
    Found in frontend/settings/pin_bindings/box_top_gpio_diagram.tsx and 4 other locations - About 1 hr to fix
    frontend/settings/pin_bindings/box_top_gpio_diagram.tsx on lines 28..30
    frontend/settings/pin_bindings/box_top_gpio_diagram.tsx on lines 31..33
    frontend/settings/pin_bindings/box_top_gpio_diagram.tsx on lines 41..43
    frontend/settings/pin_bindings/box_top_gpio_diagram.tsx on lines 44..46

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

    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

      ...(hasExtraButtons(firmwareHardware)
        ? [{ cx: 50, cy: 38, r: 4, pin: 0, label: t("LED 3"), color: Color.white }]
        : []),
    Severity: Major
    Found in frontend/settings/pin_bindings/box_top_gpio_diagram.tsx and 4 other locations - About 1 hr to fix
    frontend/settings/pin_bindings/box_top_gpio_diagram.tsx on lines 28..30
    frontend/settings/pin_bindings/box_top_gpio_diagram.tsx on lines 31..33
    frontend/settings/pin_bindings/box_top_gpio_diagram.tsx on lines 34..36
    frontend/settings/pin_bindings/box_top_gpio_diagram.tsx on lines 41..43

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

    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

      ...(hasExtraButtons(firmwareHardware)
        ? [{ cx: 40, cy: 20, r: 7, pin: 5, label: t("Button 4"), color: Color.white }]
        : []),
    Severity: Major
    Found in frontend/settings/pin_bindings/box_top_gpio_diagram.tsx and 4 other locations - About 1 hr to fix
    frontend/settings/pin_bindings/box_top_gpio_diagram.tsx on lines 28..30
    frontend/settings/pin_bindings/box_top_gpio_diagram.tsx on lines 34..36
    frontend/settings/pin_bindings/box_top_gpio_diagram.tsx on lines 41..43
    frontend/settings/pin_bindings/box_top_gpio_diagram.tsx on lines 44..46

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

    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

      return <svg id={"box-top-gpio"}
        width={"100%"} height={"100%"} viewBox={"-10 -10 20 20"}
        style={{ maxHeight: "100px", maxWidth: "100px" }}>
        <g id={"button"}>
          <circle className={props.blinking ? "fast-blink" : ""}
    Severity: Major
    Found in frontend/settings/pin_bindings/box_top_gpio_diagram.tsx and 2 other locations - About 50 mins to fix
    frontend/settings/pin_bindings/box_top_gpio_diagram.tsx on lines 105..116
    frontend/settings/pin_bindings/box_top_gpio_diagram.tsx on lines 233..248

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

    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

        return <svg id={"box-top-gpio"}
          width={"100%"} height={"100%"} viewBox={"0 0 120 52"}
          style={{ maxHeight: "300px", maxWidth: "500px" }}>
          {CIRCLES({ firmwareHardware, clean: false }).map(circle =>
            <Button key={circle.cx}
    Severity: Major
    Found in frontend/settings/pin_bindings/box_top_gpio_diagram.tsx and 2 other locations - About 50 mins to fix
    frontend/settings/pin_bindings/box_top_gpio_diagram.tsx on lines 233..248
    frontend/settings/pin_bindings/box_top_gpio_diagram.tsx on lines 259..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 51.

    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

      return <svg id={"box-top-gpio"}
        width={"100%"} height={"100%"} viewBox={"-10 -10 20 20"}
        style={{ maxHeight: "100px", maxWidth: "100px" }}>
        <g id={"button"} style={{ cursor: hasBinding ? "pointer" : "not-allowed" }}
          onMouseEnter={props.hover(pin)}
    Severity: Major
    Found in frontend/settings/pin_bindings/box_top_gpio_diagram.tsx and 2 other locations - About 50 mins to fix
    frontend/settings/pin_bindings/box_top_gpio_diagram.tsx on lines 105..116
    frontend/settings/pin_bindings/box_top_gpio_diagram.tsx on lines 259..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 51.

    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