FarmBot/Farmbot-Web-App

View on GitHub

Showing 646 of 1,897 total issues

Function render has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

  render() {
    const { imageWidth, imageHeight } = this.state;
    const { image, cameraCalibrationData, mapTransformProps, cropImage,
    } = this.props;
    const imageRotation = parse(cameraCalibrationData.rotation) ?? 0;
Severity: Minor
Found in frontend/farm_designer/map/layers/images/map_image.tsx - About 2 hrs 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

File device.rb has 281 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class Device < ApplicationRecord
  DEFAULT_MAX_CONFIGS = 300
  DEFAULT_MAX_IMAGES = 100
  DEFAULT_MAX_LOGS = 1000
  DEFAULT_MAX_TELEMETRY = 300
Severity: Minor
Found in app/models/device.rb - About 2 hrs to fix

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

      render() {
        const { chosenXY } = this;
        const allSoilHeightPoints = this.props.genericPoints.filter(soilHeightPoint);
        const getColorOverride = getSoilHeightColor(allSoilHeightPoints);
        const sensorReadings = this.props.sensorReadings
    Severity: Major
    Found in frontend/farm_designer/location_info.tsx - About 2 hrs to fix

      Function getWarningLinesContent has 68 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        (props: GetWarningLinesContentProps): WarningLinesContent => {
          const { x, y } = props;
          const gantryHeight = props.sourceFbosConfig("gantry_height").value as number;
          const locationSoilHeight = getZAtLocation({
            x,
      Severity: Major
      Found in frontend/curves/chart.tsx - About 2 hrs to fix

        Function RawEditGarden has 67 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export const RawEditGarden = (props: EditGardenProps) => {
          const navigate = useNavigate();
          const [notes, setNotes] = React.useState(props.savedGarden?.body.notes || "");
          const [expand, setExpand] = React.useState(false);
        
        
        Severity: Major
        Found in frontend/saved_gardens/garden_edit.tsx - About 2 hrs to fix

          File motors.tsx has 277 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

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

              render() {
                const panelName = "designer-sequence-editor";
                const { sequence } = this.props;
                return <DesignerPanel panelName={panelName} panel={Panel.Sequences}>
                  <DesignerPanelHeader
            Severity: Major
            Found in frontend/sequences/panel/editor.tsx - About 2 hrs to fix

              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

                File component.tsx has 275 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import React from "react";
                import { StepWrapper } from "../../step_ui";
                import { Row, ExpandableHeader } from "../../../ui";
                import { ToolTips } from "../../../constants";
                import { t } from "../../../i18next_wrapper";
                Severity: Minor
                Found in frontend/sequences/step_tiles/tile_computed_move/component.tsx - About 2 hrs to fix

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

                    render() {
                      const { dispatch, current, stepIndex, resources } = this.props;
                      const commonStepProps = { dispatch, current, index: stepIndex };
                      const click = () => {
                        scrollToBottom("sequenceDiv");
                  Severity: Major
                  Found in frontend/sequences/step_button_cluster.tsx - About 2 hrs to fix

                    File step_button_cluster.tsx has 275 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    import React from "react";
                    import { t } from "../i18next_wrapper";
                    import { StepButton, stepClick } from "./step_buttons";
                    import { equals, scrollToBottom } from "../util";
                    import { Color, SequenceBodyItem, TaggedSequence } from "farmbot";
                    Severity: Minor
                    Found in frontend/sequences/step_button_cluster.tsx - About 2 hrs to fix

                      File bot_figure.tsx has 275 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      import React from "react";
                      import { AxisNumberProperty, MapTransformProps } from "../../interfaces";
                      import { getMapSize, transformXY } from "../../util";
                      import { BotPosition } from "../../../../devices/interfaces";
                      import { Color } from "../../../../ui";
                      Severity: Minor
                      Found in frontend/farm_designer/map/layers/farmbot/bot_figure.tsx - About 2 hrs to fix

                        Function WeedInventoryItem has 65 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        export const WeedInventoryItem = (props: WeedInventoryItemProps) => {
                          const navigate = useNavigate();
                          const weed = props.tpp.body;
                          const { tpp, dispatch } = props;
                          const weedId = (weed.id || "ERR_NO_POINT_ID").toString();
                        Severity: Major
                        Found in frontend/weeds/weed_inventory_item.tsx - About 2 hrs to fix

                          Function RawEditWeed has 65 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          export const RawEditWeed = (props: EditWeedProps) => {
                            const getWeed = () => {
                              const stringyID = Path.getSlug(Path.weeds());
                              if (stringyID) {
                                return props.findPoint(parseInt(stringyID));
                          Severity: Major
                          Found in frontend/weeds/weeds_edit.tsx - About 2 hrs to fix

                            Function emptyState has 65 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            export const emptyState = (): RestResources => {
                              return {
                                consumers: {
                                  sequences: sequenceState,
                                  regimens: regimenState,
                            Severity: Major
                            Found in frontend/resources/reducer.ts - About 2 hrs to fix

                              File subcriteria.tsx has 275 lines of code (exceeds 250 allowed). Consider refactoring.
                              Open

                              import React from "react";
                              import { t } from "../../i18next_wrapper";
                              import { capitalize, uniq, some, isEqual } from "lodash";
                              import {
                                NumberLtGtInput,
                              Severity: Minor
                              Found in frontend/point_groups/criteria/subcriteria.tsx - About 2 hrs to fix

                                Function PointInventoryItem has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                                Open

                                export const PointInventoryItem = (props: PointInventoryItemProps) => {
                                  const navigate = useNavigate();
                                  const point = props.tpp.body;
                                  const color = point.meta.color || "green";
                                  const { tpp, dispatch, hovered, colorOverride } = props;
                                Severity: Minor
                                Found in frontend/points/point_inventory_item.tsx - About 2 hrs 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

                                File other_settings.tsx has 274 lines of code (exceeds 250 allowed). Consider refactoring.
                                Open

                                import React from "react";
                                import { OtherSettingsProps, SettingDescriptionProps } from "./interfaces";
                                import { Highlight } from "./maybe_highlight";
                                import { DeviceSetting, Content, ToolTips } from "../constants";
                                import { Header } from "./hardware_settings/header";
                                Severity: Minor
                                Found in frontend/settings/other_settings.tsx - About 2 hrs to fix

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

                                    render() {
                                      const {
                                        current, selected, dragging, plant, mapTransformProps,
                                        activeDragXY, zoomLvl, animate, editing, hovered, hoveredSpread,
                                      } = this.props;
                                  Severity: Major
                                  Found in frontend/farm_designer/map/layers/plants/garden_plant.tsx - About 2 hrs to fix

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

                                      render() {
                                        return <Highlight className={"section"}
                                          settingName={DeviceSetting.changeOwnership}>
                                          <ExpandableHeader
                                            expanded={this.state.open}
                                    Severity: Major
                                    Found in frontend/settings/transfer_ownership/change_ownership_form.tsx - About 2 hrs to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language