recurly/recurly-js

View on GitHub

Showing 179 of 179 total issues

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

function token (options, done) {
  debug('token');

  const data = normalize(options, FIELDS);
  const inputs = data.values;
Severity: Minor
Found in lib/recurly/bank-account.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 constructor has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  constructor (pricing, done) {
    this.pricing = pricing;
    this.items = pricing.items;

    this.price = {
Severity: Minor
Found in lib/recurly/pricing/subscription/calculations.js - About 1 hr to fix

    Function addon has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      addon (addonCode, meta, done) {
        if (typeof meta === 'function') {
          done = meta;
          meta = undefined;
        }
    Severity: Minor
    Found in lib/recurly/pricing/subscription/index.js - About 1 hr to fix

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

            if (this.state.focus) {
              classes.push(`${prefix}-focus`);
              classes.push(`${prefix}-${this.config.type}-focus`);
            }
      Severity: Major
      Found in lib/recurly/hosted-field.js and 2 other locations - About 1 hr to fix
      lib/recurly/hosted-field.js on lines 67..73
      lib/recurly/hosted-field.js on lines 70..73

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

            } else if (!this.state.focus && !this.state.empty) {
              classes.push(`${prefix}-invalid`);
              classes.push(`${prefix}-${this.config.type}-invalid`);
            }
      Severity: Major
      Found in lib/recurly/hosted-field.js and 2 other locations - About 1 hr to fix
      lib/recurly/hosted-field.js on lines 62..65
      lib/recurly/hosted-field.js on lines 67..73

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

            if (this.state.valid) {
              classes.push(`${prefix}-valid`);
              classes.push(`${prefix}-${this.config.type}-valid`);
            } else if (!this.state.focus && !this.state.empty) {
              classes.push(`${prefix}-invalid`);
      Severity: Major
      Found in lib/recurly/hosted-field.js and 2 other locations - About 1 hr to fix
      lib/recurly/hosted-field.js on lines 62..65
      lib/recurly/hosted-field.js on lines 70..73

      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

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

        discountableSubtotals (coupon, { setupFees = true, taxExempt = true } = {}) {
          let discountableNow = 0;
          let discountableNext = 0;
      
          // adjustments
      Severity: Minor
      Found in lib/recurly/pricing/checkout/calculations.js - About 1 hr to fix

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

          getHostedFieldParentForm () {
            if (this._form) return this._form;
            const fields = this.recurly.config.fields;
            debug('form fields', fields);
            const selectors = Object.keys(fields)
        Severity: Minor
        Found in lib/recurly/fraud.js - About 1 hr to fix

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

          export function validateCardInputs (recurly, inputs) {
            const format = formatFieldValidationError;
            let errors = [];
          
            if (!cardNumber(inputs.number)) {
          Severity: Minor
          Found in lib/recurly/validate.js - About 1 hr to fix

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

              initialize () {
                debug('Initializing Braintree client');
            
                const authorization = this.config.clientAuthorization;
                const braintree = window.braintree;
            Severity: Minor
            Found in lib/recurly/venmo/strategy/braintree.js - About 1 hr to fix

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

              function toLegacyLauncher (capability) {
                const capabilities = Object.assign({}, capability);
                const translations = {
                  browserName: 'browser',
                  browserVersion: 'browser_version',
              Severity: Minor
              Found in karma.ci.conf.js - About 1 hr to fix

                Function discountableSubtotals has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                  discountableSubtotals (coupon, { setupFees = true, taxExempt = true } = {}) {
                    let discountableNow = 0;
                    let discountableNext = 0;
                
                    // adjustments
                Severity: Minor
                Found in lib/recurly/pricing/checkout/calculations.js - About 55 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

                export default function loadScriptPromise (src) {
                  return new Promise((resolve, reject) => {
                    loadScript(src, (err, script) => {
                      if (err) reject(err);
                      else resolve(script);
                Severity: Minor
                Found in lib/util/load-script-promise.js and 1 other location - About 50 mins to fix
                lib/recurly/pricing/checkout/calculations.js on lines 197..204

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

                    const getTaxes = (data) => {
                      return new Promise((resolve, reject) => {
                        boundGetTaxes(data, (err, result) => {
                          if (err) reject(err);
                          else resolve(result);
                Severity: Minor
                Found in lib/recurly/pricing/checkout/calculations.js and 1 other location - About 50 mins to fix
                lib/util/load-script-promise.js on lines 10..17

                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

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

                  bindStrategy () {
                    DEFERRED_EVENTS.forEach(ev => this.strategy.on(ev, this.emit.bind(this, ev)));
                  }
                Severity: Minor
                Found in lib/recurly/venmo/index.js and 1 other location - About 50 mins to fix
                lib/recurly/paypal/index.js on lines 86..88

                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

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

                  bindStrategy () {
                    DEFERRED_EVENTS.forEach(ev => this.strategy.on(ev, this.emit.bind(this, ev)));
                  }
                Severity: Minor
                Found in lib/recurly/paypal/index.js and 1 other location - About 50 mins to fix
                lib/recurly/venmo/index.js on lines 61..63

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

                    if (updateGiftcard) {
                      pricing = pricing.giftcard(dom.value(elems.gift_card).trim()).then(null, ignoreNotFound);
                    }
                Severity: Minor
                Found in lib/recurly/pricing/subscription/attachment.js and 1 other location - About 45 mins to fix
                lib/recurly/pricing/subscription/attachment.js on lines 92..94

                Duplicated Code

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

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

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

                Tuning

                This issue has a mass of 50.

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

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

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

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

                Refactorings

                Further Reading

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

                const payWithGoogle = ({ paymentOptions, isReadyToPayRequest, paymentDataRequest, buttonOptions }) => {
                  const { paymentDataCallbacks } = paymentOptions;
                
                  if (paymentDataCallbacks) {
                    const { onPaymentAuthorized, onPaymentDataChanged } = paymentDataCallbacks;
                Severity: Minor
                Found in lib/recurly/google-pay/pay-with-google.js - About 45 mins to fix

                Cognitive Complexity

                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                A method's cognitive complexity is based on a few simple rules:

                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                • Code is considered more complex for each "break in the linear flow of the code"
                • Code is considered more complex when "flow breaking structures are nested"

                Further reading

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

                    if (userErrors.length) {
                      return done(errors('validation', {
                        fields: userErrors.map(e => e.field),
                        details: userErrors
                      }));
                Severity: Major
                Found in lib/recurly/token.js and 2 other locations - About 45 mins to fix
                lib/recurly/bank-account.js on lines 87..92
                lib/recurly/bank-account.js on lines 143..148

                Duplicated Code

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

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

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

                Tuning

                This issue has a mass of 50.

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

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

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

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

                Refactorings

                Further Reading

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

                  if (userErrors.length) {
                    return done(errors('validation', {
                      fields: userErrors.map(e => e.field),
                      details: userErrors
                    }));
                Severity: Major
                Found in lib/recurly/bank-account.js and 2 other locations - About 45 mins to fix
                lib/recurly/bank-account.js on lines 87..92
                lib/recurly/token.js on lines 168..173

                Duplicated Code

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

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

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

                Tuning

                This issue has a mass of 50.

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

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

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

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

                Refactorings

                Further Reading

                Severity
                Category
                Status
                Source
                Language