recurly/recurly-js

View on GitHub

Showing 179 of 179 total issues

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

  get elements () {
    if (this._elements) return this._elements;

    let elements = { all: [].slice.call(this.container.querySelectorAll('[data-recurly]')) };

Severity: Major
Found in lib/recurly/pricing/checkout/attachment.js and 1 other location - About 5 hrs to fix
lib/recurly/pricing/subscription/attachment.js on lines 38..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 151.

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 elements () {
    if (this._elements) return this._elements;

    let elements = { all: [].slice.call(this.container.querySelectorAll('[data-recurly]')) };

Severity: Major
Found in lib/recurly/pricing/subscription/attachment.js and 1 other location - About 5 hrs to fix
lib/recurly/pricing/checkout/attachment.js on lines 43..56

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

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 errors.js has 378 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { Reporter } from './reporter';
import squish from 'string-squish';

const BASE_URL = 'https://dev.recurly.com/docs/recurly-js-';
const GOOGLE_PAY_ERRORS = [
Severity: Minor
Found in lib/recurly/errors.js - About 5 hrs to fix

    Function onInputChange has 108 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      onInputChange (event) {
        debug('onInputChange');
    
        const elems = this.elements;
    
    
    Severity: Major
    Found in lib/recurly/pricing/checkout/attachment.js - About 4 hrs to fix

      File index.js has 320 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import clone from 'component-clone';
      import find from 'component-find';
      import intersection from 'intersect';
      import isEmpty from 'lodash.isempty';
      import Promise from 'promise';
      Severity: Minor
      Found in lib/recurly/pricing/checkout/index.js - About 3 hrs to fix

        File calculations.js has 315 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import each from 'component-each';
        import isEmpty from 'lodash.isempty';
        import Promise from 'promise';
        import uniq from 'array-unique';
        import decimalizeMember from '../../../util/decimalize-member';
        Severity: Minor
        Found in lib/recurly/pricing/checkout/calculations.js - About 3 hrs to fix

          Element has 29 functions (exceeds 20 allowed). Consider refactoring.
          Open

          export default class Element extends Emitter {
            static DATA_ATTRIBUTE_ID = 'recurlyElementId';
            static FRAME_NAME_PREFIX = 'recurly-element--';
            static INSTANCE_REF_NAME = '__recurlyElement';
            static OPTIONS = [
          Severity: Minor
          Found in lib/recurly/element/element.js - About 3 hrs to fix

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

                this.frame = recurly.Frame({
                  path: '/three_d_secure/start',
                  payload,
                  container,
                  type: Frame.TYPES.WINDOW,
            Severity: Major
            Found in lib/recurly/risk/three-d-secure/strategy/amazon.js and 2 other locations - About 3 hrs to fix
            lib/recurly/risk/three-d-secure/strategy/orbital.js on lines 39..46
            lib/recurly/risk/three-d-secure/strategy/sage-pay.js on lines 38..45

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

            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

                this.frame = recurly.Frame({
                  path: '/three_d_secure/start',
                  payload,
                  container,
                  type: Frame.TYPES.IFRAME,
            Severity: Major
            Found in lib/recurly/risk/three-d-secure/strategy/sage-pay.js and 2 other locations - About 3 hrs to fix
            lib/recurly/risk/three-d-secure/strategy/amazon.js on lines 35..42
            lib/recurly/risk/three-d-secure/strategy/orbital.js on lines 39..46

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

            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

                this.frame = recurly.Frame({
                  path: '/three_d_secure/start',
                  payload,
                  container,
                  type: Frame.TYPES.IFRAME,
            Severity: Major
            Found in lib/recurly/risk/three-d-secure/strategy/orbital.js and 2 other locations - About 3 hrs to fix
            lib/recurly/risk/three-d-secure/strategy/amazon.js on lines 35..42
            lib/recurly/risk/three-d-secure/strategy/sage-pay.js on lines 38..45

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

            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 recurly.js has 301 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            /*jshint -W058 */
            
            import clone from 'component-clone';
            import deepAssign from './util/deep-assign';
            import deepFilter from 'deep-filter';
            Severity: Minor
            Found in lib/recurly.js - About 3 hrs to fix

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

                  this.frame = recurly.Frame({ path: '/three_d_secure/start', type: Frame.TYPES.IFRAME, payload, container })
                    .on('error', cause => threeDSecure.error('3ds-auth-error', { cause }))
                    .on('done', results => this.emit('done', results));
              Severity: Major
              Found in lib/recurly/risk/three-d-secure/strategy/worldpay.js and 1 other location - About 3 hrs to fix
              lib/recurly/risk/three-d-secure/strategy/cybersource.js on lines 91..93

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

              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

                  this.frame = recurly.Frame({ path: '/three_d_secure/start', type: Frame.TYPES.IFRAME, payload, container })
                    .on('error', cause => threeDSecure.error('3ds-auth-error', { cause }))
                    .on('done', results => this.emit('done', results));
              Severity: Major
              Found in lib/recurly/risk/three-d-secure/strategy/cybersource.js and 1 other location - About 3 hrs to fix
              lib/recurly/risk/three-d-secure/strategy/worldpay.js on lines 89..91

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

              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 a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
              Open

                configure (options) {
                  debug('configure');
                  options = clone(options);
              
                  if (typeof options === 'string') options = { publicKey: options };
              Severity: Minor
              Found in lib/recurly.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

              Function adjustment has 69 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                adjustment ({ itemCode = null, amount, quantity, id = uid(), currency, taxExempt, taxCode }) {
                  const { recurly } = this;
                  return new PricingPromise((resolve, reject) => {
                    let existingAdjustment = find(this.items.adjustments, a => a.id === id);
                    let validateAmount = true;
              Severity: Major
              Found in lib/recurly/pricing/checkout/index.js - About 2 hrs to fix

                Function change has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                Open

                  change (event) {
                    debug('change');
                
                    const elems = this.elements;
                    const target = event.target || event.srcElement;
                Severity: Minor
                Found in lib/recurly/pricing/subscription/attachment.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

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

                    const get = (lib, done = () => {}) => {
                      const uri = `https://js.braintreegateway.com/web/${BRAINTREE_CLIENT_VERSION}/js/${lib}.min.js`;
                      loadScript(uri, error => {
                        if (error) this.error('venmo-load-error', { cause: error });
                        else done();
                Severity: Major
                Found in lib/recurly/venmo/strategy/braintree.js and 1 other location - About 2 hrs to fix
                lib/recurly/paypal/strategy/braintree.js on lines 35..41

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

                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 get = (lib, done = () => {}) => {
                      const uri = `https://js.braintreegateway.com/web/${BRAINTREE_CLIENT_VERSION}/js/${lib}.min.js`;
                      loadScript(uri, error => {
                        if (error) this.error('paypal-load-error', { cause: error });
                        else done();
                Severity: Major
                Found in lib/recurly/paypal/strategy/braintree.js and 1 other location - About 2 hrs to fix
                lib/recurly/venmo/strategy/braintree.js on lines 38..44

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

                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

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

                export default class CheckoutPricing extends Pricing {
                  constructor (...args) {
                    super(...args);
                    this.debug = debug;
                    this.recurly.report('pricing:checkout:create');
                Severity: Minor
                Found in lib/recurly/pricing/checkout/index.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/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

                  Severity
                  Category
                  Status
                  Source
                  Language