Shopify/active_merchant

View on GitHub
lib/active_merchant/billing/gateways/stripe.rb

Summary

Maintainability
F
1 wk
Test Coverage

File stripe.rb has 716 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'active_support/core_ext/hash/slice'

module ActiveMerchant #:nodoc:
  module Billing #:nodoc:
    # This gateway uses an older version of the Stripe API.
Severity: Major
Found in lib/active_merchant/billing/gateways/stripe.rb - About 1 day to fix

    Class StripeGateway has 73 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class StripeGateway < Gateway
          self.live_url = 'https://api.stripe.com/v1/'
    
          # Docs on AVS codes: https://en.wikipedia.org/w/index.php?title=Address_verification_service&_ga=2.97570079.1027215965.1655989706-2008268124.1655989706#AVS_response_codes
          # possible response values: https://stripe.com/docs/api/payment_methods/object#payment_method_object-card-checks
    Severity: Major
    Found in lib/active_merchant/billing/gateways/stripe.rb - About 1 day to fix

      Method add_creditcard has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
      Open

            def add_creditcard(post, creditcard, options, use_sources = false)
              card = {}
              if emv_payment?(creditcard)
                add_emv_creditcard(post, creditcard.icc_data)
                post[:card][:read_method] = 'contactless' if creditcard.read_method == 'contactless'
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/stripe.rb - About 7 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

      Method store has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

            def store(payment, options = {})
              params = {}
              post = {}
      
              if payment.is_a?(ApplePayPaymentToken)
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/stripe.rb - About 3 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

      Method add_source_owner has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

            def add_source_owner(post, creditcard, options)
              post[:owner] = {}
              post[:owner][:name] = creditcard.name if creditcard.respond_to?(:name) && creditcard.name
              post[:owner][:email] = options[:email] if options[:email]
      
      
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/stripe.rb - 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

      Method add_address has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

            def add_address(post, options)
              return unless post[:card]&.kind_of?(Hash)
      
              if address = options[:billing_address] || options[:address]
                post[:card][:address_line1] = address[:address1] if address[:address1]
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/stripe.rb - 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

      Method add_creditcard has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def add_creditcard(post, creditcard, options, use_sources = false)
              card = {}
              if emv_payment?(creditcard)
                add_emv_creditcard(post, creditcard.icc_data)
                post[:card][:read_method] = 'contactless' if creditcard.read_method == 'contactless'
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/stripe.rb - About 1 hr to fix

        Method flatten_params has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

              def flatten_params(flattened, params, prefix = nil)
                params.each do |key, value|
                  next if value != false && value.blank?
        
                  flattened_key = prefix.nil? ? key : "#{prefix}[#{key}]"
        Severity: Minor
        Found in lib/active_merchant/billing/gateways/stripe.rb - 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

        Method authorization_from has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

              def authorization_from(success, url, method, response, options)
                return response.dig('error', 'charge') || response.dig('error', 'setup_intent', 'id') || response['id'] unless success
        
                if url == 'customers'
                  [response['id'], response.dig('sources', 'data').first&.dig('id')].join('|')
        Severity: Minor
        Found in lib/active_merchant/billing/gateways/stripe.rb - 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

        Method store has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def store(payment, options = {})
                params = {}
                post = {}
        
                if payment.is_a?(ApplePayPaymentToken)
        Severity: Minor
        Found in lib/active_merchant/billing/gateways/stripe.rb - About 1 hr to fix

          Method add_shipping_address has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

                def add_shipping_address(post, payment, options = {})
                  return unless shipping = options[:shipping_address]
                  return unless shipping_name = shipping[:name]
          
                  post[:shipping] = {}
          Severity: Minor
          Found in lib/active_merchant/billing/gateways/stripe.rb - 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

          Method purchase has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

                def purchase(money, payment, options = {})
                  if ach?(payment)
                    direct_bank_error = 'Direct bank account transactions are not supported. Bank accounts must be stored and verified before use.'
                    return Response.new(false, direct_bank_error)
                  end
          Severity: Minor
          Found in lib/active_merchant/billing/gateways/stripe.rb - About 55 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

          Method authorize has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

                def authorize(money, payment, options = {})
                  if ach?(payment)
                    direct_bank_error = 'Direct bank account transactions are not supported for authorize.'
                    return Response.new(false, direct_bank_error)
                  end
          Severity: Minor
          Found in lib/active_merchant/billing/gateways/stripe.rb - About 55 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 deeply nested control flow statements.
          Open

                        card[:read_method] = 'contactless_magstripe_mode' if creditcard.read_method == 'contactless_magstripe'
          Severity: Major
          Found in lib/active_merchant/billing/gateways/stripe.rb - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                          card[:fallback_reason] = 'chip_error' if creditcard.read_method == 'fallback_chip_error'
            Severity: Major
            Found in lib/active_merchant/billing/gateways/stripe.rb - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                            card[:fallback_reason] = 'no_chip' if creditcard.read_method == 'fallback_no_chip'
              Severity: Major
              Found in lib/active_merchant/billing/gateways/stripe.rb - About 45 mins to fix

                Method refund has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                      def refund(money, identification, options = {})
                        post = {}
                        add_amount(post, money, options)
                        post[:refund_application_fee] = true if options[:refund_application_fee]
                        post[:reverse_transfer] = options[:reverse_transfer] if options[:reverse_transfer]
                Severity: Minor
                Found in lib/active_merchant/billing/gateways/stripe.rb - About 45 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

                Method authorization_from has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                      def authorization_from(success, url, method, response, options)
                Severity: Minor
                Found in lib/active_merchant/billing/gateways/stripe.rb - About 35 mins to fix

                  Method commit has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def commit(method, url, parameters = nil, options = {})
                          add_expand_parameters(parameters, options) if parameters
                          return Response.new(false, 'Invalid API Key provided') unless key_valid?(options)
                  
                          response = api_request(method, url, parameters, options)
                  Severity: Minor
                  Found in lib/active_merchant/billing/gateways/stripe.rb - 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

                  Method copy_when_present has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def copy_when_present(dest, dest_path, source, source_path = nil)
                          source_path ||= dest_path
                          source_path.each do |key|
                            return nil unless source[key]
                  
                  
                  Severity: Minor
                  Found in lib/active_merchant/billing/gateways/stripe.rb - 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

                  Method add_charge_details has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def add_charge_details(post, money, payment, options)
                          if emv_payment?(payment)
                            add_statement_address(post, options)
                            add_emv_metadata(post, payment)
                          else
                  Severity: Minor
                  Found in lib/active_merchant/billing/gateways/stripe.rb - 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

                  Method add_connected_account has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def add_connected_account(post, options = {})
                          post[:on_behalf_of] = options[:on_behalf_of] if options[:on_behalf_of]
                  
                          return unless options[:transfer_destination]
                  
                  
                  Severity: Minor
                  Found in lib/active_merchant/billing/gateways/stripe.rb - 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

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

                            post[:card][:address_line1] = address[:address1] if address[:address1]
                            post[:card][:address_line2] = address[:address2] if address[:address2]
                            post[:card][:address_country] = address[:country] if address[:country]
                            post[:card][:address_zip] = address[:zip] if address[:zip]
                            post[:card][:address_state] = address[:state] if address[:state]
                  Severity: Major
                  Found in lib/active_merchant/billing/gateways/stripe.rb and 1 other location - About 1 hr to fix
                  lib/active_merchant/billing/gateways/securion_pay.rb on lines 206..211

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

                  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

                        STANDARD_ERROR_CODE_MAPPING = {
                          'incorrect_number' => STANDARD_ERROR_CODE[:incorrect_number],
                          'invalid_number' => STANDARD_ERROR_CODE[:invalid_number],
                          'invalid_expiry_month' => STANDARD_ERROR_CODE[:invalid_expiry_date],
                          'invalid_expiry_year' => STANDARD_ERROR_CODE[:invalid_expiry_date],
                  Severity: Major
                  Found in lib/active_merchant/billing/gateways/stripe.rb and 1 other location - About 1 hr to fix
                  lib/active_merchant/billing/gateways/quickbooks.rb on lines 20..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 62.

                  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

                        def scrub(transcript)
                          transcript.
                            gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]').
                            gsub(%r((Authorization: Bearer )\w+), '\1[FILTERED]').
                            gsub(%r((&?three_d_secure\[cryptogram\]=)[\w=]*(&?)), '\1[FILTERED]\2').
                  Severity: Major
                  Found in lib/active_merchant/billing/gateways/stripe.rb and 1 other location - About 1 hr to fix
                  lib/active_merchant/billing/gateways/payeezy.rb on lines 128..144

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

                  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

                        def api_request(method, endpoint, parameters = nil, options = {})
                          raw_response = response = nil
                          begin
                            raw_response = ssl_request(method, self.live_url + endpoint, post_data(parameters), headers(options))
                            response = parse(raw_response)
                  Severity: Minor
                  Found in lib/active_merchant/billing/gateways/stripe.rb and 1 other location - About 55 mins to fix
                  lib/active_merchant/billing/gateways/pagarme.rb on lines 145..156

                  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 item.is_a?(Hash)
                              flatten_params(flattened, item, key)
                            elsif item.is_a?(Array)
                              flatten_array(flattened, item, key)
                            else
                  Severity: Minor
                  Found in lib/active_merchant/billing/gateways/stripe.rb and 1 other location - About 20 mins to fix
                  lib/active_merchant/billing/gateways/stripe.rb on lines 635..641

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

                  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 value.is_a?(Hash)
                              flatten_params(flattened, value, flattened_key)
                            elsif value.is_a?(Array)
                              flatten_array(flattened, value, flattened_key)
                            else
                  Severity: Minor
                  Found in lib/active_merchant/billing/gateways/stripe.rb and 1 other location - About 20 mins to fix
                  lib/active_merchant/billing/gateways/stripe.rb on lines 649..655

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

                  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

                  There are no issues that match your filters.

                  Category
                  Status