recurly/recurly-js

View on GitHub

Showing 179 of 179 total issues

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

  error (...params) {
    let err = params[0] instanceof Error ? params[0] : errors(...params);
    this.emit('error', err);
    return err;
  }
Severity: Major
Found in lib/recurly/paypal/strategy/index.js and 1 other location - About 1 hr to fix
lib/recurly/venmo/strategy/index.js on lines 81..85

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

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

function token (customerData, bus, done) {
  debug('token');
  debug('customerData', customerData);

  const inputs = customerData.values;
Severity: Minor
Found in lib/recurly/token.js - About 1 hr to fix

    Function tokenDispatcher has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    export function tokenDispatcher (...args) {
      let bus, elements, customerData, done;
    
      // signature variance
      if (args[0] instanceof Elements) {
    Severity: Minor
    Found in lib/recurly/token.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 discountAmounts has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

      discountAmounts () {
        const coupon = this.items.coupon;
        let discountNow = 0;
        let discountNext = 0;
        if (coupon) {
    Severity: Minor
    Found in lib/recurly/pricing/checkout/calculations.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

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

      destroy () {
        const { strategy } = this;
        if (strategy) {
          strategy.destroy();
          delete this.strategy;
    Severity: Major
    Found in lib/recurly/paypal/index.js and 1 other location - About 1 hr to fix
    lib/recurly/venmo/index.js on lines 47..54

    Duplicated Code

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

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

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

    Tuning

    This issue has a mass of 59.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

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

            }, (error, venmo) => {
              if (error) return this.fail('venmo-braintree-api-error', { cause: error });
              debug('Venmo client created');
              this.venmo = venmo;
              this.emit('ready');
    Severity: Major
    Found in lib/recurly/venmo/strategy/braintree.js and 1 other location - About 1 hr to fix
    lib/recurly/paypal/strategy/braintree.js on lines 70..75

    Duplicated Code

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

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

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

    Tuning

    This issue has a mass of 59.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Function params has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      params (data) {
        const { fraud: fraudConfig } = this.recurly.config;
        let fraudParams = [];
        debug('creating fraud params', data, fraudConfig);
    
    
    Severity: Minor
    Found in lib/recurly/fraud.js - About 1 hr to fix

      Function runner has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function runner (config) {
        const cfg = Object.assign({}, staticConfig, {
          reporters: ['mocha'],
          logLevel: config.LOG_INFO,
          browsers: [BROWSER],
      Severity: Minor
      Found in karma.ci.conf.js - About 1 hr to fix

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

                braintree.paypal.create({ client }, (error, paypal) => {
                  if (error) return this.fail('paypal-braintree-api-error', { cause: error });
                  debug('PayPal client created');
                  this.paypal = paypal;
                  this.emit('ready');
        Severity: Major
        Found in lib/recurly/paypal/strategy/braintree.js and 1 other location - About 1 hr to fix
        lib/recurly/venmo/strategy/braintree.js on lines 81..86

        Duplicated Code

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

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

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

        Tuning

        This issue has a mass of 59.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Function attach has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          attach (element) {
            super.attach(element);
            debug('Initiating 3D Secure frame');
        
            const {
        Severity: Minor
        Found in lib/recurly/risk/three-d-secure/strategy/paypal-complete.js - About 1 hr to fix

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

              frame.once('error', cause => {
                if (cause.code === 'paypal-cancel') this.emit('cancel');
                this.error('paypal-tokenize-error', { cause });
              });
          Severity: Major
          Found in lib/recurly/paypal/strategy/direct.js and 1 other location - About 1 hr to fix
          lib/recurly/paypal/strategy/complete.js on lines 18..21

          Duplicated Code

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

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

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

          Tuning

          This issue has a mass of 59.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

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

            destroy () {
              const { strategy } = this;
              if (strategy) {
                strategy.destroy();
                delete this.strategy;
          Severity: Major
          Found in lib/recurly/venmo/index.js and 1 other location - About 1 hr to fix
          lib/recurly/paypal/index.js on lines 58..65

          Duplicated Code

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

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

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

          Tuning

          This issue has a mass of 59.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Function coupon has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            coupon (newCoupon, done) {
              // If the new coupon matches the current one, we just need to ensure it
              // still applies to the current plan
              if (~this.couponCodes.indexOf(newCoupon)) {
                return new PricingPromise((resolve, reject) => {
          Severity: Minor
          Found in lib/recurly/pricing/subscription/index.js - About 1 hr to fix

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

                frame.once('error', cause => {
                  if (cause.code === 'paypal-cancel') this.emit('cancel');
                  this.error('paypal-tokenize-error', { cause });
                });
            Severity: Major
            Found in lib/recurly/paypal/strategy/complete.js and 1 other location - About 1 hr to fix
            lib/recurly/paypal/strategy/direct.js on lines 28..31

            Duplicated Code

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

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

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

            Tuning

            This issue has a mass of 59.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Function validateOptions has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              async validateOptions () {
                const getMissingField = (options, fields) => {
                  for(const field of fields) {
                    if (!(field in options)) {
                      return field;

              Function tax has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                tax (done) {
                  this.price.now.tax = 0;
                  this.price.next.tax = 0;
              
                  // If tax amount has been specified, simply apply it
              Severity: Minor
              Found in lib/recurly/pricing/subscription/calculations.js - About 1 hr to fix

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

                  constructor (pricing, done) {
                    this.pricing = pricing;
                    this.items = pricing.items;
                    this._itemizedSets = { now: {}, next: {} };
                
                
                Severity: Minor
                Found in lib/recurly/pricing/checkout/calculations.js - About 1 hr to fix

                  Function buildApplePayPaymentRequest has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export default function buildApplePayPaymentRequest (applePay, options, cb) {
                    const { recurly, config } = applePay;
                    const paymentRequest = {
                      currencyCode: options.currency,
                      countryCode: options.country,
                  Severity: Minor
                  Found in lib/recurly/apple-pay/util/build-apple-pay-payment-request.js - About 1 hr to fix

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

                      error (...params) {
                        let err = params[0] instanceof Error ? params[0] : errors(...params);
                        this.emit('error', err);
                        return err;
                      }
                    Severity: Major
                    Found in lib/recurly/adyen.js and 1 other location - About 1 hr to fix
                    lib/recurly/bank-redirect.js on lines 110..115

                    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

                      error (...params) {
                        const err = params[0] instanceof Error ? params[0] : errors(...params);
                        this.emit('error', err);
                    
                        return err;
                    Severity: Major
                    Found in lib/recurly/bank-redirect.js and 1 other location - About 1 hr to fix
                    lib/recurly/adyen.js on lines 61..65

                    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

                    Severity
                    Category
                    Status
                    Source
                    Language