Showing 646 of 1,897 total issues
Function render
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
Open
render() {
const { imageWidth, imageHeight } = this.state;
const { image, cameraCalibrationData, mapTransformProps, cropImage,
} = this.props;
const imageRotation = parse(cameraCalibrationData.rotation) ?? 0;
- Read upRead up
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
File device.rb
has 281 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
class Device < ApplicationRecord
DEFAULT_MAX_CONFIGS = 300
DEFAULT_MAX_IMAGES = 100
DEFAULT_MAX_LOGS = 1000
DEFAULT_MAX_TELEMETRY = 300
Function render
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
render() {
const { chosenXY } = this;
const allSoilHeightPoints = this.props.genericPoints.filter(soilHeightPoint);
const getColorOverride = getSoilHeightColor(allSoilHeightPoints);
const sensorReadings = this.props.sensorReadings
Function getWarningLinesContent
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
(props: GetWarningLinesContentProps): WarningLinesContent => {
const { x, y } = props;
const gantryHeight = props.sourceFbosConfig("gantry_height").value as number;
const locationSoilHeight = getZAtLocation({
x,
Function RawEditGarden
has 67 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export const RawEditGarden = (props: EditGardenProps) => {
const navigate = useNavigate();
const [notes, setNotes] = React.useState(props.savedGarden?.body.notes || "");
const [expand, setExpand] = React.useState(false);
File motors.tsx
has 277 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import React from "react";
import { BooleanMCUInputGroup } from "./boolean_mcu_input_group";
import { ToolTips, DeviceSetting } from "../../constants";
import { settingToggle } from "../../devices/actions";
import { NumericMCUInputGroup } from "./numeric_mcu_input_group";
Function render
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
render() {
const panelName = "designer-sequence-editor";
const { sequence } = this.props;
return <DesignerPanel panelName={panelName} panel={Panel.Sequences}>
<DesignerPanelHeader
File index.tsx
has 276 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import React from "react";
import { connect } from "react-redux";
import {
DesignerPanel, DesignerPanelTop, DesignerPanelContent,
} from "../farm_designer/designer_panel";
File component.tsx
has 275 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import React from "react";
import { StepWrapper } from "../../step_ui";
import { Row, ExpandableHeader } from "../../../ui";
import { ToolTips } from "../../../constants";
import { t } from "../../../i18next_wrapper";
Function render
has 65 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
render() {
const { dispatch, current, stepIndex, resources } = this.props;
const commonStepProps = { dispatch, current, index: stepIndex };
const click = () => {
scrollToBottom("sequenceDiv");
File step_button_cluster.tsx
has 275 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import React from "react";
import { t } from "../i18next_wrapper";
import { StepButton, stepClick } from "./step_buttons";
import { equals, scrollToBottom } from "../util";
import { Color, SequenceBodyItem, TaggedSequence } from "farmbot";
File bot_figure.tsx
has 275 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import React from "react";
import { AxisNumberProperty, MapTransformProps } from "../../interfaces";
import { getMapSize, transformXY } from "../../util";
import { BotPosition } from "../../../../devices/interfaces";
import { Color } from "../../../../ui";
Function WeedInventoryItem
has 65 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export const WeedInventoryItem = (props: WeedInventoryItemProps) => {
const navigate = useNavigate();
const weed = props.tpp.body;
const { tpp, dispatch } = props;
const weedId = (weed.id || "ERR_NO_POINT_ID").toString();
Function RawEditWeed
has 65 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export const RawEditWeed = (props: EditWeedProps) => {
const getWeed = () => {
const stringyID = Path.getSlug(Path.weeds());
if (stringyID) {
return props.findPoint(parseInt(stringyID));
Function emptyState
has 65 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export const emptyState = (): RestResources => {
return {
consumers: {
sequences: sequenceState,
regimens: regimenState,
File subcriteria.tsx
has 275 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import React from "react";
import { t } from "../../i18next_wrapper";
import { capitalize, uniq, some, isEqual } from "lodash";
import {
NumberLtGtInput,
Function PointInventoryItem
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
Open
export const PointInventoryItem = (props: PointInventoryItemProps) => {
const navigate = useNavigate();
const point = props.tpp.body;
const color = point.meta.color || "green";
const { tpp, dispatch, hovered, colorOverride } = props;
- Read upRead up
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
File other_settings.tsx
has 274 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import React from "react";
import { OtherSettingsProps, SettingDescriptionProps } from "./interfaces";
import { Highlight } from "./maybe_highlight";
import { DeviceSetting, Content, ToolTips } from "../constants";
import { Header } from "./hardware_settings/header";
Function render
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
render() {
const {
current, selected, dragging, plant, mapTransformProps,
activeDragXY, zoomLvl, animate, editing, hovered, hoveredSpread,
} = this.props;
Function render
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
render() {
return <Highlight className={"section"}
settingName={DeviceSetting.changeOwnership}>
<ExpandableHeader
expanded={this.state.open}