tieme-ndo/frontend

View on GitHub

Showing 50 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',
Severity: Major
Found in src/components/common/Input/addFarmerData.js - About 1 day to fix

    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({});
    Severity: Minor
    Found in src/components/pages/UpdateFarmer/UpdateFarmer.js - About 1 day 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

    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,
    Severity: Major
    Found in src/components/App/App.js - About 6 hrs to fix

      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

      Function AddStaff has 99 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function AddStaff() {
        const [state, updateState] = useState({
          username: '',
          password: '',
          confirmPassword: '',
      Severity: Major
      Found in src/components/pages/AddStaff/AddStaff.js - About 3 hrs to fix

        Function AddStaff has 95 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const AddStaff = props => {
          const { state, handleSubmit, handleChange, checkboxChange } = props;
          return (
            <>
              <Container>
        Severity: Major
        Found in src/components/pages/AddStaff/AddStaffForm.js - About 3 hrs to fix

          Function PasswordResetForm has 93 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const PasswordResetForm = props => {
            const { state, handleSubmit, handleInputChange } = props;
          
            return (
              <>
          Severity: Major
          Found in src/components/pages/PasswordReset/PasswordResetForm.js - About 3 hrs to fix

            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,
            Severity: Minor
            Found in src/components/pages/UpdateFarmer/UpdateFarmer.js - About 3 hrs to fix

              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 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>
                Severity: Major
                Found in src/components/pages/DisplayFarmer/PersonalTab.js - About 3 hrs to fix

                  Function Input has 83 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  const Input = props => {
                    const {
                      type,
                      elementType,
                      name,
                  Severity: Major
                  Found in src/components/common/Input/Input.js - About 3 hrs to fix

                    Function handleSubmit has 72 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      const handleSubmit = async () => {
                        updateState(prevState => {
                          return {
                            ...prevState,
                            createAccount: true
                    Severity: Major
                    Found in src/components/pages/AddStaff/AddStaff.js - About 2 hrs to fix

                      Function LoginForm has 66 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      const LoginForm = props => {
                        const { state, handleSubmit, handleChange } = props;
                      
                        return (
                          <Container>
                      Severity: Major
                      Found in src/components/pages/Login/LoginForm.js - About 2 hrs to fix

                        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
                        Severity: Major
                        Found in src/components/pages/UpdateFarmer/UpdateFarmer.js - About 2 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 handleSubmit has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              const handleSubmit = async () => {
                                updateState(prevState => {
                                  return {
                                    ...prevState,
                                    resetting: true
                            Severity: Minor
                            Found in src/components/pages/PasswordReset/PasswordReset.js - About 1 hr to fix

                              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>
                              Severity: Minor
                              Found in src/components/pages/DisplayFarmer/GuarantorTab.js - About 1 hr to fix

                                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));
                                Severity: Minor
                                Found in src/components/pages/UpdateFarmer/UpdateFarmer.js - About 1 hr to fix

                                  Function handleSubmit has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                    const handleSubmit = async () => {
                                      updateState(prevState => {
                                        return {
                                          ...prevState,
                                          loading: true
                                  Severity: Minor
                                  Found in src/components/pages/Login/Login.js - About 1 hr to fix

                                    Function AddStaff has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                    function AddStaff() {
                                      const [state, updateState] = useState({
                                        username: '',
                                        password: '',
                                        confirmPassword: '',
                                    Severity: Minor
                                    Found in src/components/pages/AddStaff/AddStaff.js - About 1 hr 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

                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language