Lambda-School-Labs/shopping-cart-fe

View on GitHub

Showing 76 of 76 total issues

Function Update has 245 lines of code (exceeds 50 allowed). Consider refactoring.
Open

const Update = (props) => {
  const [loading, setLoading] = useState(false);
  const [color, setColor] = useState(props.color.color);
  const [confirmDelete, setConfirmDelete] = useState(false);
  const [confirmLogout, setConfirmLogout] = useState(false);
Severity: Major
Found in src/components/Update.js - About 1 day to fix

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

    const mapStateToProps = (state) => {
      return {
        businessName: state.onboard.businessName,
        ownerName: state.onboard.ownerName,
        address: state.onboard.address,
    Severity: Major
    Found in src/components/WelcomeScreen/WelcomeScreen.js and 1 other location - About 6 hrs to fix
    src/components/BrandView.js on lines 52..66

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 160.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

    const mapStateToProps = (state) => {
      return {
        businessName: state.onboard.businessName,
        ownerName: state.onboard.ownerName,
        address: state.onboard.address,
    Severity: Major
    Found in src/components/BrandView.js and 1 other location - About 6 hrs to fix
    src/components/WelcomeScreen/WelcomeScreen.js on lines 217..231

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 160.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Function AddLogo has 178 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    const AddLogo = (props) => {
      const dispatch = useDispatch();
      const [imageUrl, setImageUrl] = useState('');
      const [loading, setLoading] = useState(false);
    
    
    Severity: Major
    Found in src/components/createStore/addLogo.js - About 6 hrs to fix

      Function SaveCart has 178 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      const SaveCart = (props) => {
        const dispatch = useDispatch()
      
        useEffect(() => {
          dispatch(actionCreators.getCurrentUser())
      Severity: Major
      Found in src/components/saveCart/saveCart.js - About 6 hrs to fix

        Function RegistrationForm has 174 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        const RegistrationForm = (props) => {
          const [confirmDirty, setConfirmDirty] = useState(false);
          const handleSubmit = (e) => {
            e.preventDefault();
            props.form.validateFieldsAndScroll((err, values) => {
        Severity: Major
        Found in src/components/register.js - About 5 hrs to fix

          Function WelcomeScreen has 158 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          const WelcomeScreen = (props) => {
            return (
              <div className='welcomeForm' data-testid='welcomeFormWrapper'>
                <img src={logo} alt='logo' />
                <h1 data-testid='welcomeHeader'>Welcome</h1>
          Severity: Major
          Found in src/components/WelcomeScreen/WelcomeScreen.js - About 5 hrs to fix

            Function Stripe has 153 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            const Stripe = (props) => {
              const { cartId } = props;
              const [clientId, setClientId] = useState('');
              const [stripeId, setStripeId] = useState('');
              const cartContents = useSelector((state) => state.savedCart);
            Severity: Major
            Found in src/components/Stripe/stripe.js - About 5 hrs to fix

              Function SetNewPassword has 153 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              const SetNewPassword = (props) => {
                const dispatch = useDispatch();
                const { isLoading } = useSelector((state) => state.user);
              
                const [confirmDirty, setConfirmDirty] = useState(false);
              Severity: Major
              Found in src/components/ResetPassword/setNewPassword.js - About 5 hrs to fix

                Function Login has 152 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

                const Login = (props) => {
                  const handleSubmit = (e) => {
                    e.preventDefault();
                    props.form.validateFieldsAndScroll((err, values) => {
                      const payload = {
                Severity: Major
                Found in src/components/login.js - About 5 hrs to fix

                  Function SingleProductView has 141 lines of code (exceeds 50 allowed). Consider refactoring.
                  Open

                  function SingleProductView(props) {
                    //productState is used only for the values that is submitted to the cart
                    const [fullProduct, setFullProduct] = useState([])
                    const [productState, setProductState] = useState([
                      {
                  Severity: Major
                  Found in src/components/singleProduct/buyerSingleProductView.js - About 4 hrs to fix

                    Function UpdateItem has 129 lines of code (exceeds 50 allowed). Consider refactoring.
                    Open

                    function UpdateItem(props) {
                      const dispatch = useDispatch();
                      const itemId = props.match.params.id;
                      const sellerId = localStorage.getItem('sellerId');
                      const [message, setMessage] = useState();
                    Severity: Major
                    Found in src/components/Products/updateItem.js - About 4 hrs to fix

                      File Update.js has 326 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      import React, { useState, useEffect } from 'react';
                      import axios from 'axios';
                      import { withFormik, Form, Field, ErrorMessage } from 'formik';
                      import * as Yup from 'yup';
                      import { connect } from 'react-redux';
                      Severity: Minor
                      Found in src/components/Update.js - About 3 hrs to fix

                        File actionCreators.js has 326 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        import * as types from './actionTypes';
                        import AxiosAuth from '../components/Auth/axiosWithAuth';
                        import axios from 'axios';
                        const getUserUrl = 'https://shopping-cart-be.herokuapp.com/api/store/';
                        export const updateForm = (details) => ({
                        Severity: Minor
                        Found in src/state/actionCreators.js - About 3 hrs to fix

                          Function AddVariants has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
                          Open

                          const AddVariants = ({
                            formData,
                            setFormData,
                            productData,
                            setProductData,
                          Severity: Minor
                          Found in src/components/Products/addVariants.js - About 3 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 ProfileView has 114 lines of code (exceeds 50 allowed). Consider refactoring.
                          Open

                          const ProfileView = () => {
                              const [ logo, setLogo ] = useState();
                              const [ address, setAddress ] = useState();
                              const [ secondAddress, setSecondAddress ] = useState();
                              const [ businessName, setBusinessName ] = useState();
                          Severity: Major
                          Found in src/components/ProfileView.js - About 3 hrs to fix

                            Function ResetPassword has 109 lines of code (exceeds 50 allowed). Consider refactoring.
                            Open

                            const ResetPassword = (props) => {
                              const dispatch = useDispatch();
                              const { isLoading } = useSelector((state) => state.user);
                            
                              const handleSubmit = (e) => {
                            Severity: Major
                            Found in src/components/ResetPassword/resetPassword.js - About 3 hrs to fix

                              Identical blocks of code found in 2 locations. Consider refactoring.
                              Open

                                AxiosAuth()
                                  .get('https://shopping-cart-be.herokuapp.com/api/store/sales')
                                  .then((res) => {
                                    setLoading(false);
                                    dispatch({ type: types.GET_SALES_HISTORY, payload: res.data });
                              Severity: Major
                              Found in src/state/actionCreators.js and 1 other location - About 3 hrs to fix
                              src/state/actionCreators.js on lines 289..298

                              Duplicated Code

                              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                              Tuning

                              This issue has a mass of 101.

                              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                              Refactorings

                              Further Reading

                              Identical blocks of code found in 2 locations. Consider refactoring.
                              Open

                                AxiosAuth()
                                  .get('https://shopping-cart-be.herokuapp.com/api/store/sales')
                                  .then((res) => {
                                    setLoading(false);
                                    dispatch({ type: types.GET_SALES_HISTORY, payload: res.data });
                              Severity: Major
                              Found in src/state/actionCreators.js and 1 other location - About 3 hrs to fix
                              src/state/actionCreators.js on lines 240..249

                              Duplicated Code

                              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                              Tuning

                              This issue has a mass of 101.

                              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                              Refactorings

                              Further Reading

                              File CartTable.js has 304 lines of code (exceeds 250 allowed). Consider refactoring.
                              Open

                              import React, { useState, useCallback, useEffect } from 'react';
                              import * as creators from '../../state/actionCreators';
                              import { useDispatch } from 'react-redux';
                              import times_icon from '../../images/times-icon.svg';
                              import equals_icon from '../../images/equals-icon.svg';
                              Severity: Minor
                              Found in src/components/cart/CartTable.js - About 3 hrs to fix
                                Severity
                                Category
                                Status
                                Source
                                Language