FarmBot/Farmbot-Web-App

View on GitHub
frontend/tools/index.tsx

Summary

Maintainability
D
3 days
Test Coverage

File index.tsx has 280 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 53 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 51 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;
        return <div
      Severity: Major
      Found in frontend/tools/index.tsx - About 2 hrs to fix

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

              <div className="tools-header">
                <label>{this.strings.tools}</label>
                <Link to={Path.tools("add")}>
                  <div className={`fb-button panel-${TAB_COLOR[Panel.Tools]} 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 95..102

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

        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="tool-slots-header">
                <label>{this.strings.toolSlots}</label>
                <Link to={Path.toolSlots("add")}>
                  <div className={`fb-button panel-${TAB_COLOR[Panel.Tools]}`}>
                    <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 119..126

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

        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 244..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 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 84..86
        frontend/plants/plant_inventory.tsx on lines 107..109
        frontend/plants/plant_inventory.tsx on lines 111..113
        frontend/points/point_inventory.tsx on lines 175..177
        frontend/weeds/weeds_inventory.tsx on lines 230..232

        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 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 164..165
        frontend/sequences/panel/preview.tsx on lines 40..41
        frontend/sequences/sequence_editor_middle_active.tsx on lines 458..459

        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 248..253

        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