myems-web/src/components/page/Invoice.js

Summary

Maintainability
D
2 days
Test Coverage

Function Invoice has 146 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const Invoice = () => {
  const [subtotal, setSubtotal] = useState(0);
  const [tax, setTax] = useState(0);
  const [total, setTotal] = useState(0);
  const { loading: invoiceLoading, data: invoice } = useFakeFetch(rawInvoice);
Severity: Major
Found in myems-web/src/components/page/Invoice.js - About 5 hrs to fix

    Function Invoice has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    const Invoice = () => {
      const [subtotal, setSubtotal] = useState(0);
      const [tax, setTax] = useState(0);
      const [total, setTotal] = useState(0);
      const { loading: invoiceLoading, data: invoice } = useFakeFetch(rawInvoice);
    Severity: Minor
    Found in myems-web/src/components/page/Invoice.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

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

                    <p className="fs--1">
                      <a href={`mailto:${invoice.user.email}`}>{invoice.user.email}</a>
                      <br />
                      <a href={`tel:${invoice.user.cell.split('-').join('')}`}>{invoice.user.cell}</a>
                    </p>
    Severity: Major
    Found in myems-web/src/components/page/Invoice.js and 1 other location - About 5 hrs to fix
    myems-web/src/components/MyEMS/Tenant/TenantBill.js on lines 578..582

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

    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

    Similar blocks of code found in 6 locations. Consider refactoring.
    Open

    ProductTr.propTypes = {
      name: PropTypes.string.isRequired,
      description: PropTypes.string.isRequired,
      quantity: PropTypes.number.isRequired,
      rate: PropTypes.number.isRequired
    Severity: Major
    Found in myems-web/src/components/page/Invoice.js and 5 other locations - About 1 hr to fix
    myems-web/src/components/MyEMS/EnergyStoragePowerStation/ScheduleDetails.js on lines 34..39
    myems-web/src/components/MyEMS/common/SharePieItem.js on lines 16..21
    myems-web/src/components/association/Association.js on lines 20..25
    myems-web/src/components/dashboard-alt/MarketShareItem.js on lines 16..21
    myems-web/src/components/landing/Testimonial.js on lines 25..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 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

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

                    <tbody>
                      {isIterableArray(invoice.products) &&
                        invoice.products.map((product, index) => <ProductTr {...product} key={index} />)}
                    </tbody>
    Severity: Major
    Found in myems-web/src/components/page/Invoice.js and 1 other location - About 1 hr to fix
    myems-web/src/components/MyEMS/Tenant/TenantBill.js on lines 625..628

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

    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

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

                        <tr>
                          <th className="text-900">Tax 8%:</th>
                          <td className="font-weight-semi-bold">{formatCurrency(tax, invoice.currency)}</td>
                        </tr>
    Severity: Major
    Found in myems-web/src/components/page/Invoice.js and 1 other location - About 1 hr to fix
    myems-web/src/components/page/Invoice.js on lines 187..190

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

    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

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

                        <tr>
                          <th className="text-900">Subtotal:</th>
                          <td className="font-weight-semi-bold">{formatCurrency(subtotal, invoice.currency)}</td>
                        </tr>
    Severity: Major
    Found in myems-web/src/components/page/Invoice.js and 1 other location - About 1 hr to fix
    myems-web/src/components/page/Invoice.js on lines 191..194

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

    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

    Similar blocks of code found in 6 locations. Consider refactoring.
    Open

          <td className="align-middle">
            <h6 className="mb-0 text-nowrap">{name}</h6>
            <p className="mb-0">{description}</p>
          </td>
    Severity: Major
    Found in myems-web/src/components/page/Invoice.js and 5 other locations - About 1 hr to fix
    myems-web/src/components/MyEMS/Tenant/TenantBill.js on lines 41..44
    myems-web/src/components/common/Calendar.js on lines 5..8
    myems-web/src/components/dashboard-alt/SharedFile.js on lines 24..27
    myems-web/src/components/e-commerce/OrderDetails.js on lines 76..79
    myems-web/src/components/notification/Notification.js on lines 12..15

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

    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

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

                          <tr>
                            <th className="text-sm-right">Invoice No:</th>
                            <td>{invoice.summary.invoice_no}</td>
                          </tr>
    Severity: Major
    Found in myems-web/src/components/page/Invoice.js and 3 other locations - About 55 mins to fix
    myems-web/src/components/page/Invoice.js on lines 136..139
    myems-web/src/components/page/Invoice.js on lines 140..143
    myems-web/src/components/page/Invoice.js on lines 144..147

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

    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

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

                          <tr>
                            <th className="text-sm-right">Payment Due:</th>
                            <td>{invoice.summary.payment_due}</td>
                          </tr>
    Severity: Major
    Found in myems-web/src/components/page/Invoice.js and 3 other locations - About 55 mins to fix
    myems-web/src/components/page/Invoice.js on lines 132..135
    myems-web/src/components/page/Invoice.js on lines 136..139
    myems-web/src/components/page/Invoice.js on lines 140..143

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

    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

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

                          <tr>
                            <th className="text-sm-right">Invoice Date:</th>
                            <td>{invoice.summary.invoice_date}</td>
                          </tr>
    Severity: Major
    Found in myems-web/src/components/page/Invoice.js and 3 other locations - About 55 mins to fix
    myems-web/src/components/page/Invoice.js on lines 132..135
    myems-web/src/components/page/Invoice.js on lines 136..139
    myems-web/src/components/page/Invoice.js on lines 144..147

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

    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

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

                          <tr>
                            <th className="text-sm-right">Order Number:</th>
                            <td>{invoice.summary.order_number}</td>
                          </tr>
    Severity: Major
    Found in myems-web/src/components/page/Invoice.js and 3 other locations - About 55 mins to fix
    myems-web/src/components/page/Invoice.js on lines 132..135
    myems-web/src/components/page/Invoice.js on lines 140..143
    myems-web/src/components/page/Invoice.js on lines 144..147

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

    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

        <Col sm={6} className="text-sm-left">
          <img src={logo} alt="invoice" width={150} />
        </Col>
    Severity: Minor
    Found in myems-web/src/components/page/Invoice.js and 1 other location - About 50 mins to fix
    myems-web/src/components/MyEMS/Tenant/TenantBill.js on lines 68..70

    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

    Similar blocks of code found in 13 locations. Consider refactoring.
    Open

    InvoiceHeader.propTypes = {
      institution: PropTypes.string.isRequired,
      logo: PropTypes.string.isRequired,
      address: PropTypes.string
    };
    Severity: Major
    Found in myems-web/src/components/page/Invoice.js and 12 other locations - About 35 mins to fix
    myems-web/src/components/MyEMS/Tenant/TenantBill.js on lines 82..86
    myems-web/src/components/MyEMS/auth/ChangePasswordForm.js on lines 133..137
    myems-web/src/components/MyEMS/auth/SentForgotPasswordEmailMessageForm.js on lines 238..242
    myems-web/src/components/MyEMS/auth/SentRegisterEmailMessageForm.js on lines 261..265
    myems-web/src/components/auth/ForgetPasswordForm.js on lines 49..53
    myems-web/src/components/common/accordion/Accordion.js on lines 23..27
    myems-web/src/components/dashboard-alt/StorageStatusProgressBar.js on lines 15..19
    myems-web/src/components/education/EducationInput.js on lines 21..25
    myems-web/src/components/experience/ExperienceInput.js on lines 21..25
    myems-web/src/components/feed/BirthdayNotice.js on lines 25..29
    myems-web/src/components/feed/ButtonImgPostCreate.js on lines 20..24
    myems-web/src/components/page/CustomerDetails.js on lines 102..106

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

    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

    There are no issues that match your filters.

    Category
    Status