FarmBot/Farmbot-Web-App

View on GitHub

Showing 612 of 1,578 total issues

Function generateTransformStyle has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const generateTransformStyle = (props: GenerateTransformStyleProps) => {
  const { zoomLvl, mapTransformProps } = props;
  const { quadrant, xySwap } = mapTransformProps;

  /** Determine if an axis is displayed vertically on the page. */
Severity: Minor
Found in frontend/farm_designer/map/background/grid_labels.tsx - About 1 hr to fix

    Function RawZones has 37 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export const RawZones = (props: ZonesProps) => {
      const navigate = (id: number) => push(Path.zones(id));
      const [searchTerm, setSearchTerm] = React.useState("");
      return <DesignerPanel panelName={"zones-inventory"} panel={Panel.Zones}>
        <DesignerNavTabs />
    Severity: Minor
    Found in frontend/zones/zones_inventory.tsx - About 1 hr to fix

      Function OtaTimeSelector has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export const OtaTimeSelector = (props: OtaTimeSelectorProps) => {
        const { device, dispatch, timeSettings } = props;
        const { utcOffset, hour24 } = timeSettings;
        const localHour = utcHourToLocalHour(device.body.ota_hour_utc, utcOffset) ??
          device.body.ota_hour;
      Severity: Minor
      Found in frontend/settings/fbos_settings/ota_time_selector.tsx - About 1 hr to fix

        Function PowerAndReset has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export function PowerAndReset(props: PowerAndResetProps) {
          const { dispatch, botOnline } = props;
          const { power_and_reset } = props.settingsPanelState;
          return <Highlight className={"section advanced"}
            settingName={DeviceSetting.powerAndReset}
        Severity: Minor
        Found in frontend/settings/fbos_settings/power_and_reset.tsx - About 1 hr to fix

          Function semverCompare has 37 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export function semverCompare(left: string, right: string): SemverResult {
            const leftSemVer = left.split("-")[0];
            const rightSemVer = right.split("-")[0];
            const leftHasSuffix = left.includes("-");
            const rightHasSuffix = right.includes("-");
          Severity: Minor
          Found in frontend/util/version.ts - About 1 hr to fix

            Function getData has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            const getData = (
              all: TaggedTelemetry[],
              metricName: keyof Telemetry,
            ): DataSegment[] => {
              const data: DataRecord[] = [];
            Severity: Minor
            Found in frontend/devices/connectivity/fbos_metric_history_plot.tsx - About 1 hr to fix

              Function PlantSlugBulkUpdate has 37 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export const PlantSlugBulkUpdate = (props: PlantSlugBulkUpdateProps) => {
                const plants = props.allPoints.filter(point =>
                  props.selected.includes(point.uuid) && point.kind === "Point" &&
                  point.body.pointer_type == "Plant")
                  .map((p: TaggedPlantPointer) => p);
              Severity: Minor
              Found in frontend/plants/edit_plant_status.tsx - About 1 hr to fix

                Function getLocationState has 36 lines of code (exceeds 25 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 1 hr to fix

                  Function BotExtents has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export function BotExtents(props: BotExtentsProps) {
                    const { stopAtHome, botSize, mapTransformProps } = props;
                    const { xySwap } = mapTransformProps;
                    const homeLength = transformXY(
                      botSize.x.value, botSize.y.value, mapTransformProps);
                  Severity: Minor
                  Found in frontend/farm_designer/map/layers/farmbot/bot_extents.tsx - About 1 hr to fix

                    Function FarmBotSettings has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    export const FarmBotSettings = (props: FarmbotSettingsProps) => {
                      const {
                        dispatch, device, timeSettings, sourceFbosConfig, botOnline, showAdvanced, bot,
                      } = props;
                      const { value } = props.sourceFbosConfig("firmware_hardware");
                    Severity: Minor
                    Found in frontend/settings/fbos_settings/farmbot_os_settings.tsx - About 1 hr to fix

                      Function urlFor has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      export function urlFor(tag: ResourceName) {
                        const OPTIONS: Partial<Record<ResourceName, string>> = {
                          Alert: API.current.alertPath,
                          Curve: API.current.curvesPath,
                          Device: API.current.devicePath,
                      Severity: Minor
                      Found in frontend/api/crud.ts - About 1 hr to fix

                        Function UTMProfile has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                        Open

                        export const UTMProfile = (props: ProfileUtmProps) => {
                          const { x, y } = props.botPosition;
                          const inProfile = !isUndefined(x) && !isUndefined(y) &&
                            withinProfileRange({
                              axis: props.profileAxis == "x" ? "y" : "x",
                        Severity: Minor
                        Found in frontend/farm_designer/map/profile/tools.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 ProfileViewer has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                        Open

                        export const ProfileViewer = (props: ProfileViewerProps) => {
                          const { dispatch } = props;
                          const { profileOpen, profileFollowBot } = props.designer;
                          const axis = props.designer.profileAxis;
                          const panelStatus = getPanelStatus();
                        Severity: Minor
                        Found in frontend/farm_designer/map/profile/viewer.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 35 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            def execute
                              ActiveRecord::Base.transaction do
                                flat_ir
                                  .each do |node|
                                  # Step 1- instantiate records.
                        Severity: Minor
                        Found in app/lib/celery_script/first_pass.rb - About 1 hr to fix

                          Function TileAssertion has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          export const TileAssertion = (props: StepParams<Assertion>) => {
                            const [monaco, setMonaco] = React.useState(window.innerWidth > 450);
                            const [expanded, setExpanded] = React.useState(false);
                            const stateToggles = {
                              [StateToggleKey.monacoEditor]:
                          Severity: Minor
                          Found in frontend/sequences/step_tiles/tile_assertion.tsx - About 1 hr to fix

                            Function ThreeInOneToolHead has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            export const ThreeInOneToolHead = (props: ThreeInOneToolHeadProps) => {
                              const { pulloutDirection } = props;
                              const { quadrant, xySwap } = props.toolTransformProps;
                              const angle = toolbaySlotAngle(pulloutDirection, quadrant, xySwap);
                              return <g id="three-in-one-tool-head">
                            Severity: Minor
                            Found in frontend/farm_designer/map/tool_graphics/three_in_one_toolhead.tsx - About 1 hr to fix

                              Function WeedPoint has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              export const WeedPoint = (props: ProfilePointProps<TaggedWeedPointer>) => {
                                const { point } = props;
                                const { radius } = point.body;
                                const color = point.body.meta.color || Color.red;
                                const plantIconSize = scaleIcon(radius) * 2;
                              Severity: Minor
                              Found in frontend/farm_designer/map/profile/plants_and_weeds.tsx - About 1 hr to fix

                                Function ScaleMenu has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                export const ScaleMenu = (props: ActionMenuProps) => {
                                  const { data } = props.curve.body;
                                  const [maxDayNum, setMaxDay] = React.useState(maxDay(data));
                                  const [maxValueNum, setMaxValue] = React.useState(maxValue(data));
                                  return <div className={"curve-action-menu"}>
                                Severity: Minor
                                Found in frontend/curves/edit_curve.tsx - About 1 hr to fix

                                  Function PinBindingsContent has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                  export const PinBindingsContent = (props: PinBindingsContentProps) => {
                                    const { dispatch, resources, firmwareHardware } = props;
                                    const pinBindings = apiPinBindings(resources);
                                    return <div className="pin-bindings">
                                      <Highlight settingName={DeviceSetting.stockPinBindings}>
                                  Severity: Minor
                                  Found in frontend/settings/pin_bindings/pin_bindings_content.tsx - About 1 hr to fix

                                    Function StartTimeForm has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                    export const StartTimeForm = (props: StartTimeFormProps) => {
                                      const forceMidnight = props.isRegimen;
                                      const isNew = !parseInt("" + props.fieldGet("id"));
                                      const startDatetimeError = isNew && !forceMidnight &&
                                        !moment(props.now).isBefore(moment(offsetTime(props.fieldGet("startDate"),
                                    Severity: Minor
                                    Found in frontend/farm_events/edit_fe_form.tsx - About 1 hr to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language