activemerchant/active_merchant

View on GitHub

Showing 1,501 of 1,501 total issues

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

      def add_stored_credential(post, options)
        return unless (stored_credential = options[:stored_credential])

        if stored_credential[:initiator] == 'cardholder'
          post[:initiated_by] = 'customer'
Severity: Minor
Found in lib/active_merchant/billing/gateways/nmi.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 add_customer_data has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

      def add_customer_data(post, options)
        post[:email] = options[:email]
        post[:ipaddress] = options[:ip]
        post[:customer_id] = options[:customer_id] || options[:customer]

Severity: Minor
Found in lib/active_merchant/billing/gateways/nmi.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 10 (exceeds 5 allowed). Consider refactoring.
Open

      def authorization_from(success, url, method, response, options)
        return error_id(response, url) 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 commit has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

      def commit(action, parameters)
        url = (test? ? test_url : live_url) + action
        headers = headers(@options[:api_key])
        body = parameters.to_query

Severity: Minor
Found in lib/active_merchant/billing/gateways/clearhaus.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 add_sub_merchant has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

      def add_sub_merchant(xml, submerchant)
        xml.tag!('v1:SubMerchant') do
          xml.tag!('v1:Mcc', submerchant[:mcc]) if submerchant[:mcc]
          xml.tag!('v1:LegalName', submerchant[:legal_name]) if submerchant[:legal_name]
          add_address(xml, submerchant[:address]) if submerchant[:address]
Severity: Minor
Found in lib/active_merchant/billing/gateways/ipg.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 add_invoice has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

      def add_invoice(post, money, options)
        post[:order_number] = options[:order_id] if options[:order_id].present?

        if options[:item_codes].present?
          codes_and_amounts = options[:item_codes].transform_keys { |key| key.to_s.delete('_') }
Severity: Minor
Found in lib/active_merchant/billing/gateways/cashnet.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 add_invoice has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

      def add_invoice(xml, money, options)
        xml.AuthCode options[:force] if options[:force]
        if options[:order_items].blank?
          xml.Total(amount(money)) unless money.nil? || money < 0.01
          xml.Description(options[:description]) unless options[:description].blank?
Severity: Minor
Found in lib/active_merchant/billing/gateways/itransact.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 build_request has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

      def build_request(body, options = {})
        xml = Builder::XmlMarkup.new
        xml.instruct!
        xml.tag! 'XMLPayRequest', 'Timeout' => timeout.to_s, 'version' => '2.1', 'xmlns' => XMLNS do
          xml.tag! 'RequestData' do
Severity: Minor
Found in lib/active_merchant/billing/gateways/payflow/payflow_common_api.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 add_mc_ucafind has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

      def add_mc_ucafind(xml, credit_card, three_d_secure, options)
        return unless three_d_secure

        if options[:alternate_ucaf_flow]
          return unless %w(4 6 7).include?(three_d_secure[:eci])
Severity: Minor
Found in lib/active_merchant/billing/gateways/orbital.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

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

        if shipping_address = options[:shipping_address] || options[:address]
          post[:ci_shipaddr1] = shipping_address[:address1].to_s
          post[:ci_shipaddr2] = shipping_address[:address2].to_s unless shipping_address[:address2].blank?
          post[:ci_shipcity]  = shipping_address[:city].to_s
          post[:ci_shipstate] = shipping_address[:state].to_s
Severity: Major
Found in lib/active_merchant/billing/gateways/sallie_mae.rb and 1 other location - About 1 hr to fix
lib/active_merchant/billing/gateways/sallie_mae.rb on lines 65..70

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

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_customer_data has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

      def add_customer_data(post, options)
        if options.has_key? :email
          post[:email] = options[:email]
          post[:email_customer] = false
        end
Severity: Minor
Found in lib/active_merchant/billing/gateways/secure_pay.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

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

        if address = options[:billing_address] || options[:address]
          post[:ci_billaddr1] = address[:address1].to_s
          post[:ci_billaddr2] = address[:address2].to_s unless address[:address2].blank?
          post[:ci_billcity]  = address[:city].to_s
          post[:ci_billstate] = address[:state].to_s
Severity: Major
Found in lib/active_merchant/billing/gateways/sallie_mae.rb and 1 other location - About 1 hr to fix
lib/active_merchant/billing/gateways/sallie_mae.rb on lines 73..78

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

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_other_tax has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

      def add_other_tax(xml, options)
        return unless %i[vat_tax_rate local_tax_amount national_tax_amount national_tax_indicator].any? { |gsf| options.include?(gsf) }

        xml.tag! 'otherTax' do
          xml.tag! 'vatTaxRate', options[:vat_tax_rate] if options[:vat_tax_rate]
Severity: Minor
Found in lib/active_merchant/billing/gateways/cyber_source.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 send_initialize has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def send_initialize(amount, is_auth, options = {})
        properties = {
          accountNumber: @options[:account],
          purchaseOperation: is_auth ? 'AUTHORIZATION' : 'SALE',
          price: amount,
Severity: Minor
Found in lib/active_merchant/billing/gateways/payex.rb - About 1 hr to fix

    Method generate_signature has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def generate_signature(action, parameters)
            signature_fields =
              case action
              when CECA_ACTION_REFUND
                options[:signature_key].to_s +
    Severity: Minor
    Found in lib/active_merchant/billing/gateways/cecabank/cecabank_xml.rb - About 1 hr to fix

      Method add_payment_method has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def add_payment_method(post, payment_method)
              case payment_method
              when String
                token, exp_month, exp_year = payment_method.split('|')[2..4]
                card = {
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/datatrans.rb - About 1 hr to fix

        Method commit has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def commit(action, request, *success_criteria, options)
                xml = ssl_post(url, request, headers(options))
                raw = parse(action, xml)
        
                if options[:execute_threed]
        Severity: Minor
        Found in lib/active_merchant/billing/gateways/worldpay.rb - About 1 hr to fix

          Method build_mass_pay_request has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def build_mass_pay_request(*args)
                  default_options = args.last.is_a?(Hash) ? args.pop : {}
                  recipients = args.first.is_a?(Array) ? args : [args]
                  receiver_type = default_options[:receiver_type]
          
          
          Severity: Minor
          Found in lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb - About 1 hr to fix

            Method add_address has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def add_address(post, creditcard, options)
                    shipping_address = options[:shipping_address]
                    if billing_address = options[:billing_address] || options[:address]
                      post['order']['customer']['billingAddress'] = {
                        'street' => truncate(split_address(billing_address[:address1])[1], 50),
            Severity: Minor
            Found in lib/active_merchant/billing/gateways/global_collect.rb - About 1 hr to fix

              Method commit has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    def commit(action, params: '', iid: '', card_number: nil, jwt: '')
                      response =
                        begin
                          case action
                          when 'void'
              Severity: Minor
              Found in lib/active_merchant/billing/gateways/priority.rb - About 1 hr to fix
                Severity
                Category
                Status
                Source
                Language