recurly/recurly-js

View on GitHub

Showing 179 of 179 total issues

Function xhr has 48 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  xhr ({ method, url, data }) {
    const error = (...args) => this.recurly.error(...args);

    return new Promise((resolve, reject) => {
      let req = new XHR;
Severity: Minor
Found in lib/recurly/request.js - About 1 hr to fix

    Function deepAssign has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    export default function deepAssign (target, ...sources) {
      if (!sources.length) return target;
      const source = sources.shift();
    
      if (isAssignableObject(target) && isAssignableObject(source)) {
    Severity: Minor
    Found in lib/util/deep-assign.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

            if (elems['tax_amount.now'] || elems['tax_amount.next']) {
              taxParams.amount = {
                now: (dom.value(elems['tax_amount.now']) || 0),
                next: (dom.value(elems['tax_amount.next']) || 0)
              };
    Severity: Major
    Found in lib/recurly/pricing/checkout/attachment.js and 1 other location - About 1 hr to fix
    lib/recurly/pricing/subscription/attachment.js on lines 119..124

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

    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 (elems['tax_amount.now'] || elems['tax_amount.next']) {
            taxParams.amount = {
              now: (dom.value(elems['tax_amount.now']) || 0),
              next: (dom.value(elems['tax_amount.next']) || 0)
            };
    Severity: Major
    Found in lib/recurly/pricing/subscription/attachment.js and 1 other location - About 1 hr to fix
    lib/recurly/pricing/checkout/attachment.js on lines 186..191

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

    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 preflight has 46 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      static preflight ({ recurly, number, month, year, gateway_code }) {
        const { preflightDeviceDataCollector } = recurly.config.risk.threeDSecure;
    
        if(!preflightDeviceDataCollector) {
          return Promise.resolve();
    Severity: Minor
    Found in lib/recurly/risk/three-d-secure/strategy/cybersource.js - About 1 hr to fix

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

        get ({ route, data, done, cached }) {
          return this.requestWithCallback({ method: 'get', route, data, done, cached });
        }
      Severity: Major
      Found in lib/recurly/request.js and 1 other location - About 1 hr to fix
      lib/recurly/request.js on lines 124..126

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

      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

        post ({ route, data, done, cached }) {
          return this.requestWithCallback({ method: 'post', route, data, done, cached });
        }
      Severity: Major
      Found in lib/recurly/request.js and 1 other location - About 1 hr to fix
      lib/recurly/request.js on lines 111..113

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

      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 parent has 45 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        parent () {
          // Check integrity of hostedFields. If fields are dead or
          // do not match chosen selectors, reset
          let reset = (
            this.hostedFields
      Severity: Minor
      Found in lib/recurly.js - About 1 hr to fix

        Function getTieredPricingValues has 44 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export function getTieredPricingValues (
          addOn,
          selectedNumUnits,
          currencyCode,
        ) {
        Severity: Minor
        Found in lib/recurly/pricing/subscription/tiered-pricing-calculator.js - About 1 hr to fix

          Function activateKountProfile has 43 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            activateKountProfile (params) {
              debug('activating Kount profiles');
              const configuredForm = this.recurly.config.fraud.kount.form;
              const sessionIdInputElement = dom.createHiddenInput({
                'data-recurly': 'fraud_session_id',
          Severity: Minor
          Found in lib/recurly/fraud.js - About 1 hr to fix

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

              function complete (err, res) {
                if (err) return done(err);
                if (customerData.fields.token && res.id) {
                  customerData.fields.token.value = res.id;
                }
            Severity: Major
            Found in lib/recurly/token.js and 1 other location - About 1 hr to fix
            lib/recurly/bank-account.js on lines 109..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 69.

            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

                done: (err, res) => {
                  if (err) return done(err);
                  if (data.fields.token && res.id) {
                    data.fields.token.value = res.id;
                  }
            Severity: Major
            Found in lib/recurly/bank-account.js and 1 other location - About 1 hr to fix
            lib/recurly/token.js on lines 182..188

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

            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 subscription has 42 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              subscription (subscription) {
                return new PricingPromise((resolve, reject) => {
                  if (!(subscription instanceof SubscriptionPricing)) {
                    return this.error(errors('invalid-option', {
                      name: 'subscription',
            Severity: Minor
            Found in lib/recurly/pricing/checkout/index.js - About 1 hr to fix

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

                fail (reason, options) {
                  if (this.failure) return;
                  debug('Failure scenario encountered', reason, options);
                  const failure = this.failure = this.error(reason, options);
                  this.emit('fail', failure);
              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 66..71

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

              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

                fail (reason, options) {
                  if (this.failure) return;
                  debug('Failure scenario encountered', reason, options);
                  const failure = this.failure = this.error(reason, options);
                  this.emit('fail', failure);
              Severity: Major
              Found in lib/recurly/venmo/strategy/index.js and 1 other location - About 1 hr to fix
              lib/recurly/paypal/strategy/index.js on lines 106..111

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

              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 41 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                attach (element) {
                  super.attach(element);
              
              
                  this.whenReady(() => {
              Severity: Minor
              Found in lib/recurly/risk/three-d-secure/strategy/braintree.js - About 1 hr to fix

                Function createAndMountWebComponent has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  async createAndMountWebComponent (paymentMethodData) {
                    const adyenOpts = this.options.adyen || {};
                
                    const checkout = await window.AdyenCheckout({
                      clientKey: adyenOpts.publicKey,
                Severity: Minor
                Found in lib/recurly/alternative-payment-methods/gateways/adyen.js - About 1 hr to fix

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

                      const modules = () => {
                        if (this.braintreeClientAvailable('venmo')) part();
                        else get('venmo', part);
                        if (this.braintreeClientAvailable('dataCollector')) part();
                        else get('data-collector', part);
                  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 43..48

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

                  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 modules = () => {
                        if (this.braintreeClientAvailable('paypal')) part();
                        else get('paypal', part);
                        if (this.braintreeClientAvailable('dataCollector')) part();
                        else get('data-collector', part);
                  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 46..51

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

                  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 googlePay has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  const googlePay = (recurly, options) => {
                    const emitter = new Emitter();
                    const handleErr = err => emitter.emit('error', err);
                    let gatewayCodeSelected;
                  
                  
                  Severity: Minor
                  Found in lib/recurly/google-pay/google-pay.js - About 1 hr to fix
                    Severity
                    Category
                    Status
                    Source
                    Language