recurly/recurly-js

View on GitHub

Showing 80 of 183 total issues

Function configure has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  configure (options) {
    if (options.recurly) this.recurly = options.recurly;
    else return this.initError = this.error('apple-pay-factory-only');

    if (options.callbacks) this.config.callbacks = options.callbacks;
Severity: Minor
Found in lib/recurly/apple-pay/apple-pay.js - About 35 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

Function tax has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

module.exports = function tax () {
  if (this.query.country === 'US' && this.query.postal_code === USST_POSTAL_CODE && this.query.tax_code === USST_TAX_CODE) return usstWithTaxCode;
  if (this.query.country === 'US' && this.query.postal_code === USST_POSTAL_CODE) return usst;
  if (this.query.country === 'US' && this.query.postal_code === USST_POSTAL_CODE_WITH_REGION) return usstWithRegion;
  if (this.query.country === VAT_COUNTRY) return vat;
Severity: Minor
Found in packages/public-api-fixture-server/fixtures/tax/index.js - About 35 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

Function recurlyErrorFactory has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

function recurlyErrorFactory (definition) {
  const { code, message, help } = definition;

  /**
   * Recurly domain-specific error class
Severity: Minor
Found in lib/recurly/errors.js - About 35 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

Function validateOptions has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  async validateOptions () {
    const getMissingField = (options, fields) => {
      for(const field of fields) {
        if (!(field in options)) {
          return field;
Severity: Minor
Found in lib/recurly/alternative-payment-methods/alternative-payment-methods.js - About 35 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

Avoid too many return statements within this function.
Open

    return BANK_ACCOUNT_TOKENS[params.account_number];
Severity: Major
Found in packages/public-api-fixture-server/fixtures/tokens/index.js - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

        return false;
    Severity: Major
    Found in lib/recurly/pricing/subscription/index.js - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

          return require('./checkout-session-token.json');
      Severity: Major
      Found in packages/public-api-fixture-server/fixtures/tokens/index.js - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

          return CREATE_INVALID;
        Severity: Major
        Found in packages/public-api-fixture-server/fixtures/tokens/index.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

            if (this.query.country === VAT_2015_COUNTRY) return vat2015;
          Severity: Major
          Found in packages/public-api-fixture-server/fixtures/tax/index.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

              return none;
            Severity: Major
            Found in packages/public-api-fixture-server/fixtures/tax/index.js - About 30 mins to fix

              Function toLegacyLauncher has a Cognitive Complexity of 6 (exceeds 5 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 25 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

              Function inject has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                inject () {
                  FIELD_TYPES.forEach(type => {
                    try {
                      this.fields.push(new HostedField(this.fieldConfig(type)));
                      this.initQueue.push(type);
              Severity: Minor
              Found in lib/recurly/hosted-fields.js - About 25 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

              Function cardType has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              export function cardType (number, partial = false) {
                const cardNumber = parseCard(number);
                const compareLength = Math.min(cardNumber.length, 6);
              
                const compareValue = buildCompareValue(cardNumber, compareLength, '0');
              Severity: Minor
              Found in lib/recurly/validate.js - About 25 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

              Function prepare has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                prepare (path, payload) {
                  const { name, recurly } = this;
                  debug('creating request frame');
              
                  payload.version = recurly.version;
              Severity: Minor
              Found in lib/recurly/frame.js - About 25 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

              Function discount has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                discount () {
                  var coupon = this.items.coupon;
              
                  this.price.now.discount = 0;
                  this.price.next.discount = 0;
              Severity: Minor
              Found in lib/recurly/pricing/subscription/calculations.js - About 25 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

              Function validatePayload has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              function validatePayload (payload) {
                var errors = [];
              
                if (payload.skinCode && payload.skinCode.length != 8) {
                  errors.push('skinCode should be 8 characters');
              Severity: Minor
              Found in lib/recurly/adyen.js - About 25 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

              Function getCollectorProfiles has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                getCollectorProfiles () {
                  if (this.dataCollectorInitiated) return;
                  this.dataCollectorInitiated = true;
              
                  this.recurly.request.get({
              Severity: Minor
              Found in lib/recurly/fraud.js - About 25 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

              Function finalizeApplePayPaymentRequest has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              export default function finalizeApplePayPaymentRequest (paymentRequest, config) {
                if (paymentRequest.billingContact && paymentRequest.shippingContact) return paymentRequest;
              
                const formAddress = config.form
                  ? normalize(config.form, ADDRESS_FIELDS, { parseCard: false }).values
              Severity: Minor
              Found in lib/recurly/apple-pay/util/finalize-apple-pay-payment-request.js - About 25 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

              Function resolvePlanOptions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                resolvePlanOptions (planCode, options = {}, done) {
                  let plan = this.items.plan;
                  let quantity;
              
                  if (typeof options === 'function') {
              Severity: Minor
              Found in lib/recurly/pricing/subscription/index.js - About 25 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

              Function destroy has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                destroy () {
                  const { iframe, window: frameWindow } = this;
              
                  if (iframe) {
                    const { parentElement } = iframe;
              Severity: Minor
              Found in lib/recurly/frame.js - About 25 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

              Severity
              Category
              Status
              Source
              Language