FarmBot/Farmbot-Web-App

View on GitHub

Showing 612 of 1,578 total issues

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

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

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 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 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 {
      currentPlant, mapTransformProps, dragging, isEditing, visible, designer,
      animate, spreadLayerVisible,
    } = this.props;
Severity: Minor
Found in frontend/farm_designer/map/active_plant/hovered_plant.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 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

Function ProfileSvg has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export const ProfileSvg = (props: ProfileSvgProps) => {
  const { expanded, mapTransformProps, tools, position, getConfigValue } = props;
  const lineAxis = props.designer.profileAxis;
  const selectionWidth = props.designer.profileWidth;
  const profileAxis = lineAxis == "x" ? "y" : "x";
Severity: Minor
Found in frontend/farm_designer/map/profile/content.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 generateTransform has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const generateTransform = (props: TransformProps): string => {
  const {
    quadrant, qCoords, size, imageOrigin, xySwap, rotate,
  } = props;
  const { qx, qy } = qCoords;
Severity: Minor
Found in frontend/farm_designer/map/layers/images/map_image.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 colorFromTemp has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export const colorFromTemp = (temp: number | undefined): string => {
  if (!isNumber(temp)) {
    return "gray";
  }
  if (temp < 0) {
Severity: Minor
Found in frontend/settings/fbos_settings/fbos_details.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 VerticalGridlines has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const VerticalGridlines = (props: PlotProps) =>
  <g id="vertical-gridlines">
    {range(props.timeStep, props.timePeriod + 1, props.timeStep).map(x => {
      const id = "vertical_gridline_" + x;
      /** label & major gridline every 3 hours/days/months and every week day */
Severity: Minor
Found in frontend/sensors/sensor_readings/graph.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 lastSeenNumber has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export const lastSeenNumber = (props: LastSeenNumberProps) => {
  const { last_saw_api } = props.device.body;
  const { uptime } = props.bot.connectivity;
  const bot2Mqtt = uptime["bot.mqtt"];
  const botToMqttAt = bot2Mqtt?.state === "up" ? bot2Mqtt.at : "";
Severity: Minor
Found in frontend/settings/fbos_settings/last_seen_row.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 occurrence has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export function occurrence(
  m: moment.Moment,
  fe: FarmEventWithExecutable,
  timeSettings: TimeSettings,
  resources: ResourceIndex,
Severity: Minor
Found in frontend/farm_events/calendar/occurrence.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 CameraCheckBase has a Cognitive Complexity of 6 (exceeds 5 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 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 WizardStepHeader has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export const WizardStepHeader = (props: WizardStepHeaderProps) => {
  const stepOpen = props.stepOpen == props.step.slug;
  const resultDate = props.stepResult?.updated_at;
  const stepDone = props.stepResult?.answer;
  const stepFail = stepDone == false;
Severity: Minor
Found in frontend/wizard/step.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 StatusIcon has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  (props: StatusIconProps) => {
    const okNoStatus = props.status ? "ok" : "no";
    const status = props.available ? okNoStatus : "unknown";
    const okNoStatusText = props.status ? t("ok") : t("error");
    const statusText = props.available ? okNoStatusText : t("unknown");
Severity: Minor
Found in frontend/settings/firmware/firmware_hardware_status.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 onLogs has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  (dispatch: Function, getState: GetState) => (msg: Log) => {
    if (isLog(msg)) {
      !msg.type && (msg.type = "info");
      actOnChannelName(msg, "toast", showLogOnScreen);
      actOnChannelName(msg, "espeak", speakLogAloud(getState));
Severity: Minor
Found in frontend/connectivity/log_handlers.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