tieme-ndo/frontend

View on GitHub
src/components/pages/AddFarmer/AddFarmer.js

Summary

Maintainability
D
1 day
Test Coverage

Function AddFarmer has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
Open

const AddFarmer = ({ history, appStateShouldUpdate }) => {
  const [state, setState] = useState({});

  const defaultState = () => {
    setState({
Severity: Minor
Found in src/components/pages/AddFarmer/AddFarmer.js - About 6 hrs 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

File AddFarmer.js has 310 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import React, { useState, useEffect } from 'react';
import Input from '../../common/Input/Input';
import {
  personalInfo,
  familyInfo,
Severity: Minor
Found in src/components/pages/AddFarmer/AddFarmer.js - About 3 hrs to fix

    Function onChangeHandler has 57 lines of code (exceeds 25 allowed). Consider refactoring.
    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
    Severity: Major
    Found in src/components/pages/AddFarmer/AddFarmer.js - About 2 hrs to fix

      Function formHandler has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        const formHandler = e => {
          e.preventDefault();
          let formData = {};
          const newState = JSON.parse(JSON.stringify(state));
          // eslint-disable-next-line no-unused-vars
      Severity: Minor
      Found in src/components/pages/AddFarmer/AddFarmer.js - About 1 hr to fix

        Parsing error: Unexpected token 189 | 190 | return (
        Open

            <>

        For more information visit Source: http://eslint.org/docs/rules/

        There are no issues that match your filters.

        Category
        Status