FarmBot/Farmbot-Web-App

View on GitHub

Showing 646 of 1,897 total issues

Avoid too many return statements within this function.
Open

  return generateFallbackLog("no_logs_to_display",
    t("No logs to display. Visit Logs page to view filters."));
Severity: Major
Found in frontend/nav/ticker_list.tsx - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

          return <div className={"os-download-wizard"}>
            <div className={"os-download-wizard-run"}>
              <p className={"os-download-wizard-note"}>
                {t(SetupWizardContent.RPI)}
              </p>
    Severity: Major
    Found in frontend/os_download/content.tsx - About 30 mins to fix

      Method no_rpi_analog has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.no_rpi_analog(node)
          args = HashWithIndifferentAccess.new(node.args)
          pin_mode = args.fetch(:pin_mode).try(:value) || DIGITAL
          pin_number = args.fetch(:pin_number)
          is_analog = pin_mode == ANALOG
      Severity: Minor
      Found in app/models/celery_script_settings_bag.rb - About 25 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 initialize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def initialize(parent = nil, args:, body: nil, comment: "", kind:, uuid: nil)
            @comment, @kind, @parent = comment, kind, parent
      
            @args = args.map do |key, value|
              [key.to_sym, maybe_initialize(self, value, key)]
      Severity: Minor
      Found in app/lib/celery_script/ast_node.rb - About 25 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 broadcast? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def broadcast?
          return false if self.class.auto_sync_paused
          return false unless current_device
          return false unless (gone? || notable_changes?)
          return true
      Severity: Minor
      Found in app/models/application_record.rb - About 25 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 PhotoButtons has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      export const PhotoButtons = (props: PhotoButtonsProps) => {
        const { imageUrl } = props;
        const { image, dispatch, flags, size } = props;
        const imageShowMenuProps = { dispatch, flags, image, size };
        return <div className={"photo-action-buttons"}>
      Severity: Minor
      Found in frontend/photos/images/photos.tsx - About 25 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 process has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def process(delivery_info, payload)
          params = { routing_key: delivery_info.routing_key, payload: payload }
          m = AmqpTelemetryParser.run!(params)
          device_key = "device_#{m.device_id}"
          THROTTLE_POLICY.track(device_key)
      Severity: Minor
      Found in app/lib/telemetry_service.rb - About 25 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 filterImagesByType has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      export const filterImagesByType = (designer: DesignerState) =>
        (img: TaggedImage | undefined) => {
          const {
            showPhotoImages, showCalibrationImages, showDetectionImages, showHeightImages,
          } = designer;
      Severity: Minor
      Found in frontend/photos/photo_filter_settings/util.ts - About 25 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 setOverwriteFromLocation has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      export const setOverwriteFromLocation = (
        locationSelection: string | undefined,
        overwrite: Record<Xyz, number | string | undefined>,
      ) => {
        const adjustValue = (axis: Xyz) => {
      Severity: Minor
      Found in frontend/sequences/step_tiles/tile_computed_move/location.tsx - About 25 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 process has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def process(delivery_info, payload)
          params = { routing_key: delivery_info.routing_key, payload: payload }
          m = AmqpLogParser.run!(params)
          THROTTLE_POLICY.track(m.device_id)
          m.device.trim_excess_logs if rand(0..TIDY_RATE) == TIDY_RATE
      Severity: Minor
      Found in app/lib/log_service.rb - About 25 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 dropDownName has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      export function dropDownName(name: string, v?: Record<Xyz, number | undefined>,
        gantryMounted = false) {
        let label = name || "untitled";
        if (v) {
          const labelFor = (axis: number | undefined) => isNumber(axis) ? axis : "---";
      Severity: Minor
      Found in frontend/sequences/locals_list/variable_form_list.ts - About 25 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 6 (exceeds 5 allowed). Consider refactoring.
      Open

        render() {
          const { sequence, dispatch } = this.props;
          const items = (sequence.body.body || [])
            .map((currentStep: SequenceBodyItem, index) => {
              /** HACK: React's diff algorithm (probably?) can't keep track of steps
      Severity: Minor
      Found in frontend/sequences/all_steps.tsx - About 25 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_node has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def recurse_into_node(node)
            out = { kind: node.kind, args: recurse_into_args(node) }
            body = get_body_elements(node)
            if body.empty?
              # Legacy sequences *must* have body on sequence. Others are fine.
      Severity: Minor
      Found in app/mutations/sequences/legacy_renderer.rb - About 25 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 cross_check has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def cross_check(corpus, key)
            actual = kind
            allowed = corpus.fetchArg(key).allowed_values
            # It would be safe to run type checking here.
            if (actual == "identifier")
      Severity: Minor
      Found in app/lib/celery_script/ast_node.rb - About 25 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 AddCommandButton has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      export const AddCommandButton = (props: AddCommandButtonProps) => {
        const { index, dispatch, stepCount } = props;
        const getPositionClass = () => {
          switch (index) {
            case 0: return "first";
      Severity: Minor
      Found in frontend/sequences/sequence_editor_middle_active.tsx - About 25 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 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.create(inputs = {})
          inputs[:device] ||= FactoryBot.create(:device, inputs[:device] || {})
          FactoryBot.create(:user, device: inputs[:device]) if inputs[:device].users.empty?
          inputs[:name] ||= Faker::Company.catch_phrase
          inputs[:color] ||= Sequence::COLORS.sample
      Severity: Minor
      Found in spec/fake_sequence.rb - About 25 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 onDrop has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        (dispatch1: Function, sequence: TaggedSequence) =>
          (index: number, key: string) => {
            if (key.length > 0) {
              dispatch1(function (dispatch2: Function) {
                const dataXferObj = dispatch2(stepGet(key));
      Severity: Minor
      Found in frontend/sequences/sequence_editor_middle_active.tsx - About 25 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 readOnlyInterceptor has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      export const readOnlyInterceptor = (config: InternalAxiosRequestConfig) => {
        const method = (config.method || "get").toLowerCase();
        const relevant = ["put", "patch", "delete"].includes(method);
      
        if (relevant && appIsReadonly(store.getState().resources.index)) {
      Severity: Minor
      Found in frontend/read_only_mode/index.tsx - About 25 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 getPanelStatus has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      export const getPanelStatus = (): MapPanelStatus => {
        if (Path.equals(Path.designer())) {
          return isMobile() ? MapPanelStatus.mobileClosed : MapPanelStatus.closed;
        }
        const mode = getMode();
      Severity: Minor
      Found in frontend/farm_designer/map/util.ts - About 25 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 addOrRemoveFromGroup has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        (clickedPlantUuid: UUID, resources: ResourceIndex) =>
          (dispatch: Function) => {
            const group = findGroupFromUrl(selectAllPointGroups(resources));
            const point =
              resources.references[clickedPlantUuid] as TaggedPoint | undefined;
      Severity: Minor
      Found in frontend/farm_designer/map/actions.ts - About 25 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