recurly/recurly-js

View on GitHub

Showing 179 of 179 total issues

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

  attach (container) {
    if (this.attachment) this.attachment.detach();
    this.attachment = new Attachment(this, container);
    this.attachment.once('ready', () => this.emit('attached'));
    return this.attachment;
Severity: Major
Found in lib/recurly/pricing/checkout/index.js and 1 other location - About 2 hrs to fix
lib/recurly/pricing/subscription/index.js on lines 67..72

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

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

  detach () {
    this.pricing.off('change', this.updateOutput);

    this.elements.all.forEach(elem => {
      elem.removeEventListener('change', this.onInputChange);
Severity: Major
Found in lib/recurly/pricing/checkout/attachment.js and 1 other location - About 2 hrs to fix
lib/recurly/pricing/subscription/attachment.js on lines 157..164

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

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

ApplePay has 23 functions (exceeds 20 allowed). Consider refactoring.
Open

export class ApplePay extends Emitter {
  constructor (options) {
    super();

    this._ready = false;
Severity: Minor
Found in lib/recurly/apple-pay/apple-pay.js - About 2 hrs to fix

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

      attach (container) {
        if (this.attachment) this.attachment.detach();
        this.attachment = new Attachment(this, container);
        this.attachment.once('ready', () => this.emit('attached'));
        return this.attachment;
    Severity: Major
    Found in lib/recurly/pricing/subscription/index.js and 1 other location - About 2 hrs to fix
    lib/recurly/pricing/checkout/index.js on lines 105..110

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

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

      change (event) {
        debug('change');
    
        const elems = this.elements;
        const target = event.target || event.srcElement;
    Severity: Major
    Found in lib/recurly/pricing/subscription/attachment.js - About 2 hrs to fix

      File apple-pay.js has 266 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import Emitter from 'component-emitter';
      import errors from '../errors';
      import { normalize } from '../../util/normalize';
      import { NON_ADDRESS_FIELDS } from '../token';
      import { Pricing } from '../pricing';
      Severity: Minor
      Found in lib/recurly/apple-pay/apple-pay.js - About 2 hrs to fix

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

          get top () {
            const outerHeight = window.outerHeight || window.document.documentElement.clientHeight;
            const outerTop = window.screenY === null ? window.screenTop : window.screenY;
        
            return center(outerHeight, this.height, outerTop);
        Severity: Major
        Found in lib/recurly/frame.js and 1 other location - About 2 hrs to fix
        lib/recurly/frame.js on lines 136..141

        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

          get left () {
            const outerWidth = window.outerWidth || window.document.documentElement.clientWidth;
            const outerLeft = window.screenX === null ? window.screenLeft : window.screenX;
        
            return center(outerWidth, this.width, outerLeft);
        Severity: Major
        Found in lib/recurly/frame.js and 1 other location - About 2 hrs to fix
        lib/recurly/frame.js on lines 123..128

        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

        function validateIdealPayload (data) {
          const errors = [];
        
          if (!data || !data.issuer_id) {
            errors.push('issuer_id cannot be blank');
        Severity: Major
        Found in lib/recurly/bank-redirect.js and 1 other location - About 2 hrs to fix
        lib/recurly/bank-redirect.js on lines 166..178

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

        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

        function validateSofortPayload (data) {
          const errors = [];
        
          if (!data || !data.country_code) {
            errors.push('country_code cannot be blank');
        Severity: Major
        Found in lib/recurly/bank-redirect.js and 1 other location - About 2 hrs to fix
        lib/recurly/bank-redirect.js on lines 152..164

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

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

          taxes () {
            let taxNow = this.price.now.taxes = 0;
            let taxNext = this.price.next.taxes = 0;
        
            // If tax amount has been specified, simply apply it
        Severity: Major
        Found in lib/recurly/pricing/checkout/calculations.js - About 2 hrs to fix

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

              function useGiftcard (price,giftcardValue){
                let used = 0;
                let remains = 0;
                if(giftcardValue > price){
                  used = price;
          Severity: Major
          Found in lib/recurly/pricing/subscription/calculations.js and 1 other location - About 2 hrs to fix
          lib/recurly/pricing/checkout/calculations.js on lines 265..277

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

          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

              function useGiftcard (price, giftCardValue) {
                let used = 0;
                let remains = 0;
          
                if (giftCardValue > price) {
          Severity: Major
          Found in lib/recurly/pricing/checkout/calculations.js and 1 other location - About 2 hrs to fix
          lib/recurly/pricing/subscription/calculations.js on lines 252..262

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

          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

          File element.js has 255 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import deepAssign from '../../util/deep-assign';
          import dom from '../../util/dom';
          import Emitter from 'component-emitter';
          import find from 'component-find';
          import pick from 'lodash.pick';
          Severity: Minor
          Found in lib/recurly/element/element.js - About 2 hrs to fix

            Function transformAddress has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

            export function transformAddress (source, { to = 'contact', except = [], map = CONTACT_MAP } = {}) {
              if (isEmpty(source)) return null;
            
              const target = Object.keys(map).reduce((target, addressField) => {
                const contactField = map[addressField];
            Severity: Minor
            Found in lib/recurly/apple-pay/util/transform-address.js - About 2 hrs to fix

            Cognitive Complexity

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

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

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

            Further reading

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

              get iframeTitle () {
                if (this.config.type === 'card') {
                  return 'Billing information';
                } else if (this.config.style?.placeholder?.content) {
                  return this.config.style.placeholder.content;
            Severity: Major
            Found in lib/recurly/element/element.js and 1 other location - About 2 hrs to fix
            lib/recurly/hosted-field.js on lines 168..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 76.

            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

              get iframeTitle () {
                if (this.config.type === 'card') {
                  return 'Billing information';
                } else if (this.config.style?.placeholder?.content) {
                  return this.config.style.placeholder.content;
            Severity: Major
            Found in lib/recurly/hosted-field.js and 1 other location - About 2 hrs to fix
            lib/recurly/element/element.js on lines 222..230

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

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

              configure (options) {
                debug('configure');
                options = clone(options);
            
                if (typeof options === 'string') options = { publicKey: options };
            Severity: Major
            Found in lib/recurly.js - About 2 hrs to fix

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

                loadAdyenLibrary () {
                  return new Promise((resolve, reject) => {
                    if (window.AdyenCheckout) return resolve();
                    loadScript(AdyenStrategy.libUrl, error => {
                      if (error) reject(error);
              Severity: Major
              Found in lib/recurly/risk/three-d-secure/strategy/adyen.js and 1 other location - About 1 hr to fix
              lib/recurly/risk/three-d-secure/strategy/stripe.js on lines 58..66

              Duplicated Code

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

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

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

              Tuning

              This issue has a mass of 74.

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

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

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

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

              Refactorings

              Further Reading

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

                loadStripeLibrary () {
                  return new Promise((resolve, reject) => {
                    if (window.Stripe) return resolve();
                    loadScript(StripeStrategy.libUrl, error => {
                      if (error) reject(error);
              Severity: Major
              Found in lib/recurly/risk/three-d-secure/strategy/stripe.js and 1 other location - About 1 hr to fix
              lib/recurly/risk/three-d-secure/strategy/adyen.js on lines 151..159

              Duplicated Code

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

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

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

              Tuning

              This issue has a mass of 74.

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

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

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

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

              Refactorings

              Further Reading

              Severity
              Category
              Status
              Source
              Language