FarmBot/Farmbot-Web-App

View on GitHub
frontend/devices/connectivity/fbos_metric_history_plot.tsx

Summary

Maintainability
C
1 day
Test Coverage

File fbos_metric_history_plot.tsx has 261 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import React from "react";
import { trim } from "../../util";
import { Telemetry } from "farmbot/dist/resources/api_resources";
import { TaggedTelemetry } from "farmbot";
import { flatten, isNumber, last, max, range, sortBy } from "lodash";
Severity: Minor
Found in frontend/devices/connectivity/fbos_metric_history_plot.tsx - About 2 hrs 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 VersionChangeLines has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const VersionChangeLines = (props: VersionChangeLinesProps) => {
        const changes: VersionChangeRecord[] = [];
        const mostRecent = last(sortBy(props.telemetry, "body.created_at"));
        props.telemetry.map((d, i) => {
          if (i == 0) { return; }
      Severity: Minor
      Found in frontend/devices/connectivity/fbos_metric_history_plot.tsx - About 1 hr to fix

        Function FbosMetricHistoryPlot has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export const FbosMetricHistoryPlot = (props: FbosMetricHistoryPlotProps) => {
          const mostRecent = last(sortBy(props.telemetry, "body.created_at"));
          const hoveredSeconds = clipX(props.hoveredTime, mostRecent);
          return <svg
            className={"fbos-metric-history-plot-border"}
        Severity: Minor
        Found in frontend/devices/connectivity/fbos_metric_history_plot.tsx - About 1 hr to fix

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                  <text x={plotXSeconds(change.changedAt) - 3} y={VERSION_LABEL_Y_POSITION}
                    fill={"gray"} textAnchor={"end"} style={{ textAnchor: "end" }}>
                    v{change.previousVersion}
                  </text>
          Severity: Major
          Found in frontend/devices/connectivity/fbos_metric_history_plot.tsx and 1 other location - About 1 hr to fix
          frontend/devices/connectivity/fbos_metric_history_plot.tsx on lines 248..251

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 73.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                  <text x={plotXSeconds(change.changedAt) + 3} y={VERSION_LABEL_Y_POSITION}
                    fill={"gray"} textAnchor={"start"} style={{ textAnchor: "start" }}>
                    v{change.nextVersion}
                  </text>
          Severity: Major
          Found in frontend/devices/connectivity/fbos_metric_history_plot.tsx and 1 other location - About 1 hr to fix
          frontend/devices/connectivity/fbos_metric_history_plot.tsx on lines 244..247

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 73.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

              <line x1={0} y1={0} x2={MAX_X} y2={0} strokeWidth={0.25} stroke={"grey"} />
          Severity: Minor
          Found in frontend/devices/connectivity/fbos_metric_history_plot.tsx and 1 other location - About 40 mins to fix
          frontend/controls/move/motor_position_plot.tsx on lines 190..190

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 49.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              <line x1={0} y1={MAX_Y} x2={MAX_X} y2={MAX_Y}
                strokeWidth={0.25} stroke={"grey"} />
          Severity: Minor
          Found in frontend/devices/connectivity/fbos_metric_history_plot.tsx and 1 other location - About 40 mins to fix
          frontend/controls/move/motor_position_plot.tsx on lines 162..162

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 49.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          There are no issues that match your filters.

          Category
          Status