FarmBot/Farmbot-Web-App

View on GitHub

Showing 612 of 1,578 total issues

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

export function determineInstalledOsVersion(
  bot: BotState, device: TaggedDevice | undefined): string | undefined {
  const fromBotState = bot.hardware.informational_settings.controller_version;
  const fromAPI = device ? device.body.fbos_version : undefined;
  if (isUndefined(fromBotState) && isUndefined(fromAPI)) { return undefined; }
Severity: Minor
Found in frontend/util/version.ts - 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 createTimeLabel has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  (x: number, timePeriod: number, timeStep: number, timeMax: moment.Moment,
    timeSettings: TimeSettings) =>
    (period: "current" | "previous"): string => {
      const calcFormat = () => {
        if (timePeriod > 3600 * 24 * 32) { return "MMM D YYYY"; }
Severity: Minor
Found in frontend/sensors/sensor_readings/graph.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

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

export function mapStateToPropsAddEdit(props: Everything): AddEditFarmEventProps {
  const executableList: DropDownItem[] = [
    { label: t("Sequences"), heading: true, value: 0, headingId: "Sequence" },
    ...addExecutables(selectAllSequences(props.resources.index)),
    { label: t("Regimens"), heading: true, value: 0, headingId: "Regimen" },
Severity: Minor
Found in frontend/farm_events/map_state_to_props_add_edit.ts - 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 tooltip has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  get tooltip() {
    const scale = {
      x: microstepScaledConfig(this.props.x) ? 1 : this.props.xScale || 1,
      y: microstepScaledConfig(this.props.y) ? 1 : this.props.yScale || 1,
      z: microstepScaledConfig(this.props.z) ? 1 : this.props.zScale || 1,
Severity: Minor
Found in frontend/settings/hardware_settings/numeric_mcu_input_group.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

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

export const saveOrEditFarmwareEnv = (ri: ResourceIndex): SaveFarmwareEnv =>
  (key: string, value: string) => (dispatch: Function) => {
    const fwEnvLookup: Record<string, TaggedFarmwareEnv> = {};
    selectAllFarmwareEnvs(ri)
      .map(x => { fwEnvLookup[x.body.key] = x; });
Severity: Minor
Found in frontend/farmware/state_to_props.ts - 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 convertUptime has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

export const convertUptime = (seconds: number, abrv = false) => {
  if (seconds >= 172800) {
    return `${Math.round(seconds / 86400)} ${t("days")}`;
  } else if (seconds >= 7200) {
    return `${Math.round(seconds / 3600)} ${t("hours")}`;
Severity: Minor
Found in frontend/settings/fbos_settings/fbos_details.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

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

const PercentChange = (props: PercentChangeProps) => {
  const exactData = populatedData(props.curve.body.data, true);
  const prev = exactData[props.index] || 0;
  const value = exactData[props.index + 1];
  if (prev == 0) { return <p>-</p>; }
Severity: Minor
Found in frontend/curves/edit_curve.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

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

export function stopIE() {
  try {
    // Can't use Array.proto.map because IE.
    // Can't translate the text because IE (no promises)
    for (let i = 0; i < REQUIRED_GLOBALS.length; i++) {
Severity: Minor
Found in frontend/util/stop_ie.ts - 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 Button has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

const Button = (props: ButtonProps) => {
  const { pin, color, cx, cy, r } = props;
  const hovered = props.hovered && !props.bound;
  return <g id={"button"} style={{ cursor: "pointer" }}
    onMouseEnter={props.hover(pin)}
Severity: Minor
Found in frontend/settings/pin_bindings/box_top_gpio_diagram.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

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

export const beforeEach = (state: RestResources,
  action: ReduxAction<unknown>,
  handler: ActionHandler<RestResources, unknown>) => {
  const { byKind, references } = state.index;
  const w = references[Object.keys(byKind.WebAppConfig)[0]];
Severity: Minor
Found in frontend/resources/reducer_support.ts - 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 render has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  render() {
    const { logs, botOnline, imageJobs, env } = this.props;
    const { clickedAt } = this.state;
    const camDisabled = cameraBtnProps(env, botOnline);
    const job = imageJobs.filter(x => greaterThanTime(x.updated_at, clickedAt))[0];
Severity: Minor
Found in frontend/controls/move/take_photo_button.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

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

export function directionDisabled(props: DirectionButtonProps): boolean {
  const {
    stopAtHome, stopAtMax, axisLength, position, isInverted, negativeOnly
  } = props.directionAxisProps;
  const { direction } = props;
Severity: Minor
Found in frontend/controls/move/direction_button.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

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

export const FolderNameEditor = (props: FolderNodeProps) => {
  const { node } = props;
  const [settingsOpen, setSettingsOpen] = React.useState(false);
  const [hovered, setHovered] = React.useState(false);
  return <div
Severity: Minor
Found in frontend/folders/component.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

Consider simplifying this complex logical expression.
Open

      if (i > 0 && previousCoordinate && currentCoordinate && isNumber(cur.water)) {
        const p1 = toQ(currentCoordinate);
        const p2 = toQ(previousCoordinate);
        return <g id={"trail-record"} key={i}>
          <line id={`trail-line-${i}`}
Severity: Major
Found in frontend/farm_designer/map/layers/farmbot/bot_trail.tsx - About 40 mins to fix

    Consider simplifying this complex logical expression.
    Open

      if (activeXYZ && !isUndefined(activeXYZ.x) && !isUndefined(activeXYZ.y)
        && plantXYZ && !isUndefined(plantXYZ.x) && !isUndefined(plantXYZ.y)) {
        // Plant editing (dragging) is occuring
        const activeXY = { x: round(activeXYZ.x), y: round(activeXYZ.y) };
        const distance = Math.sqrt(
    Severity: Major
    Found in frontend/farm_designer/map/layers/spread/spread_overlap_helper.tsx - About 40 mins to fix

      Consider simplifying this complex logical expression.
      Open

          if (isUndefined(botPosition0.x)
            || isUndefined(botPosition0.y)
            || isUndefined(botPosition0.z)
            || isUndefined(botPosition1.x)
            || isUndefined(botPosition1.y)
      Severity: Major
      Found in frontend/farm_designer/map/layers/logs/logs_layer.tsx - About 40 mins to fix

        Consider simplifying this complex logical expression.
        Open

                if (imagePosition) {
                  const { width, height, transformOrigin } = imagePosition;
                  const transform = this.props.disableTranslation ?
                    imagePosition.transform.replace(/translate\(.*?\)/g, "")
                    : imagePosition.transform;
        Severity: Major
        Found in frontend/farm_designer/map/layers/images/map_image.tsx - About 40 mins to fix

          Function variableFormList has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

            resources: ResourceIndex,
            additionalItems: DropDownItem[],
            variableItems?: DropDownItem[],
            displayGroups?: boolean,
            variableType?: VariableType,
          Severity: Minor
          Found in frontend/sequences/locals_list/variable_form_list.ts - About 35 mins to fix

            Function stepPut has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            export function stepPut(value: Step,
              ev: React.DragEvent<HTMLElement>,
              intent: DataXferIntent,
              draggerId: number,
              resourceUuid?: UUID):
            Severity: Minor
            Found in frontend/draggable/actions.ts - About 35 mins to fix

              Function occurrence has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                m: moment.Moment,
                fe: FarmEventWithExecutable,
                timeSettings: TimeSettings,
                resources: ResourceIndex,
                modifiers?: { numHidden?: number, empty?: boolean }):
              Severity: Minor
              Found in frontend/farm_events/calendar/occurrence.ts - About 35 mins to fix
                Severity
                Category
                Status
                Source
                Language