recurly/recurly-js

View on GitHub

Showing 179 of 179 total issues

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

const localIdentifier = `${Math.round(Math.random() * 100)}-${Date.now()}`;
Severity: Minor
Found in wdio.ci.conf.js and 1 other location - About 35 mins to fix
karma.ci.conf.js on lines 30..30

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

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

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

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

        if (!options.braintree || !options.braintree.clientAuthorization) {
          throw this.error('paypal-config-missing', { opt: 'braintree.clientAuthorization' });
        }
    Severity: Minor
    Found in lib/recurly/paypal/strategy/braintree.js and 1 other location - About 30 mins to fix
    lib/recurly/venmo/strategy/braintree.js on lines 21..23

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

    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

    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

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

          if (fraudConfig.litle.sessionId) {
            fraudParams.push({
              processor: 'litle_threat_metrix',
              session_id: fraudConfig.litle.sessionId
            });
      Severity: Minor
      Found in lib/recurly/fraud.js and 1 other location - About 30 mins to fix
      lib/recurly/fraud.js on lines 56..61

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

      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

      export function factory (options) {
        options = Object.assign({}, options, { recurly: this });
        return new PayPal(options);
      }
      Severity: Minor
      Found in lib/recurly/paypal/index.js and 1 other location - About 30 mins to fix
      lib/recurly/venmo/index.js on lines 10..13

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

      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

      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

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

        export function factory (options) {
          options = Object.assign({}, options, { recurly: this });
          return new Venmo(options);
        }
        Severity: Minor
        Found in lib/recurly/venmo/index.js and 1 other location - About 30 mins to fix
        lib/recurly/paypal/index.js on lines 14..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 45.

        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 (fraudConfig.braintree.deviceData) {
              fraudParams.push({
                processor: 'braintree',
                session_id: fraudConfig.braintree.deviceData
              });
        Severity: Minor
        Found in lib/recurly/fraud.js and 1 other location - About 30 mins to fix
        lib/recurly/fraud.js on lines 49..54

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

        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 (!options.braintree || !options.braintree.clientAuthorization) {
              throw this.error('venmo-config-missing', { opt: 'braintree.clientAuthorization' });
            }
        Severity: Minor
        Found in lib/recurly/venmo/strategy/braintree.js and 1 other location - About 30 mins to fix
        lib/recurly/paypal/strategy/braintree.js on lines 20..22

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

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