src/components/pages/AddFarmer/AddFarmer.js
Function AddFarmer
has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring. Open
Open
const AddFarmer = ({ history, appStateShouldUpdate }) => {
const [state, setState] = useState({});
const defaultState = () => {
setState({
- 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 AddFarmer.js
has 310 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import React, { useState, useEffect } from 'react';
import Input from '../../common/Input/Input';
import {
personalInfo,
familyInfo,
Function onChangeHandler
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const onChangeHandler = async (e, data, elementType, elementConfigObj) => {
let name, value, type, files;
if (elementType === 'checkbox') {
// This is for the checkboxes to work as Semantic UI uses the :before pseudoelement
Function formHandler
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const formHandler = e => {
e.preventDefault();
let formData = {};
const newState = JSON.parse(JSON.stringify(state));
// eslint-disable-next-line no-unused-vars
Parsing error: Unexpected token 189 |
190 | return ( Open
Open
<>
- Read upRead up
- Exclude checks
For more information visit Source: http://eslint.org/docs/rules/