FarmBot/Farmbot-Web-App

View on GitHub
frontend/tools/index.tsx

Summary

Maintainability
D
2 days
Test Coverage

File index.tsx has 276 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import React from "react";
import { connect } from "react-redux";
import {
  DesignerPanel, DesignerPanelTop, DesignerPanelContent,
} from "../farm_designer/designer_panel";
Severity: Minor
Found in frontend/tools/index.tsx - About 2 hrs to fix

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

      render() {
        const panelName = "tools";
        const hasTools = this.props.tools.length > 0;
        const toolSlotGroups = pointGroupSubset(this.props.groups, "ToolSlot");
        const filteredGroups = toolSlotGroups
    Severity: Major
    Found in frontend/tools/index.tsx - About 2 hrs to fix

      Function ToolSlotInventoryItem has 48 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export const ToolSlotInventoryItem = (props: ToolSlotInventoryItemProps) => {
        const { x, y, z, id, tool_id, gantry_mounted } = props.toolSlot.body;
        const toolName = props.tools
          .filter(tool => tool.body.id == tool_id)[0]?.body.name;
        const navigate = useNavigate();
      Severity: Minor
      Found in frontend/tools/index.tsx - About 1 hr to fix

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

              <div className="row grid-exp-1">
                <label>{this.strings.tools}</label>
                <Link to={Path.tools("add")}>
                  <div className={"fb-button green add-tool-btn"}>
                    <i className="fa fa-plus" title={this.strings.titleText} />
        Severity: Major
        Found in frontend/tools/index.tsx and 1 other location - About 4 hrs to fix
        frontend/tools/index.tsx on lines 94..101

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

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

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

              <div className="row grid-exp-1">
                <label>{this.strings.toolSlots}</label>
                <Link to={Path.toolSlots("add")}>
                  <div className={"fb-button green"}>
                    <i className="fa fa-plus" title={this.strings.addSlot} />
        Severity: Major
        Found in frontend/tools/index.tsx and 1 other location - About 4 hrs to fix
        frontend/tools/index.tsx on lines 118..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 116.

        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

                    <PanelSection isOpen={this.state.groups} panel={Panel.Tools}
                      toggleOpen={this.toggleOpen("groups")}
                      itemCount={toolSlotGroups.length}
                      addNew={() => this.props.dispatch(createGroup({
                        criteria: {
        Severity: Major
        Found in frontend/tools/index.tsx and 1 other location - About 3 hrs to fix
        frontend/weeds/weeds_inventory.tsx on lines 246..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 102.

        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={({ tool_id }) => {
                  this.props.dispatch(edit(this.props.device,
                    { mounted_tool_id: tool_id }));
                  this.props.dispatch(save(this.props.device.uuid));
                }}
        Severity: Major
        Found in frontend/tools/index.tsx and 1 other location - About 1 hr to fix
        frontend/settings/fbos_settings/timezone_row.tsx on lines 23..26

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

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

            const filteredGroups = toolSlotGroups
              .filter(p => p.body.name.toLowerCase()
                .includes(this.state.searchTerm.toLowerCase()));
        Severity: Major
        Found in frontend/tools/index.tsx and 5 other locations - About 1 hr to fix
        frontend/curves/curves_inventory.tsx on lines 90..92
        frontend/plants/plant_inventory.tsx on lines 111..113
        frontend/plants/plant_inventory.tsx on lines 115..117
        frontend/points/point_inventory.tsx on lines 179..181
        frontend/weeds/weeds_inventory.tsx on lines 233..235

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

        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

              <div className="mounted-tool-header">
                <label>{t("mounted tool")}</label>
                <Help text={Content.MOUNTED_TOOL} />
              </div>
        Severity: Major
        Found in frontend/tools/index.tsx and 3 other locations - About 1 hr to fix
        frontend/photos/capture_settings/capture_size_selection.tsx on lines 69..72
        frontend/photos/capture_settings/rotation_setting.tsx on lines 24..27
        frontend/photos/data_management/index.tsx on lines 32..35

        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

          toggleOpen = (category: keyof ToolsState) => () =>
            this.setState({ ...this.state, [category]: !this.state[category] });
        Severity: Major
        Found in frontend/tools/index.tsx and 4 other locations - About 50 mins to fix
        frontend/curves/edit_curve.tsx on lines 99..100
        frontend/farm_designer/move_to.tsx on lines 153..154
        frontend/sequences/panel/preview.tsx on lines 40..41
        frontend/sequences/sequence_editor_middle_active.tsx on lines 456..457

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

                      addNew={() => this.props.dispatch(createGroup({
                        criteria: {
                          ...DEFAULT_CRITERIA,
                          string_eq: { pointer_type: ["ToolSlot"] },
                        },
        Severity: Minor
        Found in frontend/tools/index.tsx and 1 other location - About 40 mins to fix
        frontend/weeds/weeds_inventory.tsx on lines 250..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 49.

        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