makeomatic/ms-payments

View on GitHub

Showing 20 of 93 total issues

Function createSaveToRedis has 66 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function createSaveToRedis(redis, message) {
  return function saveToRedis(data) {
    const { plan, plans } = data;
    const { meta, level, title } = message;
    const aliasedId = message.alias || plan.id;
Severity: Major
Found in src/actions/plan/create.js - About 2 hrs to fix

    Function saveToRedis has 64 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      return function saveToRedis(data) {
        const { plan, plans } = data;
        const { meta, level, title } = message;
        const aliasedId = message.alias || plan.id;
        const hidden = message.hidden || false;
    Severity: Major
    Found in src/actions/plan/create.js - About 2 hrs to fix

      Function updateRedis has 45 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function updateRedis(sale) {
        const { redis } = this;
        const { state } = sale;
      
        if (state !== 'approved') {
      Severity: Minor
      Found in src/actions/sale/execute.js - About 1 hr to fix

        Function processKeys has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function processKeys(amqp) {
          const { config, log, redis } = this;
          const { keyPrefix } = config.redis.options;
          const masterNode = getRedisMasterNode(redis, config);
          const pipeline = redis.pipeline();
        Severity: Minor
        Found in src/migrations/generate-users-ids/index.js - About 1 hr to fix

          Function cleanupCache has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function cleanupCache(_index) {
            const { redis, redisType, config } = this;
            const { keyPrefix } = config.redis.options;
            const keyPrefixLength = keyPrefix.length;
            const index = `${keyPrefix}${_index}`;
          Severity: Minor
          Found in src/list-utils.js - About 1 hr to fix

            Function agreementExecute has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

            async function agreementExecute({ params }) {
              const { config, redis, amqp } = this;
              const { token } = params;
            
              let agreementData;
            Severity: Minor
            Found in src/actions/agreement/execute.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 getUsers has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            async function getUsers(ctx, opts = {}) {
              const { audience, amqp, usersList, pulledUsers, pool } = ctx;
            
              // give 5 minutes based on due date
              const current = opts.start || moment().subtract(5, 'minutes').valueOf();
            Severity: Minor
            Found in src/actions/agreement/sync.js - About 1 hr to fix

              Function sendRequest has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function sendRequest(config, message) {
                const defaultMerchantPreferences = {
                  return_url: config.urls.plan_return,
                  cancel_url: config.urls.plan_cancel,
                  auto_bill_amount: 'YES',
              Severity: Minor
              Found in src/actions/plan/create.js - About 1 hr to fix

                Function saveAgreement has 7 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                async function saveAgreement(redis, token, agreement, owner, planId, creatorTaskId, finalizedAt) {
                Severity: Major
                Found in src/actions/agreement/execute.js - About 50 mins to fix

                  Function fetchUpdatedAgreement has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  async function fetchUpdatedAgreement(paypalCfg, log, agreementId, owner, token, creatorTaskId) {
                  Severity: Minor
                  Found in src/actions/agreement/execute.js - About 45 mins to fix

                    Function agreementBill has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                    async function agreementBill({ log, params }) {
                      const { agreement: id, username: owner, subscriptionInterval } = params;
                      const { amqp } = this;
                    
                      log.debug('billing %s on %s', owner, id);
                    Severity: Minor
                    Found in src/actions/agreement/bill.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 calculateDiscounts has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                    function calculateDiscounts(subscription, customSetupFee, skipSetupFee, trialDiscount, trialCycle) {
                    Severity: Minor
                    Found in src/actions/agreement/create.js - About 35 mins to fix

                      Function syncTransactions has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                      async function syncTransactions(dispatch, agreementId, owner, start, end) {
                      Severity: Minor
                      Found in src/utils/paypal/transactions.js - About 35 mins to fix

                        Function agreementState has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                        async function agreementState({ params: message }) {
                          const { config, redis, amqp, log } = this;
                          const { agreement: agreementId, state: action } = message;
                          const note = message.note || `Applying '${action}' operation to agreement`;
                        
                        
                        Severity: Minor
                        Found in src/actions/agreement/state.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 performSync has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                        async function performSync(ctx, { log }) {
                          const { agreements, txIds } = await getUpdatedTransactions(ctx);
                        
                          // done - nothing to sync
                          if (agreements.size === 0) {
                        Severity: Minor
                        Found in src/actions/transaction/sync-updated.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 transactionSync has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                        function transactionSync({ params: message = {} }) {
                          const { config, redis } = this;
                          const { paypal: paypalConfig } = config;
                        
                          function updateCommon(sale, owner) {
                        Severity: Minor
                        Found in src/actions/sale/sync.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 getPendingAgreements has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                        async function getPendingAgreements(ctx, query, opts = {}) {
                          const { service, pulledUsers, missingUsers, pendingAgreements, agreementOwners } = ctx;
                          const offset = opts.cursor || 0;
                        
                          const response = await service.dispatch('agreement.list', {
                        Severity: Minor
                        Found in src/actions/agreement/sync.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 calculateDiscounts has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                        function calculateDiscounts(subscription, customSetupFee, skipSetupFee, trialDiscount, trialCycle) {
                          const regularPayment = { ...subscription.definition.amount };
                          const setupFee = { ...regularPayment };
                          const extractCycle = skipSetupFee ? 0 : 1;
                          const normalizedTrialCycle = subscription.name === 'year'
                        Severity: Minor
                        Found in src/actions/agreement/create.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 createSaveToRedis has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                        function createSaveToRedis(redis, message) {
                          return function saveToRedis(data) {
                            const { plan, plans } = data;
                            const { meta, level, title } = message;
                            const aliasedId = message.alias || plan.id;
                        Severity: Minor
                        Found in src/actions/plan/create.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 updateRedis has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                        function updateRedis(sale) {
                          const { redis } = this;
                          const { state } = sale;
                        
                          if (state !== 'approved') {
                        Severity: Minor
                        Found in src/actions/sale/execute.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