FarmBot/Farmbot-Web-App

View on GitHub

Showing 646 of 1,897 total issues

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

      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 getNewTrailArray has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      function getNewTrailArray(
        update: TrailRecord, watering: boolean, readOnly: boolean,
      ): TrailRecord[] {
        const key = VirtualTrail.records; // sessionStorage location
        const trailLength: number = get(sessionStorage, VirtualTrail.length, 100);
      Severity: Minor
      Found in frontend/farm_designer/map/layers/farmbot/bot_trail.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 PointGraphic has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      const PointGraphic = (props: ProfilePointProps) => {
        const { point } = props;
        const { color } = props.point.body.meta;
        switch (point.body.pointer_type) {
          case "ToolSlot":
      Severity: Minor
      Found in frontend/farm_designer/map/profile/content.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 downloadProgress has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      export function downloadProgress(job: JobProgress | undefined) {
        if (job && !isJobDone(job)) {
          switch (job.unit) {
            case "bytes":
              const kiloBytes = Math.round(job.bytes / 1024);
      Severity: Minor
      Found in frontend/settings/fbos_settings/os_update_button.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 getCurrentPanel has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      export const getCurrentPanel = (): Tabs | undefined => {
        if (Path.equals(Path.designer())) {
          return Panel.Map;
        } else if (Path.getSlug(Path.app()) == "sequences") {
          return Panel.Sequences;
      Severity: Minor
      Found in frontend/farm_designer/panel_header.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 Bot has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      export const Bot = (props: FarmbotModelProps) => {
        const config = props.config;
        const {
          x, y, z, botSizeX, botSizeY, botSizeZ, beamLength, trail, laser, soilHeight,
          bedXOffset, bedYOffset, bedLengthOuter, bedWidthOuter, tracks, zDimension,
      Severity: Minor
      Found in frontend/three_d_garden/bot.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 parseColClassNames has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      export function parseColClassNames(props: ParseColClassNamesProps, base?: string) {
      
        const classNames: string[] = [];
        if (base) { classNames.push(base); }
      
      
      Severity: Minor
      Found in frontend/ui/util.ts - 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 render has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        render() {
          const { urlTourSlug, urlTourStepSlug } = this.tourState;
      
          this.updateStateAndUrl();
      
      
      Severity: Minor
      Found in frontend/help/tours/index.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 PinBindingsList has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      export const PinBindingsList = (props: PinBindingsListProps) => {
        const { pinBindings, resources, dispatch } = props;
      
        const deleteBinding = (pin: number, uuid?: string) => {
          if (!sysBtnBindings.includes(pin)) {
      Severity: Minor
      Found in frontend/settings/pin_bindings/pin_bindings_list.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 dropDown2CeleryArg has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        (ri: ResourceIndex, item: DropDownItem): number | NamedPin => {
          if (isString(item.value)) { // str means "Named Pin". num means "Raw Pin"
            if (Object.values(BoxLed).map((x: string) => x).includes(item.value)) {
              return {
                kind: "named_pin",
      Severity: Minor
      Found in frontend/sequences/step_tiles/pin_support/pin_and_peripheral_support.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

      Method provide_feedback has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def provide_feedback(message, slug = "Not provided")
          webhook_url = ENV["FEEDBACK_WEBHOOK_URL"]
          if webhook_url
            email = self.users.pluck(:email).join(" ")
            name = self.users.first.name
      Severity: Minor
      Found in app/models/device.rb - 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

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

      export const SequenceBtnGroup = ({
        dispatch,
        sequence,
        syncStatus,
        resources,
      Severity: Minor
      Found in frontend/sequences/sequence_editor_middle_active.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

      Method topic_action has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def topic_action # Called during subscribe
            # Example JSON:
            #   "name"        => "amq.topic",
            #   "permission"  => "read",
            #   "resource"    => "topic",
      Severity: Minor
      Found in app/controllers/api/rmq_utils_controller.rb - 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

      Method check_arity has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def check_arity(node)
            allowed = corpus.args(node)
            allowed.map do |arg|
              has_key = node.args.has_key?(arg) || node.args.has_key?(arg.to_s)
              unless has_key
      Severity: Minor
      Found in app/lib/celery_script/checker.rb - 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

      Severity
      Category
      Status
      Source
      Language