FarmBot/Farmbot-Web-App

View on GitHub

Showing 646 of 1,897 total issues

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 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
      # 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 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

        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 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 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 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 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 Promo has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export const Promo = () => {
                    const [config, setConfig] = React.useState<Config>(INITIAL);
                    const [toolTip, setToolTip] = React.useState<ToolTip>({ timeoutId: 0, text: "" });
                    const [activeFocus, setActiveFocus] = React.useState("");
                    const common = {
                  Severity: Minor
                  Found in frontend/promo/promo.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 PowerAndResetMenu has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      export const PowerAndResetMenu = (props: PowerAndResetMenuProps) => {
                        const { botOnline } = props;
                        return <div className={"power-and-reset-menu"}>
                          <FbosButtonRow
                            botOnline={botOnline}
                      Severity: Minor
                      Found in frontend/controls/move/jog_buttons.tsx - About 1 hr to fix

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

                        const YAxis = (props: YAxisProps) => {
                          const { data } = props.curve.body;
                          const { normY, xMax } = props.plotTools;
                          const thirds = maxValue(data) / 3;
                          const yStep = floor(thirds, 1 - ("" + floor(thirds)).length);
                        Severity: Minor
                        Found in frontend/curves/chart.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

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

                              (resources: ResourceIndex, sequenceUuid: UUID): DropDownItem[] => {
                                const deviceId = maybeGetDevice(resources)?.body.id || 0;
                                const points = selectAllPoints(resources).filter(p => !!p.body.id);
                                const mapPoints = points.filter(p => p.body.pointer_type == "GenericPointer");
                                const weeds = points.filter(p => p.body.pointer_type == "Weed");
                            Severity: Minor
                            Found in frontend/sequences/step_tiles/tile_mark_as/resource_selection.tsx - About 1 hr to fix

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

                                render() {
                                  const H_AVG = this.props.invertHue
                                    ? 0
                                    : ((this.props.h[1] * 2 + this.props.h[0] * 2) / 2);
                                  /** 💥💥💥SURPRISING CODE AHEAD:
                              Severity: Minor
                              Found in frontend/photos/image_workspace/farmbot_picker.tsx - About 1 hr to fix

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

                                export const sanitizeNodes = (thisSequence: Sequence): SanitizationResult => {
                                  // Collect all *declared* variables.
                                  const declared: Dictionary<ScopeDeclarationBodyItem> = {};
                                  (thisSequence.args.locals.body || []).map(variable =>
                                    declared[variable.args.label] = variable);
                                Severity: Minor
                                Found in frontend/sequences/locals_list/sanitize_nodes.ts - About 1 hr to fix

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

                                  export const BoolConfig = (props: BoolConfigProps) => {
                                    const value = !!props.wdEnvGet(props.configKey);
                                    return <Highlight settingName={props.settingName}
                                      hidden={props.advanced && !(props.showAdvanced || props.modified)}
                                      className={props.advanced ? "advanced" : undefined}
                                  Severity: Minor
                                  Found in frontend/photos/camera_calibration/config.tsx - About 1 hr to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language