activemerchant/active_merchant

View on GitHub

Showing 1,501 of 1,501 total issues

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

      def message_from(parsed)
        message = parsed[:message]
        if parsed[:response_code].to_i == 2
          if CARD_CODE_ERRORS.include?(parsed[:card_code])
            message = CVVResult.messages[parsed[:card_code]]
Severity: Minor
Found in lib/active_merchant/billing/gateways/blue_pay.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 commit has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def commit(action, money, fields, options = {})
        fields[:AMOUNT] = amount(money) unless fields[:TRANS_TYPE] == 'VOID' || action == 'rebill'
        fields[:MODE] = (test? ? 'TEST' : 'LIVE')
        fields[:ACCOUNT_ID] = @options[:login]
        fields[:CUSTOMER_IP] = options[:ip] if options[:ip]
Severity: Minor
Found in lib/active_merchant/billing/gateways/blue_pay.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 add_basket_product has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def add_basket_product(post, basket_options)
        basket = []

        basket_options.each do |product|
          obj = {}
Severity: Minor
Found in lib/active_merchant/billing/gateways/moka.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 commit has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def commit(action, parameters, auth = nil)
        url = url_for(action, auth)
        authorization_secret_key = parameters[:authorization_secret_key] if parameters
        parameters.merge!(parameters[:payment][:credit_card].delete(:card)).delete(:payment) if action == 'store'
        response = if %w[refund void].include? action
Severity: Minor
Found in lib/active_merchant/billing/gateways/mundipagg.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 raw_ssl_request has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def raw_ssl_request(method, endpoint, data, headers = {})
      logger&.warn "#{self.class} using ssl_strict=false, which is insecure" unless ssl_strict
      logger&.warn "#{self.class} posting to plaintext endpoint, which is insecure" unless endpoint.to_s =~ /^https:/

      connection = new_connection(endpoint)
Severity: Minor
Found in lib/active_merchant/posts_data.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 full_messages has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

          def full_messages
            result = []

            self.each do |key, messages|
              next unless messages && !messages.empty?
Severity: Minor
Found in lib/active_merchant/billing/compatibility.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

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

      def authorize(money, payment_object, options = {})
        post = {}
        add_payment_method(post, payment_object)
        add_invoice(post, options)
        add_address(post, options)
Severity: Minor
Found in lib/active_merchant/billing/gateways/blue_pay.rb and 1 other location - About 45 mins to fix
lib/active_merchant/billing/gateways/blue_pay.rb on lines 103..113

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

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 purchase(money, payment_object, options = {})
        post = {}
        add_payment_method(post, payment_object)
        add_invoice(post, options)
        add_address(post, options)
Severity: Minor
Found in lib/active_merchant/billing/gateways/blue_pay.rb and 1 other location - About 45 mins to fix
lib/active_merchant/billing/gateways/blue_pay.rb on lines 79..89

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

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

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

      def add_mastercard_network_tokenization_ucaf_data(xml, payment_method, options)
        return unless network_tokenization?(payment_method) && card_brand(payment_method).to_sym == :master
        return if payment_method.source == :network_token

        commerce_indicator = 'internet' if subsequent_nt_apple_pay_auth(payment_method.source, options)
Severity: Minor
Found in lib/active_merchant/billing/gateways/cyber_source.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

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

        if (billing_address = (options[:billing_address] || options[:address]))
          post[:billToAddressLine1]  = billing_address[:address1]
          post[:billToCity]          = billing_address[:city]
          post[:billToState]         = billing_address[:state]
          post[:billToZip]           = billing_address[:zip]
Severity: Minor
Found in lib/active_merchant/billing/gateways/first_giving.rb and 1 other location - About 45 mins to fix
lib/active_merchant/billing/gateways/visanet_peru.rb on lines 118..123

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

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

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

      def remote_url(url = :primary)
        if url == :primary
          (self.test? ? self.test_url : self.live_url)
        else
          (self.test? ? self.secondary_test_url : self.secondary_live_url)
Severity: Minor
Found in lib/active_merchant/billing/gateways/orbital.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

Avoid deeply nested control flow statements.
Open

                opt_element.add_element('name').text = option[:name] unless option[:name].blank?
Severity: Major
Found in lib/active_merchant/billing/gateways/linkpoint.rb - About 45 mins to fix

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

          def add_credentials(xml)
            xml.Credentials do
              xml.AccountID @options[:account_id]
              xml.AccountToken @options[:account_token]
              xml.AcceptorID @options[:acceptor_id]
    Severity: Minor
    Found in lib/active_merchant/billing/gateways/vantiv_express.rb and 1 other location - About 45 mins to fix
    lib/active_merchant/billing/gateways/element.rb on lines 163..172

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

    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

          CURRENCY_EXPONENTS = {
            'AUD' => '2',
            'BRL' => '2',
            'CAD' => '2',
            'CLP' => '2',
    Severity: Major
    Found in lib/active_merchant/billing/gateways/orbital.rb and 2 other locations - About 45 mins to fix
    lib/active_merchant/billing/gateways/barclaycard_smartpay.rb on lines 134..153
    lib/active_merchant/billing/gateways/orbital.rb on lines 87..106

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

    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

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

          def add_address(doc, options)
            address = options[:billing_address] || {}
            doc.country(address[:country] ? lookup_country_code(address[:country]) : 'NA')
            doc.city(address[:city] || 'City')
            doc.line1(address[:address1] || 'Address')
    Severity: Minor
    Found in lib/active_merchant/billing/gateways/telr.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 message_from has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def message_from(results)
            if results[:response_code] == DECLINED
              return CVVResult.messages[results[:card_code]] if CARD_CODE_ERRORS.include?(results[:card_code])
              return AVSResult.messages[results[:avs_result_code]] if AVS_REASON_CODES.include?(results[:response_reason_code]) && AVS_ERRORS.include?(results[:avs_result_code])
            end
    Severity: Minor
    Found in lib/active_merchant/billing/gateways/secure_pay.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 validate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def validate
            errors = []
    
            %i[name routing_number account_number].each do |attr|
              errors << [attr, 'cannot be empty'] if empty?(self.send(attr))
    Severity: Minor
    Found in lib/active_merchant/billing/check.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

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

          def headers(params = {})
            result = {
              'Content-Type' => 'application/json',
              'Authorization' => "Basic #{Base64.strict_encode64(options[:api_key] + ':').strip}"
            }
    Severity: Minor
    Found in lib/active_merchant/billing/gateways/pin.rb and 1 other location - About 45 mins to fix
    lib/active_merchant/billing/gateways/trexle.rb on lines 148..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 40.

    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 headers(params = {})
            result = {
              'Content-Type' => 'application/json',
              'Authorization' => "Basic #{Base64.strict_encode64(options[:api_key] + ':').strip}"
            }
    Severity: Minor
    Found in lib/active_merchant/billing/gateways/trexle.rb and 1 other location - About 45 mins to fix
    lib/active_merchant/billing/gateways/pin.rb on lines 204..212

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

    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

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

          def add_address(xml, payment_source, options)
            return unless (address = get_address(options))
    
            if avs_supported?(address[:country]) || empty?(address[:country])
              xml.tag! :AVSzip, byte_limit(format_address_field(address[:zip]), 10)
    Severity: Minor
    Found in lib/active_merchant/billing/gateways/orbital.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

    Severity
    Category
    Status
    Source
    Language