FarmBot/Farmbot-Web-App

View on GitHub

Showing 612 of 1,578 total issues

Function resizeBox has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

export const resizeBox = (props: ResizeSelectionBoxProps) => {
  if (props.selectionBox) {
    const current = props.gardenCoords;
    if (current) {
      const { x0, y0 } = props.selectionBox;
Severity: Minor
Found in frontend/farm_designer/map/background/selection_box_actions.ts - About 1 hr 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 10 (exceeds 5 allowed). Consider refactoring.
Open

  render() {
    const { figureName, position, plantAreaOffset, mapTransformProps,
    } = this.props;
    const { xySwap } = mapTransformProps;
    const mapSize = getMapSize(mapTransformProps, plantAreaOffset);
Severity: Minor
Found in frontend/farm_designer/map/layers/farmbot/bot_figure.tsx - About 1 hr 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 10 (exceeds 5 allowed). Consider refactoring.
Open

  render() {
    const weed = this.props.tpp.body;
    const { tpp, dispatch } = this.props;
    const weedId = (weed.id || "ERR_NO_POINT_ID").toString();
    const scale = this.props.maxSize
Severity: Minor
Found in frontend/weeds/weed_inventory_item.tsx - About 1 hr 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 triggerBinding has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  (resources: ResourceIndex, botOnline: boolean) =>
    (pin: number) =>
      () => {
        const binding = findBinding(resources)(pin);
        if (!botOnline || !binding) { return; }
Severity: Minor
Found in frontend/settings/pin_bindings/actions.ts - About 1 hr 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 CIRCLES has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

const CIRCLES = ({ firmwareHardware, clean }: CirclesProps) => [
  ...(hasExtraButtons(firmwareHardware)
    ? [{ cx: 20, cy: 20, r: 7, pin: 20, label: t("Button 5"), color: Color.white }]
    : []),
  ...(hasExtraButtons(firmwareHardware)
Severity: Minor
Found in frontend/settings/pin_bindings/box_top_gpio_diagram.tsx - About 1 hr 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 toggleEqCriteria has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  <T extends string | number>(
    eqCriteria: EqCriteria<T>,
    direction?: "on" | "off",
  ) => (key: string, value: T) => {
    const values: T[] = eqCriteria[key] || [];
Severity: Minor
Found in frontend/point_groups/criteria/edit.ts - About 1 hr 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 Job has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

const Job = (props: JobProps) => (job: JobProgressWithTitle) => {
  const percent = job.unit == "percent" && job.percent;
  const color = percent == 100 ? Color.green : Color.yellow;
  return <tr key={job.title}>
    <td className={"job-name"} title={job.title}>
Severity: Minor
Found in frontend/devices/jobs.tsx - About 1 hr 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 FolderListItem has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

export const FolderListItem = (props: FolderItemProps) => {
  const { sequence, movedSequenceUuid, inUse } = props;
  const seqName = sequence.body.name;
  const url = Path.sequences(urlFriendly(seqName || ""));
  const moveSource = movedSequenceUuid === sequence.uuid ? "move-source" : "";
Severity: Minor
Found in frontend/folders/component.tsx - About 1 hr 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 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def execute
    klass = Class.new(Mutations::Command)

    klass.instance_variable_set("@resource", resource)

Severity: Minor
Found in app/mutations/create_destroyer.rb - About 1 hr to fix

    Function SequenceSelectBox has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function SequenceSelectBox(props: SequenceSelectBoxProps) {
    
      const sequenceDropDownList = () => {
        const { resources } = props;
        const dropDownList: DropDownItem[] = [];
    Severity: Minor
    Found in frontend/sequences/sequence_select_box.tsx - About 1 hr to fix

      Function ThenElse has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function ThenElse(props: ThenElseParams) {
        const {
          onChange, selectedItem, calledSequenceVariableData, assignVariable
        } = IfBlockDropDownHandler(props);
        const { body } = props.currentStep.args[props.thenElseKey];
      Severity: Minor
      Found in frontend/sequences/step_tiles/tile_if/then_else.tsx - About 1 hr to fix

        Method execute has 27 lines of code (exceeds 25 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 1 hr to fix

          Function getOverwriteState has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export const getOverwriteState = (step: Move, axis: Xyz): {
            selection: AxisSelection | undefined,
            overwrite: string | number | undefined,
          } => {
            const overwrite = step.body?.reverse().find(x =>
          Severity: Minor
          Found in frontend/sequences/step_tiles/tile_computed_move/overwrite.tsx - About 1 hr to fix

            Function FeaturedSequenceListItem has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            const FeaturedSequenceListItem = (props: FeaturedSequenceListItemProps) => {
              const { item } = props;
              const [importing, setImporting] = React.useState(false);
              const [descriptionOpen, setDescriptionOpen] = React.useState(false);
              return <li className={"sequence-list-item"}>
            Severity: Minor
            Found in frontend/sequences/panel/list.tsx - About 1 hr to fix

              Function vacuumFigure has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function vacuumFigure(
                props: { i: number, cx: number, cy: number, animate: boolean }) {
                const { i, cx, cy, animate } = props;
                const color = "black";
                const copies = animate ? 3 : 1;
              Severity: Minor
              Found in frontend/farm_designer/map/layers/farmbot/bot_peripherals.tsx - About 1 hr to fix

                Function rotaryFigure has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function rotaryFigure(
                  props: { i: number, cx: number, cy: number, animate: boolean }) {
                  const { i, cx, cy, animate } = props;
                  const color = "black";
                  const copies = animate ? 3 : 1;
                Severity: Minor
                Found in frontend/farm_designer/map/layers/farmbot/bot_peripherals.tsx - About 1 hr to fix

                  Function FarmwareInfo has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export function FarmwareInfo(props: FarmwareInfoProps) {
                    const { farmware } = props;
                    return farmware
                      ? <div className="farmware-info">
                        <label>{t("Description")}</label>
                  Severity: Minor
                  Found in frontend/farmware/farmware_info.tsx - About 1 hr to fix

                    Function CameraCheckBase has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    const CameraCheckBase = (props: CameraCheckBaseProps) => {
                      const images = selectAllImages(props.resources);
                      const getLastImageId = () => last(images)?.body.id;
                      const [prevImageId, setPrevImageId] = React.useState(getLastImageId());
                      const newImageUrls = images
                    Severity: Minor
                    Found in frontend/wizard/checks.tsx - About 1 hr to fix

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

                        render() {
                          return <Highlight settingName={DeviceSetting.firmware}>
                            <Row>
                              <Col xs={2}>
                                <label>
                      Severity: Minor
                      Found in frontend/settings/firmware/board_type.tsx - About 1 hr to fix

                        Function checkCriteria has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            (point: TaggedPoint, criteriaKey: keyof PointGroupCriteria) => {
                              switch (criteriaKey) {
                                case "string_eq":
                                case "number_eq":
                                  return every(Object.entries(criteria[criteriaKey])
                        Severity: Minor
                        Found in frontend/point_groups/criteria/apply.ts - About 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language