TryGhost/Ghost

View on GitHub
ghost/stripe/lib/StripeMigrations.js

Summary

Maintainability
F
1 wk
Test Coverage

File StripeMigrations.js has 528 lines of code (exceeds 250 allowed). Consider refactoring.
Open

const _ = require('lodash');
const logging = require('@tryghost/logging');

module.exports = class StripeMigrations {
    /**
Severity: Major
Found in ghost/stripe/lib/StripeMigrations.js - About 1 day to fix

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

        async populateMembersMonthlyPriceIdSettings(options) {
            if (!options) {
                return this.models.Product.transaction((transacting) => {
                    return this.populateMembersMonthlyPriceIdSettings({transacting});
                });
    Severity: Major
    Found in ghost/stripe/lib/StripeMigrations.js - About 2 hrs to fix

      Function populateMembersYearlyPriceIdSettings has 63 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          async populateMembersYearlyPriceIdSettings(options) {
              if (!options) {
                  return this.models.Product.transaction((transacting) => {
                      return this.populateMembersYearlyPriceIdSettings({transacting});
                  });
      Severity: Major
      Found in ghost/stripe/lib/StripeMigrations.js - About 2 hrs to fix

        Function populateStripePricesFromStripePlansSetting has 61 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            async populateStripePricesFromStripePlansSetting(options) {
                if (!options) {
                    return this.models.Product.transaction((transacting) => {
                        return this.populateStripePricesFromStripePlansSetting({transacting});
                    });
        Severity: Major
        Found in ghost/stripe/lib/StripeMigrations.js - About 2 hrs to fix

          Function populateProductsAndPrices has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

              async populateProductsAndPrices(options) {
                  if (!options) {
                      return this.models.Product.transaction((transacting) => {
                          return this.populateProductsAndPrices({transacting});
                      });
          Severity: Minor
          Found in ghost/stripe/lib/StripeMigrations.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 populateProductsAndPrices has 59 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              async populateProductsAndPrices(options) {
                  if (!options) {
                      return this.models.Product.transaction((transacting) => {
                          return this.populateProductsAndPrices({transacting});
                      });
          Severity: Major
          Found in ghost/stripe/lib/StripeMigrations.js - About 2 hrs to fix

            Function updatePortalPlansSetting has 57 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                async updatePortalPlansSetting(plans, options) {
                    if (!options) {
                        return this.models.Product.transaction((transacting) => {
                            return this.updatePortalPlansSetting(plans, {transacting});
                        });
            Severity: Major
            Found in ghost/stripe/lib/StripeMigrations.js - About 2 hrs to fix

              Function revertPortalPlansSetting has 51 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  async revertPortalPlansSetting(options) {
                      if (!options) {
                          return this.models.Product.transaction((transacting) => {
                              return this.revertPortalPlansSetting({transacting});
                          });
              Severity: Major
              Found in ghost/stripe/lib/StripeMigrations.js - About 2 hrs to fix

                Function updatePortalPlansSetting has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                    async updatePortalPlansSetting(plans, options) {
                        if (!options) {
                            return this.models.Product.transaction((transacting) => {
                                return this.updatePortalPlansSetting(plans, {transacting});
                            });
                Severity: Minor
                Found in ghost/stripe/lib/StripeMigrations.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 populateStripePricesFromStripePlansSetting has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                    async populateStripePricesFromStripePlansSetting(options) {
                        if (!options) {
                            return this.models.Product.transaction((transacting) => {
                                return this.populateStripePricesFromStripePlansSetting({transacting});
                            });
                Severity: Minor
                Found in ghost/stripe/lib/StripeMigrations.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 revertPortalPlansSetting has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    async revertPortalPlansSetting(options) {
                        if (!options) {
                            return this.models.Product.transaction((transacting) => {
                                return this.revertPortalPlansSetting({transacting});
                            });
                Severity: Minor
                Found in ghost/stripe/lib/StripeMigrations.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 populateMembersMonthlyPriceIdSettings has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    async populateMembersMonthlyPriceIdSettings(options) {
                        if (!options) {
                            return this.models.Product.transaction((transacting) => {
                                return this.populateMembersMonthlyPriceIdSettings({transacting});
                            });
                Severity: Minor
                Found in ghost/stripe/lib/StripeMigrations.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 populateMembersYearlyPriceIdSettings has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    async populateMembersYearlyPriceIdSettings(options) {
                        if (!options) {
                            return this.models.Product.transaction((transacting) => {
                                return this.populateMembersYearlyPriceIdSettings({transacting});
                            });
                Severity: Minor
                Found in ghost/stripe/lib/StripeMigrations.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

                        if (!monthlyPrice) {
                            logging.info('Could not any active Monthly price - creating a new one');
                            let defaultStripeProduct;
                            const stripeProductsPage = await this.models.StripeProduct.findPage({...options, limit: 1});
                            defaultStripeProduct = stripeProductsPage.data[0];
                Severity: Major
                Found in ghost/stripe/lib/StripeMigrations.js and 1 other location - About 1 day to fix
                ghost/stripe/lib/StripeMigrations.js on lines 399..424

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

                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

                        if (!yearlyPrice) {
                            logging.info('Could not any active yearly price - creating a new one');
                            let defaultStripeProduct;
                            const stripeProductsPage = await this.models.StripeProduct.findPage({...options, limit: 1});
                            defaultStripeProduct = stripeProductsPage.data[0];
                Severity: Major
                Found in ghost/stripe/lib/StripeMigrations.js and 1 other location - About 1 day to fix
                ghost/stripe/lib/StripeMigrations.js on lines 323..348

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

                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

                    async populateDefaultProductMonthlyPriceId(options) {
                        if (!options) {
                            return this.models.Product.transaction((transacting) => {
                                return this.populateDefaultProductMonthlyPriceId({transacting});
                            });
                Severity: Major
                Found in ghost/stripe/lib/StripeMigrations.js and 1 other location - About 1 day to fix
                ghost/stripe/lib/StripeMigrations.js on lines 450..469

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

                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

                    async populateDefaultProductYearlyPriceId(options) {
                        if (!options) {
                            return this.models.Product.transaction((transacting) => {
                                return this.populateDefaultProductYearlyPriceId({transacting});
                            });
                Severity: Major
                Found in ghost/stripe/lib/StripeMigrations.js and 1 other location - About 1 day to fix
                ghost/stripe/lib/StripeMigrations.js on lines 429..448

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

                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

                            if (plan === 'monthly') {
                                const monthlyPlan = plans.find((planItem) => {
                                    return planItem.name === 'Monthly';
                                });
                                if (!monthlyPlan) {
                Severity: Major
                Found in ghost/stripe/lib/StripeMigrations.js and 1 other location - About 2 hrs to fix
                ghost/stripe/lib/StripeMigrations.js on lines 252..261

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

                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

                            if (plan === 'yearly') {
                                const yearlyPlan = plans.find((planItem) => {
                                    return planItem.name === 'Yearly';
                                });
                                if (!yearlyPlan) {
                Severity: Major
                Found in ghost/stripe/lib/StripeMigrations.js and 1 other location - About 2 hrs to fix
                ghost/stripe/lib/StripeMigrations.js on lines 242..251

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

                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

                        if (!yearlyPrice) {
                            logging.info('Could not find active yearly price from stripe_plans - searching by interval');
                            yearlyPrice = await this.models.StripePrice.where('amount', '>', 0)
                                .where({interval: 'year', active: true}).fetch(options);
                        }
                Severity: Major
                Found in ghost/stripe/lib/StripeMigrations.js and 1 other location - About 1 hr to fix
                ghost/stripe/lib/StripeMigrations.js on lines 317..321

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

                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

                        if (!monthlyPrice) {
                            logging.info('Could not find active Monthly price from stripe_plans - searching by interval');
                            monthlyPrice = await this.models.StripePrice.where('amount', '>', 0)
                                .where({interval: 'month', active: true}).fetch(options);
                        }
                Severity: Major
                Found in ghost/stripe/lib/StripeMigrations.js and 1 other location - About 1 hr to fix
                ghost/stripe/lib/StripeMigrations.js on lines 393..397

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

                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

                        try {
                            portalPlans = JSON.parse(portalPlansSetting.get('value'));
                        } catch (err) {
                            logging.error({
                                message: 'Could not parse portal_plans setting, skipping migration',
                Severity: Major
                Found in ghost/stripe/lib/StripeMigrations.js and 1 other location - About 1 hr to fix
                ghost/stripe/lib/StripeMigrations.js on lines 481..489

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

                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

                        try {
                            portalPlans = JSON.parse(portalPlansSetting.get('value'));
                        } catch (err) {
                            logging.error({
                                message: 'Could not parse portal_plans setting, skipping migration',
                Severity: Major
                Found in ghost/stripe/lib/StripeMigrations.js and 1 other location - About 1 hr to fix
                ghost/stripe/lib/StripeMigrations.js on lines 221..229

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

                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

                        monthlyPrice = await this.models.StripePrice.findOne({
                            amount: monthlyPlan.amount,
                            currency: monthlyPlan.currency,
                            interval: monthlyPlan.interval,
                            active: true
                Severity: Major
                Found in ghost/stripe/lib/StripeMigrations.js and 1 other location - About 1 hr to fix
                ghost/stripe/lib/StripeMigrations.js on lines 386..391

                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

                        yearlyPrice = await this.models.StripePrice.findOne({
                            amount: yearlyPlan.amount,
                            currency: yearlyPlan.currency,
                            interval: yearlyPlan.interval,
                            active: true
                Severity: Major
                Found in ghost/stripe/lib/StripeMigrations.js and 1 other location - About 1 hr to fix
                ghost/stripe/lib/StripeMigrations.js on lines 310..315

                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

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

                        await this.models.Settings.edit({
                            key: 'portal_plans',
                            value: JSON.stringify(newPortalPlans)
                        }, {
                            ...options,
                Severity: Minor
                Found in ghost/stripe/lib/StripeMigrations.js and 1 other location - About 55 mins to fix
                ghost/stripe/lib/StripeMigrations.js on lines 524..530

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

                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

                        await this.models.Settings.edit({
                            key: 'portal_plans',
                            value: JSON.stringify(newPortalPlans)
                        }, {
                            ...options,
                Severity: Minor
                Found in ghost/stripe/lib/StripeMigrations.js and 1 other location - About 55 mins to fix
                ghost/stripe/lib/StripeMigrations.js on lines 267..273

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

                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

                        await this.models.Settings.edit({key: 'members_monthly_price_id', value: monthlyPrice.id}, {...options, id: monthlyPriceId.id});
                Severity: Minor
                Found in ghost/stripe/lib/StripeMigrations.js and 1 other location - About 45 mins to fix
                ghost/stripe/lib/StripeMigrations.js on lines 426..426

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

                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

                        await this.models.Settings.edit({key: 'members_yearly_price_id', value: yearlyPrice.id}, {...options, id: yearlyPriceId.id});
                Severity: Minor
                Found in ghost/stripe/lib/StripeMigrations.js and 1 other location - About 45 mins to fix
                ghost/stripe/lib/StripeMigrations.js on lines 350..350

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

                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 {data} = await this.models.Product.findPage({
                            ...options,
                            limit: 1,
                            filter: 'type:paid'
                        });
                Severity: Minor
                Found in ghost/stripe/lib/StripeMigrations.js and 1 other location - About 30 mins to fix
                ghost/stripe/lib/StripeMigrations.js on lines 564..568

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

                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 {data} = await this.models.Product.findPage({
                            ...options,
                            limit: 1,
                            filter: 'type:paid'
                        });
                Severity: Minor
                Found in ghost/stripe/lib/StripeMigrations.js and 1 other location - About 30 mins to fix
                ghost/stripe/lib/StripeMigrations.js on lines 58..62

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

                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