recurly/recurly-js

View on GitHub

Showing 80 of 183 total issues

File errors.js has 383 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

            File recurly.js has 311 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

              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

                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

                  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

                    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

                        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

                          Function configure has 53 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

                            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

                              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

                                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
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language