AugurProject/augur-ui

View on GitHub
src/modules/notifications/actions/notifications.js

Summary

Maintainability
F
5 days
Test Coverage

Function loadNotifications has 101 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function loadNotifications() {
  return (dispatch, getState) => {
    const { notifications, transactionsData } = store.getState();
    for (let i = 0; i < notifications.length; i++) {
      if (notifications[i].status.toLowerCase() === PENDING) {
Severity: Major
Found in src/modules/notifications/actions/notifications.js - About 4 hrs to fix

    File notifications.js has 302 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import store from "src/store";
    import { augur } from "services/augurjs";
    import * as notificationLevels from "modules/notifications/constants/notifications";
    import setNotificationText from "modules/notifications/actions/set-notification-text";
    import { createBigNumber } from "utils/create-big-number";
    Severity: Minor
    Found in src/modules/notifications/actions/notifications.js - About 3 hrs to fix

      Function handleFilledOnly has 65 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function handleFilledOnly(tradeInProgress = null) {
        return (dispatch, getState) => {
          const { notifications, transactionsData } = store.getState();
          for (let i = 0; i < notifications.length; i++) {
            if (notifications[i].status.toLowerCase() === PENDING) {
      Severity: Major
      Found in src/modules/notifications/actions/notifications.js - About 2 hrs to fix

        Function updateNotification has 53 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export function updateNotification(id, notification) {
          return (dispatch, getState) => {
            const callback = notification => {
              const fullNotification = {
                type: UPDATE_NOTIFICATION,
        Severity: Major
        Found in src/modules/notifications/actions/notifications.js - About 2 hrs to fix

          Consider simplifying this complex logical expression.
          Open

                    if (
                      transactionsData[key].transactions &&
                      transactionsData[key].transactions.length &&
                      transactionsData[key].transactions[0].tradeGroupId ===
                        tradeGroupId &&
          Severity: Major
          Found in src/modules/notifications/actions/notifications.js - About 1 hr to fix

            Consider simplifying this complex logical expression.
            Open

                        if (
                          transactionsData[key].transactions &&
                          transactionsData[key].transactions.length &&
                          transactionsData[key].transactions[0].tradeGroupId ===
                            tradeGroupId &&
            Severity: Major
            Found in src/modules/notifications/actions/notifications.js - About 1 hr to fix

              Avoid deeply nested control flow statements.
              Open

                            if (
                              transaction.meta &&
                              transaction.meta.txhash === notifications[i].id
                            ) {
                              dispatch(
              Severity: Major
              Found in src/modules/notifications/actions/notifications.js - About 45 mins to fix

                Consider simplifying this complex logical expression.
                Open

                          if (
                            notification.log &&
                            notifications[index].log &&
                            notification.log.eventName !== notifications[index].log.eventName &&
                            notifications[index].log.orderId &&
                Severity: Major
                Found in src/modules/notifications/actions/notifications.js - About 40 mins to fix

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

                              if (
                                transactionsData[key].transactions &&
                                transactionsData[key].transactions.length &&
                                transactionsData[key].transactions[0].tradeGroupId ===
                                  tradeGroupId &&
                  Severity: Major
                  Found in src/modules/notifications/actions/notifications.js and 1 other location - About 1 day to fix
                  src/modules/notifications/actions/notifications.js on lines 114..141

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

                  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

                            if (
                              transactionsData[key].transactions &&
                              transactionsData[key].transactions.length &&
                              transactionsData[key].transactions[0].tradeGroupId ===
                                tradeGroupId &&
                  Severity: Major
                  Found in src/modules/notifications/actions/notifications.js and 1 other location - About 1 day to fix
                  src/modules/notifications/actions/notifications.js on lines 70..97

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

                  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

                            } else if (
                              notifications[i].params.type.toUpperCase() === "CANCELORDER" &&
                              transactionsData[key].status.toLowerCase() === SUCCESS
                            ) {
                              const groupedTransactions = transactionsData[key].transactions;
                  Severity: Major
                  Found in src/modules/notifications/actions/notifications.js and 1 other location - About 3 hrs to fix
                  src/modules/notifications/actions/notifications.js on lines 183..203

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

                  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

                            } else if (transactionsData[key].status.toLowerCase() === SUCCESS) {
                              const groupedTransactions = transactionsData[key].transactions;
                              groupedTransactions.forEach(transaction => {
                                if (
                                  transaction.meta &&
                  Severity: Major
                  Found in src/modules/notifications/actions/notifications.js and 1 other location - About 3 hrs to fix
                  src/modules/notifications/actions/notifications.js on lines 160..203

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

                  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