FarmBot/Farmbot-Web-App

View on GitHub

Showing 612 of 1,578 total issues

Function mapStateToProps has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const mapStateToProps = (props: Everything): RegimenEditorProps => {
  const { dispatch } = props;
  const { currentRegimen } = props.resources.consumers.regimens;
  const current = maybeGetRegimen(props.resources.index, currentRegimen);
  const timeSettings = maybeGetTimeSettings(props.resources.index);
Severity: Minor
Found in frontend/regimens/editor/state_to_props.ts - About 1 hr to fix

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

      render() {
        return <DesignerPanel panelName={"farm-event"} panel={Panel.FarmEvents}>
          <DesignerNavTabs />
          <DesignerPanelTop
            panel={Panel.FarmEvents}
    Severity: Minor
    Found in frontend/farm_events/farm_events.tsx - About 1 hr to fix

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

        render() {
          const sensorNameByPinLookup: { [x: number]: string } = {};
          this.props.sensors.map(x => {
            sensorNameByPinLookup[x.body.pin || 0] = x.body.label;
          });
      Severity: Minor
      Found in frontend/sensors/sensor_readings/table.tsx - About 1 hr to fix

        Function TableRow has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export const TableRow = (props: TableRowProps) => {
          const {
            sensorReading, timeSettings, period, sensorName, hover, hovered,
          } = props;
          const { uuid, body } = sensorReading;
        Severity: Minor
        Found in frontend/sensors/sensor_readings/table.tsx - About 1 hr to fix

          Function regimenCalendarAdder has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            (f: FarmEventWithRegimen, c: Calendar, now = moment()) => {
              const { regimen_items } = f.executable;
              const gracePeriod = itemGracePeriod(now);
              const lastRI = last(regimen_items);
              const lastRITime = lastRI &&
          Severity: Minor
          Found in frontend/farm_events/map_state_to_props.ts - About 1 hr to fix

            Function SaveBtn has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export function SaveBtn(props: SaveBtnProps) {
              const CLASS: Record<SpecialStatus, string> = {
                [SpecialStatus.DIRTY]: "is-dirty",
                [SpecialStatus.SAVING]: "is-saving",
                [SpecialStatus.SAVED]: "is-saved",
            Severity: Minor
            Found in frontend/ui/save_button.tsx - About 1 hr to fix

              Function FirmwareNumberSettings has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export const FirmwareNumberSettings = (props: FirmwareNumberSettingsProps) => {
                const sourceFwConfig = sourceFwConfigValue(
                  validFwConfig(getFirmwareConfig(props.resources)),
                  props.bot.hardware.mcu_params);
                return <div className={"motor-settings"}>
              Severity: Minor
              Found in frontend/wizard/step_components.tsx - About 1 hr to fix

                Function AlertCard has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export const AlertCard = (props: AlertCardProps) => {
                  const { alert, timeSettings, findApiAlertById, dispatch } = props;
                  const commonProps = { alert, timeSettings, findApiAlertById, dispatch };
                  switch (alert.problem_tag) {
                    case "farmbot_os.firmware.missing":
                Severity: Minor
                Found in frontend/messages/cards.tsx - About 1 hr to fix

                  Function CameraOffset has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export const CameraOffset = (props: WizardStepComponentProps) => {
                    const helpText = t(ToolTips.CAMERA_OFFSET, {
                      defaultX: WD_KEY_DEFAULTS["CAMERA_CALIBRATION_camera_offset_x"],
                      defaultY: WD_KEY_DEFAULTS["CAMERA_CALIBRATION_camera_offset_y"],
                    });
                  Severity: Minor
                  Found in frontend/wizard/checks.tsx - About 1 hr to fix

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

                      render() {
                        const { cropSearchResults } = this.props.designer;
                        const { result, backgroundURL } =
                          getCropHeaderProps({ cropSearchResults });
                        const panelName = "add-plant";
                    Severity: Minor
                    Found in frontend/plants/add_plant.tsx - About 1 hr to fix

                      Function ToolVerification has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      export const ToolVerification = (props: ToolVerificationProps) => {
                        const toolVerificationSensor =
                          props.sensors.filter(sensor => sensor.body.label.toLowerCase()
                            .includes("tool verification"))[0] as TaggedSensor | undefined;
                        const toolVerificationPin = toolVerificationSensor
                      Severity: Minor
                      Found in frontend/tools/tool_verification.tsx - About 1 hr to fix

                        Function PeripheralList has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            {sortResourcesById(props.peripherals).map(peripheral => {
                              const toggleValue =
                                (props.pins[peripheral.body.pin || -1] || { value: undefined }).value;
                              return <Row key={peripheral.uuid}>
                                <Col xs={6}>
                        Severity: Minor
                        Found in frontend/controls/peripherals/peripheral_list.tsx - About 1 hr to fix

                          Function SubCriteriaSection has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          export const SubCriteriaSection = (props: SubCriteriaSectionProps) => {
                            const { group, dispatch, disabled } = props;
                            const pointTypes = props.pointerTypes.sort();
                            if (pointTypes.length > 1 &&
                              !isEqual(pointTypes, ["GenericPointer", "Weed"])) {
                          Severity: Minor
                          Found in frontend/point_groups/criteria/subcriteria.tsx - About 1 hr to fix

                            Function MotorPositionPlot has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            export const MotorPositionPlot = (props: MotorPositionPlotProps) => {
                              const svgYMin = props.load ? -HEIGHT : -HEIGHT / 2;
                              const yMin = svgYMin - BORDER_WIDTH;
                              const height = props.load ? HEIGHT + BORDERS : HEIGHT + BORDERS;
                              const { load, encoders } = props;
                            Severity: Minor
                            Found in frontend/controls/move/motor_position_plot.tsx - About 1 hr to fix

                              Function getPaths has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              const getPaths = (props: PlotContentProps): Paths => {
                                const last = getLastEntry();
                                const keys = getKeys(props);
                                const maxY = findYLimit(props);
                                const plotY = calcY(props);
                              Severity: Minor
                              Found in frontend/controls/move/motor_position_plot.tsx - About 1 hr to fix

                                Function getLocationState has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                Open

                                export const getLocationState = (step: Move): {
                                  location: LocationNode | undefined,
                                  locationSelection: LocSelection | undefined,
                                } => {
                                  /** Last axis_overwrite where axis_operand is a point, tool, or identifier. */
                                Severity: Minor
                                Found in frontend/sequences/step_tiles/tile_computed_move/location.tsx - About 55 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

                                Function getSelectedField has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                Open

                                const getSelectedField = (
                                  resource: MaybeResourceArg,
                                  field: KnownField | undefined,
                                ): DropDownItem => {
                                  const DDI = UPDATE_RESOURCE_DDIS();
                                Severity: Minor
                                Found in frontend/sequences/step_tiles/tile_mark_as/field_selection.tsx - About 55 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

                                Method check_resource_type has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                Open

                                  def self.check_resource_type(node, resource_type, resource_id, owner)
                                    raise "OPPS!" unless owner
                                    case resource_type # <= Security critical code (for const_get'ing)
                                    when "Device"
                                      # When "resource_type" is "Device", resource_id always refers to
                                Severity: Minor
                                Found in app/models/celery_script_settings_bag.rb - About 55 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

                                Method maybe_continue has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                Open

                                      def maybe_continue(username)
                                        is_guest = (username == FARMBOT_DEMO_USER)
                                        max = is_guest ? MAX_GUEST_COUNT : PER_DEVICE_MAX
                                        key = CACHE_KEY_TPL % username
                                        total = (cache.get(key) || "0").to_i
                                Severity: Minor
                                Found in app/controllers/api/rmq_utils_controller.rb - About 55 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

                                Function DefaultFarmwareStep has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                Open

                                export const DefaultFarmwareStep = (props: StepParams<ExecuteScript>) => {
                                  const {
                                    dispatch, currentStep, index, currentSequence, farmwareData,
                                  } = props;
                                
                                
                                Severity: Minor
                                Found in frontend/sequences/step_tiles/tile_execute_script.tsx - About 55 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

                                Severity
                                Category
                                Status
                                Source
                                Language