Showing 31 of 50 total issues
File addFarmerData.js
has 678 lines of code (exceeds 250 allowed). Consider refactoring. Open
export const personalInfo = {
image_url: {
elementType: 'input',
name: 'image_url',
type: 'file',
Function UpdateFarmer
has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring. Open
const UpdateFarmer = ({ location, history, appStateShouldUpdate, user }) => {
// Prevents errors when location state is empty
const { farmer: farmerData } = location.state || {};
// state that keeps track of changed input fields
const [changes, setChanges] = useState({});
- 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
Function App
has 170 lines of code (exceeds 25 allowed). Consider refactoring. Open
function App() {
const [user, setUser] = useState(undefined);
const [data, setData] = useState({
farmers: undefined,
farmersDashboard: undefined,
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({
- 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
Function AddStaff
has 99 lines of code (exceeds 25 allowed). Consider refactoring. Open
function AddStaff() {
const [state, updateState] = useState({
username: '',
password: '',
confirmPassword: '',
Function AddStaff
has 95 lines of code (exceeds 25 allowed). Consider refactoring. Open
const AddStaff = props => {
const { state, handleSubmit, handleChange, checkboxChange } = props;
return (
<>
<Container>
Function PasswordResetForm
has 93 lines of code (exceeds 25 allowed). Consider refactoring. Open
const PasswordResetForm = props => {
const { state, handleSubmit, handleInputChange } = props;
return (
<>
File UpdateFarmer.js
has 312 lines of code (exceeds 250 allowed). Consider refactoring. Open
import React, { useState } from 'react';
import Input from '../../common/Input/Input';
import * as form from '../../common/Input/addFarmerData';
import {
updateFarmerHandler,
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,
Function PersonalTab
has 85 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function PersonalTab(props) {
const data = props.farmer.personalInfo;
return (
<Grid columns={2} stackable>
Function Input
has 83 lines of code (exceeds 25 allowed). Consider refactoring. Open
const Input = props => {
const {
type,
elementType,
name,
Function handleSubmit
has 72 lines of code (exceeds 25 allowed). Consider refactoring. Open
const handleSubmit = async () => {
updateState(prevState => {
return {
...prevState,
createAccount: true
Function LoginForm
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
const LoginForm = props => {
const { state, handleSubmit, handleChange } = props;
return (
<Container>
Function onChangeHandler
has 64 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
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
Function handleSubmit
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
const handleSubmit = async () => {
updateState(prevState => {
return {
...prevState,
resetting: true
Function GuarantorTab
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function GuarantorTab(props) {
const data = props.farmer.guarantor;
return (
<Grid columns={2} stackable>
Function formHandler
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
const formHandler = e => {
setStateLoading(true);
e.preventDefault();
let formData = {};
const newState = JSON.parse(JSON.stringify(formElementsState));
Function handleSubmit
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
const handleSubmit = async () => {
updateState(prevState => {
return {
...prevState,
loading: true
Function AddStaff
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
function AddStaff() {
const [state, updateState] = useState({
username: '',
password: '',
confirmPassword: '',
- 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"