FarmBot/Farmbot-Web-App

View on GitHub

Showing 646 of 1,897 total issues

Function FolderNameEditor has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

export const FolderNameEditor = (props: FolderNodeProps) => {
  const { node } = props;
  const [settingsOpen, setSettingsOpen] = React.useState(false);
  const [hovered, setHovered] = React.useState(false);
  return <div
Severity: Minor
Found in frontend/folders/component.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

Consider simplifying this complex logical expression.
Open

        if (imagePosition) {
          const { width, height, transformOrigin } = imagePosition;
          const transform = this.props.disableTranslation ?
            imagePosition.transform.replace(/translate\(.*?\)/g, "")
            : imagePosition.transform;
Severity: Major
Found in frontend/farm_designer/map/layers/images/map_image.tsx - About 40 mins to fix

    Consider simplifying this complex logical expression.
    Open

          if (i > 0 && previousCoordinate && currentCoordinate && isNumber(cur.water)) {
            const p1 = toQ(currentCoordinate);
            const p2 = toQ(previousCoordinate);
            return <g id={"trail-record"} key={i}>
              <line id={`trail-line-${i}`}
    Severity: Major
    Found in frontend/farm_designer/map/layers/farmbot/bot_trail.tsx - About 40 mins to fix

      Consider simplifying this complex logical expression.
      Open

          if (isUndefined(botPosition0.x)
            || isUndefined(botPosition0.y)
            || isUndefined(botPosition0.z)
            || isUndefined(botPosition1.x)
            || isUndefined(botPosition1.y)
      Severity: Major
      Found in frontend/farm_designer/map/layers/logs/logs_layer.tsx - About 40 mins to fix

        Consider simplifying this complex logical expression.
        Open

          if (activeXYZ && !isUndefined(activeXYZ.x) && !isUndefined(activeXYZ.y)
            && plantXYZ && !isUndefined(plantXYZ.x) && !isUndefined(plantXYZ.y)) {
            // Plant editing (dragging) is occuring
            const activeXY = { x: round(activeXYZ.x), y: round(activeXYZ.y) };
            const distance = Math.sqrt(
        Severity: Major
        Found in frontend/farm_designer/map/layers/spread/spread_overlap_helper.tsx - About 40 mins to fix

          Function variableFormList has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

            resources: ResourceIndex,
            additionalItems: DropDownItem[],
            variableItems?: DropDownItem[],
            displayGroups?: boolean,
            variableType?: VariableType,
          Severity: Minor
          Found in frontend/sequences/locals_list/variable_form_list.ts - About 35 mins to fix

            Function stepPut has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            export function stepPut(value: Step,
              ev: React.DragEvent<HTMLElement>,
              intent: DataXferIntent,
              draggerId: number,
              resourceUuid?: UUID):
            Severity: Minor
            Found in frontend/draggable/actions.ts - About 35 mins to fix

              Function occurrence has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                m: moment.Moment,
                fe: FarmEventWithExecutable,
                timeSettings: TimeSettings,
                resources: ResourceIndex,
                modifiers?: { numHidden?: number, empty?: boolean }):
              Severity: Minor
              Found in frontend/farm_events/calendar/occurrence.ts - About 35 mins to fix

                Method mark_as_seen has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    def mark_as_seen(bot = (current_user && current_user.device))
                      when_farmbot_os do
                        if bot
                          v = fbos_version
                          bot.last_saw_api = Time.now
                Severity: Minor
                Found in app/controllers/api/abstract_controller.rb - About 35 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 emit_nodes has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                def emit_nodes()
                  nodes = NODES.map do |node|
                    tags = node.fetch("tags").sort.uniq
                    # Don't publish internal CeleryScript nodes:
                    next if tags.include?(:private)
                Severity: Minor
                Found in latest_corpus.rb - About 35 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 execute has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    def execute
                      # LEGACY SHIM:
                      #  1. CelerySlicer inserts a `nothing` node at the start of the flat_ast
                      #  2. The new Fragment table expects an ENTRY node at position 0 of the
                      #     flat_ast
                Severity: Minor
                Found in app/mutations/fragments/create.rb - About 35 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 create has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    def create
                      # Around June of 2020, we started getting Rails double
                      # render errors on this endpoint when users would try
                      # to log in with an unverified account (500 error).
                      # Still not sure what changed or why, but this is a
                Severity: Minor
                Found in app/controllers/api/tokens_controller.rb - About 35 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 cameraBtnProps has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                export const cameraBtnProps = (env: UserEnv, botOnline: boolean) => {
                  const disabled = cameraDisabled(env) || !botOnline;
                  const noCameraTitle = t(Content.NO_CAMERA_SELECTED);
                  const offlineTitle = botOnline ? "" : t("FarmBot is offline");
                  const title = cameraDisabled(env) ? noCameraTitle : offlineTitle;
                Severity: Minor
                Found in frontend/photos/capture_settings/camera_selection.tsx - About 35 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 recurse_into_body has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    def recurse_into_body(heap, canonical_list, previous_address, index = 0)
                      if canonical_list[index]
                        is_head = index == 0
                        # BE CAREFUL EDITING THIS LINE, YOU MIGHT BREAK `BODY` NODES:
                        heap # See note above!
                Severity: Minor
                Found in app/lib/celery_script/slicer.rb - About 35 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 setArgsDotPinNumber has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  (x: StepParams) => (d: DropDownItem) => {
                    const { dispatch, currentSequence, index, resources, currentStep } = x;
                
                    dispatch(editStep({
                      step: currentStep,
                Severity: Minor
                Found in frontend/sequences/step_tiles/pin_support/pin_and_peripheral_support.tsx - About 35 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 mapImagePositionData has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                export const mapImagePositionData = (props: MapImagePositionDataProps):
                  MapImagePositionData | undefined => {
                  const { cameraCalibrationData, alreadyRotated, noRotation } = props;
                  const imageRotated = alreadyRotated && !noRotation;
                  const parsed = parseCalibrationData(cameraCalibrationData);
                Severity: Minor
                Found in frontend/farm_designer/map/layers/images/map_image.tsx - About 35 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 createPlant has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                export const createPlant = (props: CreatePlantProps): void => {
                  const {
                    cropName, slug, gardenCoords, gridSize, openedSavedGarden, depth, designer,
                  } = props;
                  const { x, y } = gardenCoords;
                Severity: Minor
                Found in frontend/farm_designer/map/layers/plants/plant_actions.ts - About 35 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 maybeUpdateGroup has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  (props: MaybeUpdateGroupProps) => {
                    const { group } = props;
                    if (props.selectionBox && group) {
                      if (props.editGroupAreaInMap) {
                        props.dispatch(editGtLtCriteria(group, props.selectionBox));
                Severity: Minor
                Found in frontend/farm_designer/map/background/selection_box_actions.ts - About 35 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 TextInRoundedSvgBox has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                export const TextInRoundedSvgBox = (props: RoundedBoxProps) => {
                  const { x, y, width, height, fill, radius } = props;
                  const r = radius || 4;
                  const upperRightCorner = `a${r},${r} 0 0 1 ${r},${r}`;
                  const lowerRightCorner = `a${r},${r} 0 0 1 -${r},${r}`;
                Severity: Minor
                Found in frontend/farm_designer/map/background/grid_labels.tsx - About 35 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 render has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  render() {
                    const { point, getX, soilHeight, getConfigValue, designer } = this.props;
                    const { icon, spreadDiaCm } = this.state;
                    const currentPlantUuid = designer.selectedPoints?.[0];
                    const radius = point.uuid == currentPlantUuid && designer.hoveredSpread
                Severity: Minor
                Found in frontend/farm_designer/map/profile/plants_and_weeds.tsx - About 35 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