Lambda-School-Labs/shopping-cart-fe

View on GitHub

Showing 76 of 76 total issues

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

          <div className='rightContainer'>
            <BasicDetails
              inventory={inventory}
              productData={productData}
              setProductData={setProductData}
Severity: Major
Found in src/components/Products/updateItem.js and 1 other location - About 3 hrs to fix
src/components/Products/createProductView.js on lines 87..101

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 96.

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

          <div className='rightContainer'>
            <BasicDetails
              inventory={inventory}
              productData={productData}
              setProductData={setProductData}
Severity: Major
Found in src/components/Products/createProductView.js and 1 other location - About 3 hrs to fix
src/components/Products/updateItem.js on lines 141..155

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 96.

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 CreateStore has 97 lines of code (exceeds 50 allowed). Consider refactoring.
Open

const CreateStore = (props) => {
  const dispatch = useDispatch();

  const handleSubmit = (e) => {
    e.preventDefault();
Severity: Major
Found in src/components/createStore/firstView.js - About 2 hrs to fix

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

      const url = `${window.location.origin.toString()}/store/${
        user && user.storeName && user.storeName.toLowerCase().split(' ').join('-')
      }-${user && user._id}`;
    Severity: Major
    Found in src/components/Navbar.js and 1 other location - About 2 hrs to fix
    src/components/DashboardHome/Dashboard.js on lines 28..30

    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 86.

    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 url = `${window.location.origin.toString()}/store/${
        user && user.storeName && user.storeName.toLowerCase().split(' ').join('-')
      }-${user && user._id}`;
    Severity: Major
    Found in src/components/DashboardHome/Dashboard.js and 1 other location - About 2 hrs to fix
    src/components/Navbar.js on lines 33..35

    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 86.

    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 CreateProductView has 84 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    const CreateProductView = () => {
      // inventory gets all of the products from the redux store (redux store is calling the db)
      const inventory = useSelector((state) => state.store);
      //Keeps track of what field is empty
      const [errorState, setErrorState] = useState();
    Severity: Major
    Found in src/components/Products/createProductView.js - About 2 hrs to fix

      Function Navbar has 83 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      const Navbar = (props) => {
        const dispatch = useDispatch();
      
        useEffect(() => {
          dispatch(creators.getCurrentUser());
      Severity: Major
      Found in src/components/Navbar.js - About 2 hrs to fix

        Function StoreNav has 79 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        const StoreNav = (props) => {
          const [show, setShow] = useState(false)
          const cartContents = useSelector((state) => state.cart)
          const store = useSelector((state) => state.user.user)
          const [place, setPlace] = useState()
        Severity: Major
        Found in src/components/store/StoreNav.js - About 2 hrs to fix

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

                  axios
                    .post(URL, payload)
                    .then((res) => {
                      message.success('Your password reset is on its way!');
                      dispatch(creators.setLoading(false));
          Severity: Major
          Found in src/components/ResetPassword/resetPassword.js and 2 other locations - About 2 hrs to fix
          src/components/ResetPassword/setNewPassword.js on lines 26..44
          src/components/createStore/addLogo.js on lines 85..98

          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 77.

          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 3 locations. Consider refactoring.
          Open

                  axios
                    .post(URL, payload)
                    .then((res) => {
                      dispatch(creators.setLoading(false));
                      dispatch(creators.clearErrors());
          Severity: Major
          Found in src/components/ResetPassword/setNewPassword.js and 2 other locations - About 2 hrs to fix
          src/components/ResetPassword/resetPassword.js on lines 25..37
          src/components/createStore/addLogo.js on lines 85..98

          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 77.

          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 3 locations. Consider refactoring.
          Open

                  AxiosAuth()
                    .post(createStoreUrl, payload)
                    .then((res) => {
                      dispatch(creators.setStore(res.data.saved));
                      message.success('store created');
          Severity: Major
          Found in src/components/createStore/addLogo.js and 2 other locations - About 2 hrs to fix
          src/components/ResetPassword/resetPassword.js on lines 25..37
          src/components/ResetPassword/setNewPassword.js on lines 26..44

          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 77.

          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 SingleProductView has a Cognitive Complexity of 16 (exceeds 5 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: Minor
          Found in src/components/singleProduct/buyerSingleProductView.js - About 2 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 Account has 77 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          function Account() {
            //State for the information obtained by the axios request below
            const [stripeAccount, setStripeAccount] = useState(null);
          
            //Makes a request to the DB to get stripe info
          Severity: Major
          Found in src/components/SellerAccount/SellerAccount.js - About 2 hrs to fix

            Function CartTable has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

            const CartTable = ({ cartContents, totalPrice, store }) => {
                // Hooks for Redux & Stripe
                const dispatch = useDispatch();
                const stripe = useStripe();
                const elements = useElements();
            Severity: Minor
            Found in src/components/cart/CartTable.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

            Function App has 64 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            function App() {
                window.addEventListener('load', () => {
                    function handleNetworkChange(event) {
                        // delete this comment
                        if (navigator.onLine) {
            Severity: Major
            Found in src/App.js - About 1 hr to fix

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

                const validateToNextPassword = (rule, value, callback) => {
                  const { form } = props;
              
                  if (value && confirmDirty) {
                    form.validateFields(['confirm'], { force: true });
              Severity: Major
              Found in src/components/register.js and 1 other location - About 1 hr to fix
              src/components/ResetPassword/setNewPassword.js on lines 62..68

              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 65.

              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 validateToNextPassword = (rule, value, callback) => {
                  const { form } = props;
                  if (value && confirmDirty) {
                    form.validateFields(['confirm'], { force: true });
                  }
              Severity: Major
              Found in src/components/ResetPassword/setNewPassword.js and 1 other location - About 1 hr to fix
              src/components/register.js on lines 53..60

              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 65.

              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 userReducer has 62 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              export function userReducer (state = initialUserState, action) {
                switch (action.type) {
                  case types.GET_CURRENT_USER:
                    localStorage.setItem('user', JSON.stringify(action.payload))
                    return {
              Severity: Major
              Found in src/state/reducers/userReducer.js - About 1 hr to fix

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

                        const { getByTestId } = renderWithProviders(
                            <Elements stripe={stripePromise}>
                                <CartTable cartContents={cartContents} totalPrice={totalPrice} store={store} />
                            </Elements>
                        );
                Severity: Major
                Found in src/__tests__/cart.test.js and 1 other location - About 1 hr to fix
                src/__tests__/cart.test.js on lines 76..80

                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 64.

                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 7 locations. Consider refactoring.
                Open

                  const formItemLayout = {
                    labelCol: {
                      xs: { span: 24 },
                      sm: { span: 8 },
                    },
                Severity: Major
                Found in src/components/saveCart/saveCart.js and 6 other locations - About 1 hr to fix
                src/components/ResetPassword/resetPassword.js on lines 44..53
                src/components/ResetPassword/setNewPassword.js on lines 72..81
                src/components/createStore/addLogo.js on lines 114..123
                src/components/createStore/firstView.js on lines 32..41
                src/components/login.js on lines 60..69
                src/components/register.js on lines 64..73

                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 64.

                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

                Severity
                Category
                Status
                Source
                Language