Lambda-School-Labs/shopping-cart-fe

View on GitHub

Showing 76 of 76 total issues

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

    const totalPrice = (arr) => {
        return arr.reduce((sum, item) => {
            return sum + item.price * item.quantity;
        }, 0);
    };
Severity: Major
Found in src/components/cart/CartView.js and 3 other locations - About 50 mins to fix
src/__tests__/cart.test.js on lines 36..40
src/components/elements/cartHeader.js on lines 24..28
src/components/saveCart/saveCart.js on lines 32..36

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

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 a Cognitive Complexity of 8 (exceeds 5 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: Minor
Found in src/components/Products/createProductView.js - About 45 mins 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 BuyerInfo has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

const BuyerInfo = ({ fullOrder, setOrderCanceled, orderId }) => {
  const { _id, orderCreated, orderStatus, orderCompleted } = fullOrder;
  //Instead of using the full 10+ long ID shorten it to the last 5 digits
  const orderNumber = _id ? _id.substr(_id.length - 5) : 0;
  //Status State
Severity: Minor
Found in src/components/Orders/BuyerInfo.js - About 45 mins 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 UpdateItem has a Cognitive Complexity of 8 (exceeds 5 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: Minor
Found in src/components/Products/updateItem.js - About 45 mins 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 SaveCart has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

const SaveCart = (props) => {
  const dispatch = useDispatch()

  useEffect(() => {
    dispatch(actionCreators.getCurrentUser())
Severity: Minor
Found in src/components/saveCart/saveCart.js - About 35 mins 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 BasicDetails has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

const BasicDetails = ({
  productData,
  setProductData,
  errorState,
  inventory,
Severity: Minor
Found in src/components/Products/basicDetails.js - About 35 mins 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

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

  const tailFormItemLayout = {
    wrapperCol: {
      xs: {
        span: 24,
        offset: 0,
Severity: Major
Found in src/components/createStore/addLogo.js and 6 other locations - About 35 mins to fix
src/components/ResetPassword/resetPassword.js on lines 54..65
src/components/ResetPassword/setNewPassword.js on lines 82..93
src/components/createStore/firstView.js on lines 42..53
src/components/login.js on lines 70..81
src/components/register.js on lines 74..85
src/components/saveCart/saveCart.js on lines 94..105

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

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 tailFormItemLayout = {
    wrapperCol: {
      xs: {
        span: 24,
        offset: 0,
Severity: Major
Found in src/components/register.js and 6 other locations - About 35 mins to fix
src/components/ResetPassword/resetPassword.js on lines 54..65
src/components/ResetPassword/setNewPassword.js on lines 82..93
src/components/createStore/addLogo.js on lines 124..135
src/components/createStore/firstView.js on lines 42..53
src/components/login.js on lines 70..81
src/components/saveCart/saveCart.js on lines 94..105

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

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 tailFormItemLayout = {
    wrapperCol: {
      xs: {
        span: 24,
        offset: 0,
Severity: Major
Found in src/components/ResetPassword/setNewPassword.js and 6 other locations - About 35 mins to fix
src/components/ResetPassword/resetPassword.js on lines 54..65
src/components/createStore/addLogo.js on lines 124..135
src/components/createStore/firstView.js on lines 42..53
src/components/login.js on lines 70..81
src/components/register.js on lines 74..85
src/components/saveCart/saveCart.js on lines 94..105

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

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 tailFormItemLayout = {
    wrapperCol: {
      xs: {
        span: 24,
        offset: 0,
Severity: Major
Found in src/components/ResetPassword/resetPassword.js and 6 other locations - About 35 mins to fix
src/components/ResetPassword/setNewPassword.js on lines 82..93
src/components/createStore/addLogo.js on lines 124..135
src/components/createStore/firstView.js on lines 42..53
src/components/login.js on lines 70..81
src/components/register.js on lines 74..85
src/components/saveCart/saveCart.js on lines 94..105

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

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 tailFormItemLayout = {
    wrapperCol: {
      xs: {
        span: 24,
        offset: 0,
Severity: Major
Found in src/components/saveCart/saveCart.js and 6 other locations - About 35 mins to fix
src/components/ResetPassword/resetPassword.js on lines 54..65
src/components/ResetPassword/setNewPassword.js on lines 82..93
src/components/createStore/addLogo.js on lines 124..135
src/components/createStore/firstView.js on lines 42..53
src/components/login.js on lines 70..81
src/components/register.js on lines 74..85

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

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 tailFormItemLayout = {
    wrapperCol: {
      xs: {
        span: 24,
        offset: 0,
Severity: Major
Found in src/components/login.js and 6 other locations - About 35 mins to fix
src/components/ResetPassword/resetPassword.js on lines 54..65
src/components/ResetPassword/setNewPassword.js on lines 82..93
src/components/createStore/addLogo.js on lines 124..135
src/components/createStore/firstView.js on lines 42..53
src/components/register.js on lines 74..85
src/components/saveCart/saveCart.js on lines 94..105

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

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 tailFormItemLayout = {
    wrapperCol: {
      xs: {
        span: 24,
        offset: 0,
Severity: Major
Found in src/components/createStore/firstView.js and 6 other locations - About 35 mins to fix
src/components/ResetPassword/resetPassword.js on lines 54..65
src/components/ResetPassword/setNewPassword.js on lines 82..93
src/components/createStore/addLogo.js on lines 124..135
src/components/login.js on lines 70..81
src/components/register.js on lines 74..85
src/components/saveCart/saveCart.js on lines 94..105

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

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 useCurrency has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const useCurrency = currencyDescription => {
  const [sign, setSign] = useState('')
  const fixCurrency = (currencyDescription) => {
    if (currencyDescription === 'POU') {
      setSign('£')
Severity: Minor
Found in src/components/hooks/useCurrency.js - About 25 mins 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 Stripe has a Cognitive Complexity of 6 (exceeds 5 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: Minor
Found in src/components/Stripe/stripe.js - About 25 mins 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 StripeConfirmAccount has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const StripeConfirmAccount = () => {
    //Grab code from the querry string (Splitting the "equal sign" creates an array of two items. Index 1 holds the code)
    const code = window.location.href.split('=');
    //state to hold returned information
    const [ stripeInfo, setStripeInfo ] = useState(null);
Severity: Minor
Found in src/components/Stripe/StripeConfirmAccount.js - About 25 mins 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