TryGhost/Ghost

View on GitHub
ghost/members-api/lib/repositories/MemberRepository.js

Summary

Maintainability
F
3 wks
Test Coverage

File MemberRepository.js has 1296 lines of code (exceeds 250 allowed). Consider refactoring.
Open

const _ = require('lodash');
const errors = require('@tryghost/errors');
const logging = require('@tryghost/logging');
const tpl = require('@tryghost/tpl');
const DomainEvents = require('@tryghost/domain-events');
Severity: Major
Found in ghost/members-api/lib/repositories/MemberRepository.js - About 3 days to fix

    Function linkSubscription has a Cognitive Complexity of 132 (exceeds 5 allowed). Consider refactoring.
    Open

        async linkSubscription(data, options = {}) {
            if (!this._stripeAPIService.configured) {
                throw new errors.BadRequestError({message: tpl(messages.noStripeConnection, {action: 'link Stripe Subscription'})});
            }
    
    
    Severity: Minor
    Found in ghost/members-api/lib/repositories/MemberRepository.js - About 2 days 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 linkSubscription has 325 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        async linkSubscription(data, options = {}) {
            if (!this._stripeAPIService.configured) {
                throw new errors.BadRequestError({message: tpl(messages.noStripeConnection, {action: 'link Stripe Subscription'})});
            }
    
    
    Severity: Major
    Found in ghost/members-api/lib/repositories/MemberRepository.js - About 1 day to fix

      Function update has a Cognitive Complexity of 70 (exceeds 5 allowed). Consider refactoring.
      Open

          async update(data, options) {
              const sharedOptions = {
                  transacting: options.transacting
              };
      
      
      Severity: Minor
      Found in ghost/members-api/lib/repositories/MemberRepository.js - About 1 day 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 update has 209 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          async update(data, options) {
              const sharedOptions = {
                  transacting: options.transacting
              };
      
      
      Severity: Major
      Found in ghost/members-api/lib/repositories/MemberRepository.js - About 1 day to fix

        Function create has 123 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            async create(data, options) {
                if (!options) {
                    options = {};
                }
        
        
        Severity: Major
        Found in ghost/members-api/lib/repositories/MemberRepository.js - About 4 hrs to fix

          Function create has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
          Open

              async create(data, options) {
                  if (!options) {
                      options = {};
                  }
          
          
          Severity: Minor
          Found in ghost/members-api/lib/repositories/MemberRepository.js - About 4 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 setComplimentarySubscription has 108 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              async setComplimentarySubscription(data, options = {}) {
                  if (!options.transacting) {
                      return this._Member.transaction((transacting) => {
                          return this.setComplimentarySubscription(data, {
                              ...options,
          Severity: Major
          Found in ghost/members-api/lib/repositories/MemberRepository.js - About 4 hrs to fix

            Function updateSubscription has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
            Open

                async updateSubscription(data, options) {
                    const sharedOptions = {
                        transacting: options ? options.transacting : null
                    };
                    if (!this._stripeAPIService.configured) {
            Severity: Minor
            Found in ghost/members-api/lib/repositories/MemberRepository.js - About 3 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 updateSubscription has 88 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                async updateSubscription(data, options) {
                    const sharedOptions = {
                        transacting: options ? options.transacting : null
                    };
                    if (!this._stripeAPIService.configured) {
            Severity: Major
            Found in ghost/members-api/lib/repositories/MemberRepository.js - About 3 hrs to fix

              exports has 28 functions (exceeds 20 allowed). Consider refactoring.
              Open

              module.exports = class MemberRepository {
                  /**
                   * @param {object} deps
                   * @param {any} deps.Member
                   * @param {any} deps.MemberNewsletter
              Severity: Minor
              Found in ghost/members-api/lib/repositories/MemberRepository.js - About 3 hrs to fix

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

                    async bulkEdit(data, options) {
                        const {all, filter, search} = options;
                
                        if (!['unsubscribe', 'addLabel', 'removeLabel'].includes(data.action)) {
                            throw new errors.IncorrectUsageError({
                Severity: Major
                Found in ghost/members-api/lib/repositories/MemberRepository.js - About 2 hrs to fix

                  Function getMRR has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                  Open

                      getMRR({interval, amount, status = null, canceled = false, discount = null}) {
                          if (status === 'trialing') {
                              return 0;
                          }
                          if (status === 'incomplete') {
                  Severity: Minor
                  Found in ghost/members-api/lib/repositories/MemberRepository.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 bulkEdit has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                      async bulkEdit(data, options) {
                          const {all, filter, search} = options;
                  
                          if (!['unsubscribe', 'addLabel', 'removeLabel'].includes(data.action)) {
                              throw new errors.IncorrectUsageError({
                  Severity: Minor
                  Found in ghost/members-api/lib/repositories/MemberRepository.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 setComplimentarySubscription has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                      async setComplimentarySubscription(data, options = {}) {
                          if (!options.transacting) {
                              return this._Member.transaction((transacting) => {
                                  return this.setComplimentarySubscription(data, {
                                      ...options,
                  Severity: Minor
                  Found in ghost/members-api/lib/repositories/MemberRepository.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 getMRR has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      getMRR({interval, amount, status = null, canceled = false, discount = null}) {
                          if (status === 'trialing') {
                              return 0;
                          }
                          if (status === 'incomplete') {
                  Severity: Minor
                  Found in ghost/members-api/lib/repositories/MemberRepository.js - About 1 hr to fix

                    Function cancelSubscription has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        async cancelSubscription(data, options) {
                            const sharedOptions = {
                                transacting: options ? options.transacting : null
                            };
                            if (!this._stripeAPIService.configured) {
                    Severity: Minor
                    Found in ghost/members-api/lib/repositories/MemberRepository.js - About 1 hr to fix

                      Function destroy has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          async destroy(data, options) {
                              const member = await this._Member.findOne(data, options);
                      
                              if (!member) {
                                  // throw error?
                      Severity: Minor
                      Found in ghost/members-api/lib/repositories/MemberRepository.js - About 1 hr to fix

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

                            async createSubscription(data, options) {
                                if (!this._stripeAPIService.configured) {
                                    throw new errors.BadRequestError({message: tpl(messages.noStripeConnection, {action: 'create Stripe Subscription'})});
                                }
                                const member = await this._Member.findOne({
                        Severity: Minor
                        Found in ghost/members-api/lib/repositories/MemberRepository.js - About 1 hr to fix

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

                              constructor({
                                  Member,
                                  MemberNewsletter,
                                  MemberCancelEvent,
                                  MemberSubscribeEventModel,
                          Severity: Minor
                          Found in ghost/members-api/lib/repositories/MemberRepository.js - About 1 hr to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                    if (dontAllowToRemoveProductsIds.includes(deleteId)) {
                                                        throw new errors.BadRequestError({message: tpl(messages.deleteProductWithActiveSubscription)});
                                                    }
                            Severity: Major
                            Found in ghost/members-api/lib/repositories/MemberRepository.js - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                      if (this.isActiveSubscriptionStatus(subscriptionModel.get('status')) && subscriptionModel.id !== model.id) {
                                                          try {
                                                              const subscriptionProduct = await this._productRepository.get({stripe_price_id: subscriptionModel.get('stripe_price_id')}, options);
                                                              if (subscriptionProduct && previousProduct && subscriptionProduct.id === previousProduct.id) {
                                                                  activeSubscriptionForPreviousProduct = true;
                              Severity: Major
                              Found in ghost/members-api/lib/repositories/MemberRepository.js - About 45 mins to fix

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

                                    async destroy(data, options) {
                                        const member = await this._Member.findOne(data, options);
                                
                                        if (!member) {
                                            // throw error?
                                Severity: Minor
                                Found in ghost/members-api/lib/repositories/MemberRepository.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 cancelComplimentarySubscription has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                Open

                                    async cancelComplimentarySubscription({id}, options) {
                                        if (!this._stripeAPIService.configured) {
                                            throw new errors.BadRequestError({message: tpl(messages.noStripeConnection, {action: 'cancel Complimentary Subscription'})});
                                        }
                                
                                
                                Severity: Minor
                                Found in ghost/members-api/lib/repositories/MemberRepository.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

                                Avoid too many return statements within this function.
                                Open

                                            return amountWithDiscount * 30;
                                Severity: Major
                                Found in ghost/members-api/lib/repositories/MemberRepository.js - About 30 mins to fix

                                  Avoid too many return statements within this function.
                                  Open

                                              return 0;
                                  Severity: Major
                                  Found in ghost/members-api/lib/repositories/MemberRepository.js - About 30 mins to fix

                                    Avoid too many return statements within this function.
                                    Open

                                                return amountWithDiscount * 4;
                                    Severity: Major
                                    Found in ghost/members-api/lib/repositories/MemberRepository.js - About 30 mins to fix

                                      Avoid too many return statements within this function.
                                      Open

                                                  return amountWithDiscount;
                                      Severity: Major
                                      Found in ghost/members-api/lib/repositories/MemberRepository.js - About 30 mins to fix

                                        Avoid too many return statements within this function.
                                        Open

                                                    return Math.floor(amountWithDiscount / 12);
                                        Severity: Major
                                        Found in ghost/members-api/lib/repositories/MemberRepository.js - About 30 mins to fix

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

                                              async cancelSubscription(data, options) {
                                                  const sharedOptions = {
                                                      transacting: options ? options.transacting : null
                                                  };
                                                  if (!this._stripeAPIService.configured) {
                                          Severity: Minor
                                          Found in ghost/members-api/lib/repositories/MemberRepository.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 _resolveContextSource has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                          Open

                                              _resolveContextSource(context) {
                                                  let source;
                                          
                                                  if (context.import || context.importer) {
                                                      source = 'import';
                                          Severity: Minor
                                          Found in ghost/members-api/lib/repositories/MemberRepository.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

                                                                      try {
                                                                          const subscriptionProduct = await this._productRepository.get({stripe_price_id: subscriptionModel.get('stripe_price_id')}, options);
                                                                          if (subscriptionProduct && previousProduct && subscriptionProduct.id === previousProduct.id) {
                                                                              activeSubscriptionForPreviousProduct = true;
                                                                          }
                                          Severity: Major
                                          Found in ghost/members-api/lib/repositories/MemberRepository.js and 1 other location - About 7 hrs to fix
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1218..1232

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

                                          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

                                                              try {
                                                                  const subscriptionProduct = await this._productRepository.get({stripe_price_id: subscriptionModel.get('stripe_price_id')}, options);
                                                                  if (subscriptionProduct && ghostProduct && subscriptionProduct.id === ghostProduct.id) {
                                                                      activeSubscriptionForGhostProduct = true;
                                                                  }
                                          Severity: Major
                                          Found in ghost/members-api/lib/repositories/MemberRepository.js and 1 other location - About 7 hrs to fix
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1179..1193

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

                                          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

                                              _resolveContextSource(context) {
                                                  let source;
                                          
                                                  if (context.import || context.importer) {
                                                      source = 'import';
                                          Severity: Major
                                          Found in ghost/members-api/lib/repositories/MemberRepository.js and 1 other location - About 3 hrs to fix
                                          ghost/member-attribution/lib/MemberAttributionService.js on lines 187..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 113.

                                          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 (member.attributes.status !== member._previousAttributes.status) {
                                                      await this._MemberStatusEvent.add({
                                                          member_id: member.id,
                                                          from_status: member._previousAttributes.status,
                                                          to_status: member.get('status')
                                          Severity: Major
                                          Found in ghost/members-api/lib/repositories/MemberRepository.js and 1 other location - About 2 hrs to fix
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 653..659

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

                                          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 (member.attributes.email !== member._previousAttributes.email) {
                                                      await this._MemberEmailChangeEvent.add({
                                                          member_id: member.id,
                                                          from_email: member._previousAttributes.email,
                                                          to_email: member.get('email')
                                          Severity: Major
                                          Found in ghost/members-api/lib/repositories/MemberRepository.js and 1 other location - About 2 hrs to fix
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 661..667

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

                                          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

                                                      const event = SubscriptionCreatedEvent.create({
                                                          source,
                                                          tierId: ghostProduct?.get('id'),
                                                          memberId: member.id,
                                                          subscriptionId: subscriptionModel.get('id'),
                                          Severity: Major
                                          Found in ghost/members-api/lib/repositories/MemberRepository.js and 1 other location - About 2 hrs to fix
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1140..1148

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

                                          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

                                                          const activatedEvent = SubscriptionActivatedEvent.create({
                                                              source,
                                                              tierId: ghostProduct?.get('id'),
                                                              memberId: member.id,
                                                              subscriptionId: subscriptionModel.get('id'),
                                          Severity: Major
                                          Found in ghost/members-api/lib/repositories/MemberRepository.js and 1 other location - About 2 hrs to fix
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1128..1136

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

                                          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 (!filter && !search && (!all || all !== true)) {
                                                      throw new errors.IncorrectUsageError({
                                                          message: tpl(messages.bulkActionRequiresFilter, {action: 'bulk edit'})
                                                      });
                                                  }
                                          Severity: Major
                                          Found in ghost/members-api/lib/repositories/MemberRepository.js and 1 other location - About 1 hr to fix
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 732..736

                                          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

                                                  if (!filter && !search && (!all || all !== true)) {
                                                      throw new errors.IncorrectUsageError({
                                                          message: tpl(messages.bulkActionRequiresFilter, {action: 'bulk delete'})
                                                      });
                                                  }
                                          Severity: Major
                                          Found in ghost/members-api/lib/repositories/MemberRepository.js and 1 other location - About 1 hr to fix
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 769..773

                                          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

                                          const messages = {
                                              noStripeConnection: 'Cannot {action} without a Stripe Connection',
                                              moreThanOneProduct: 'A member cannot have more than one Product',
                                              addProductWithActiveSubscription: 'Cannot add comped Products to a Member with active Subscriptions',
                                              deleteProductWithActiveSubscription: 'Cannot delete a non-comped Product from a Member, because it has an active Subscription for the same product',
                                          Severity: Major
                                          Found in ghost/members-api/lib/repositories/MemberRepository.js and 1 other location - About 1 hr to fix
                                          ghost/core/core/server/models/post.js on lines 25..36

                                          Duplicated Code

                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                          Tuning

                                          This issue has a mass of 58.

                                          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 (data.id) {
                                                      findQuery = {id: data.id};
                                                  } else if (data.email) {
                                                      findQuery = {email: data.email};
                                                  }
                                          Severity: Major
                                          Found in ghost/members-api/lib/repositories/MemberRepository.js and 1 other location - About 1 hr to fix
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1370..1374

                                          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

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

                                                  if (data.id) {
                                                      findQuery = {id: data.id};
                                                  } else if (data.email) {
                                                      findQuery = {email: data.email};
                                                  }
                                          Severity: Major
                                          Found in ghost/members-api/lib/repositories/MemberRepository.js and 1 other location - About 1 hr to fix
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1326..1330

                                          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 2 locations. Consider refactoring.
                                          Open

                                                  for (const newsletterToAdd of newslettersToAdd) {
                                                      await this._MemberSubscribeEvent.add({
                                                          member_id: member.id,
                                                          newsletter_id: newsletterToAdd,
                                                          subscribed: true,
                                          Severity: Major
                                          Found in ghost/members-api/lib/repositories/MemberRepository.js and 1 other location - About 1 hr to fix
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 637..644

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

                                          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

                                                  for (const newsletterToRemove of newslettersToRemove) {
                                                      await this._MemberSubscribeEvent.add({
                                                          member_id: member.id,
                                                          newsletter_id: newsletterToRemove,
                                                          subscribed: false,
                                          Severity: Major
                                          Found in ghost/members-api/lib/repositories/MemberRepository.js and 1 other location - About 1 hr to fix
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 628..635

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

                                          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 5 locations. Consider refactoring.
                                          Open

                                                  if (!options.transacting) {
                                                      return this._Member.transaction((transacting) => {
                                                          return this.setComplimentarySubscription(data, {
                                                              ...options,
                                                              transacting
                                          Severity: Major
                                          Found in ghost/members-api/lib/repositories/MemberRepository.js and 4 other locations - About 1 hr to fix
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 888..895
                                          ghost/members-api/lib/repositories/ProductRepository.js on lines 82..89
                                          ghost/members-api/lib/repositories/ProductRepository.js on lines 174..181
                                          ghost/members-api/lib/repositories/ProductRepository.js on lines 348..355

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

                                          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 5 locations. Consider refactoring.
                                          Open

                                                  if (!options.transacting) {
                                                      return this._Member.transaction((transacting) => {
                                                          return this.linkSubscription(data, {
                                                              ...options,
                                                              transacting
                                          Severity: Major
                                          Found in ghost/members-api/lib/repositories/MemberRepository.js and 4 other locations - About 1 hr to fix
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1518..1525
                                          ghost/members-api/lib/repositories/ProductRepository.js on lines 82..89
                                          ghost/members-api/lib/repositories/ProductRepository.js on lines 174..181
                                          ghost/members-api/lib/repositories/ProductRepository.js on lines 348..355

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

                                          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._StripeCustomer.upsert({
                                                          customer_id: stripeCustomer.id,
                                                          member_id: data.id,
                                                          email: stripeCustomer.email,
                                                          name: stripeCustomer.name
                                          Severity: Major
                                          Found in ghost/members-api/lib/repositories/MemberRepository.js and 1 other location - About 1 hr to fix
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1494..1499

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

                                          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._StripeCustomer.add({
                                                          customer_id: stripeCustomer.id,
                                                          member_id: data.id,
                                                          email: stripeCustomer.email,
                                                          name: stripeCustomer.name
                                          Severity: Major
                                          Found in ghost/members-api/lib/repositories/MemberRepository.js and 1 other location - About 1 hr to fix
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1607..1612

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

                                          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 3 locations. Consider refactoring.
                                          Open

                                                          let zeroValuePrice = zeroValuePrices.find((p) => {
                                                              return p.currency.toLowerCase() === price.get('currency').toLowerCase();
                                                          });
                                          Severity: Major
                                          Found in ghost/members-api/lib/repositories/MemberRepository.js and 2 other locations - About 55 mins to fix
                                          ghost/core/core/server/models/member.js on lines 312..314
                                          ghost/core/core/server/models/product.js on lines 81..83

                                          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 4 locations. Consider refactoring.
                                          Open

                                                  const subscription = await member.related('stripeSubscriptions').query({
                                                      where: {
                                                          subscription_id: data.subscription.subscription_id
                                                      }
                                                  }).fetchOne(options);
                                          Severity: Major
                                          Found in ghost/members-api/lib/repositories/MemberRepository.js and 3 other locations - About 55 mins to fix
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 905..909
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1338..1342
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1382..1386

                                          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

                                                  const customer = await member.related('stripeCustomers').query({
                                                      where: {
                                                          customer_id: data.subscription.customer
                                                      }
                                                  }).fetchOne(options);
                                          Severity: Major
                                          Found in ghost/members-api/lib/repositories/MemberRepository.js and 3 other locations - About 55 mins to fix
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1304..1308
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1338..1342
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1382..1386

                                          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

                                                  const subscription = await member.related('stripeSubscriptions').query({
                                                      where: {
                                                          subscription_id: data.subscription.subscription_id
                                                      }
                                                  }).fetchOne(options);
                                          Severity: Major
                                          Found in ghost/members-api/lib/repositories/MemberRepository.js and 3 other locations - About 55 mins to fix
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 905..909
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1304..1308
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1382..1386

                                          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

                                                  const subscriptionModel = await member.related('stripeSubscriptions').query({
                                                      where: {
                                                          subscription_id: data.subscription.subscription_id
                                                      }
                                                  }).fetchOne(options);
                                          Severity: Major
                                          Found in ghost/members-api/lib/repositories/MemberRepository.js and 3 other locations - About 55 mins to fix
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 905..909
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1304..1308
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1338..1342

                                          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 2 locations. Consider refactoring.
                                          Open

                                                  return await this._StripeCustomer.upsert({
                                                      customer_id: data.customer_id,
                                                      member_id: data.member_id,
                                                      name: data.name,
                                                      email: data.email
                                          Severity: Minor
                                          Found in ghost/members-api/lib/repositories/MemberRepository.js and 1 other location - About 50 mins to fix
                                          ghost/payments/lib/PaymentsService.js on lines 171..176

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

                                          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 3 locations. Consider refactoring.
                                          Open

                                                  for (const productToAdd of productsToAdd) {
                                                      await this._MemberProductEvent.add({
                                                          member_id: member.id,
                                                          product_id: productToAdd,
                                                          action: 'added'
                                          Severity: Major
                                          Found in ghost/members-api/lib/repositories/MemberRepository.js and 2 other locations - About 50 mins to fix
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 608..614
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1277..1283

                                          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 3 locations. Consider refactoring.
                                          Open

                                                  for (const productToAdd of productsToAdd) {
                                                      await this._MemberProductEvent.add({
                                                          member_id: member.id,
                                                          product_id: productToAdd,
                                                          action: 'added'
                                          Severity: Major
                                          Found in ghost/members-api/lib/repositories/MemberRepository.js and 2 other locations - About 50 mins to fix
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1269..1275
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1277..1283

                                          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 3 locations. Consider refactoring.
                                          Open

                                                  for (const productToRemove of productsToRemove) {
                                                      await this._MemberProductEvent.add({
                                                          member_id: member.id,
                                                          product_id: productToRemove,
                                                          action: 'removed'
                                          Severity: Major
                                          Found in ghost/members-api/lib/repositories/MemberRepository.js and 2 other locations - About 50 mins to fix
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 608..614
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1269..1275

                                          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 8 locations. Consider refactoring.
                                          Open

                                                  if (!this._stripeAPIService.configured) {
                                                      throw new errors.BadRequestError({message: tpl(messages.noStripeConnection, {action: 'link Stripe Subscription'})});
                                                  }
                                          Severity: Major
                                          Found in ghost/members-api/lib/repositories/MemberRepository.js and 7 other locations - About 40 mins to fix
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 836..838
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1296..1298
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1321..1323
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1365..1367
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1469..1471
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1527..1529
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1655..1657

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

                                          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 8 locations. Consider refactoring.
                                          Open

                                                  if (!this._stripeAPIService.configured) {
                                                      throw new errors.BadRequestError({message: tpl(messages.noStripeConnection, {action: 'get Stripe Subscription'})});
                                                  }
                                          Severity: Major
                                          Found in ghost/members-api/lib/repositories/MemberRepository.js and 7 other locations - About 40 mins to fix
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 836..838
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 884..886
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1321..1323
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1365..1367
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1469..1471
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1527..1529
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1655..1657

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

                                          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 8 locations. Consider refactoring.
                                          Open

                                                  if (!this._stripeAPIService.configured) {
                                                      throw new errors.BadRequestError({message: tpl(messages.noStripeConnection, {action: 'link Stripe Customer'})});
                                                  }
                                          Severity: Major
                                          Found in ghost/members-api/lib/repositories/MemberRepository.js and 7 other locations - About 40 mins to fix
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 884..886
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1296..1298
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1321..1323
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1365..1367
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1469..1471
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1527..1529
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1655..1657

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

                                          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 8 locations. Consider refactoring.
                                          Open

                                                  if (!this._stripeAPIService.configured) {
                                                      throw new errors.BadRequestError({message: tpl(messages.noStripeConnection, {action: 'create Stripe Subscription'})});
                                                  }
                                          Severity: Major
                                          Found in ghost/members-api/lib/repositories/MemberRepository.js and 7 other locations - About 40 mins to fix
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 836..838
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 884..886
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1296..1298
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1321..1323
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1365..1367
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1527..1529
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1655..1657

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

                                          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 8 locations. Consider refactoring.
                                          Open

                                                  if (!this._stripeAPIService.configured) {
                                                      throw new errors.BadRequestError({message: tpl(messages.noStripeConnection, {action: 'update Stripe Subscription'})});
                                                  }
                                          Severity: Major
                                          Found in ghost/members-api/lib/repositories/MemberRepository.js and 7 other locations - About 40 mins to fix
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 836..838
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 884..886
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1296..1298
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1321..1323
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1469..1471
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1527..1529
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1655..1657

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

                                          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 8 locations. Consider refactoring.
                                          Open

                                                  if (!this._stripeAPIService.configured) {
                                                      throw new errors.BadRequestError({message: tpl(messages.noStripeConnection, {action: 'create Complimentary Subscription'})});
                                                  }
                                          Severity: Major
                                          Found in ghost/members-api/lib/repositories/MemberRepository.js and 7 other locations - About 40 mins to fix
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 836..838
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 884..886
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1296..1298
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1321..1323
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1365..1367
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1469..1471
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1655..1657

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

                                          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 8 locations. Consider refactoring.
                                          Open

                                                  if (!this._stripeAPIService.configured) {
                                                      throw new errors.BadRequestError({message: tpl(messages.noStripeConnection, {action: 'cancel Complimentary Subscription'})});
                                                  }
                                          Severity: Major
                                          Found in ghost/members-api/lib/repositories/MemberRepository.js and 7 other locations - About 40 mins to fix
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 836..838
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 884..886
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1296..1298
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1321..1323
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1365..1367
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1469..1471
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1527..1529

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

                                          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 8 locations. Consider refactoring.
                                          Open

                                                  if (!this._stripeAPIService.configured) {
                                                      throw new errors.BadRequestError({message: tpl(messages.noStripeConnection, {action: 'update Stripe Subscription'})});
                                                  }
                                          Severity: Major
                                          Found in ghost/members-api/lib/repositories/MemberRepository.js and 7 other locations - About 40 mins to fix
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 836..838
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 884..886
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1296..1298
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1365..1367
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1469..1471
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1527..1529
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1655..1657

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

                                          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 3 locations. Consider refactoring.
                                          Open

                                                  if (!subscription) {
                                                      throw new errors.NotFoundError({message: tpl(messages.subscriptionNotFound, {id: data.subscription.subscription_id})});
                                                  }
                                          Severity: Major
                                          Found in ghost/members-api/lib/repositories/MemberRepository.js and 2 other locations - About 40 mins to fix
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1344..1346
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1388..1390

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

                                          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 3 locations. Consider refactoring.
                                          Open

                                                  if (!subscriptionModel) {
                                                      throw new errors.NotFoundError({message: tpl(messages.subscriptionNotFound, {id: data.subscription.subscription_id})});
                                                  }
                                          Severity: Major
                                          Found in ghost/members-api/lib/repositories/MemberRepository.js and 2 other locations - About 40 mins to fix
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1310..1312
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1344..1346

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

                                          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 3 locations. Consider refactoring.
                                          Open

                                                  if (!subscription) {
                                                      throw new errors.NotFoundError({message: tpl(messages.subscriptionNotFound, {id: data.subscription.subscription_id})});
                                                  }
                                          Severity: Major
                                          Found in ghost/members-api/lib/repositories/MemberRepository.js and 2 other locations - About 40 mins to fix
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1310..1312
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1388..1390

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

                                          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 (!activeSubscriptionForGhostProduct) {
                                                          // We don't have an active subscription for this product anymore, so we can safely unlink it from the member
                                                          memberProducts = memberProducts.filter((product) => {
                                                              return product.id !== ghostProduct.id;
                                                          });
                                          Severity: Minor
                                          Found in ghost/members-api/lib/repositories/MemberRepository.js and 1 other location - About 35 mins to fix
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1197..1202

                                          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

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

                                                              if (!activeSubscriptionForPreviousProduct) {
                                                                  // We can safely remove the product from this member because it doesn't have any other remaining active subscription for it
                                                                  memberProducts = memberProducts.filter((product) => {
                                                                      return product.id !== previousProduct.id;
                                                                  });
                                          Severity: Minor
                                          Found in ghost/members-api/lib/repositories/MemberRepository.js and 1 other location - About 35 mins to fix
                                          ghost/members-api/lib/repositories/MemberRepository.js on lines 1236..1241

                                          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