activemerchant/active_merchant

View on GitHub

Showing 1,501 of 1,501 total issues

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

      MESSAGES = {
        'A' => 'Street address matches, but postal code does not match.',
        'B' => 'Street address matches, but postal code not verified.',
        'C' => 'Street address and postal code do not match.',
        'D' => 'Street address and postal code match.',
Severity: Major
Found in lib/active_merchant/billing/avs_result.rb and 1 other location - About 1 hr to fix
lib/active_merchant/billing/gateways/pay_hub.rb on lines 21..47

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

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

          if value.is_a?(Hash)
            h = {}
            value.each do |k, v|
              h["#{key}[#{k}]"] = v unless v.blank?
            end
Severity: Major
Found in lib/active_merchant/billing/gateways/securion_pay.rb and 1 other location - About 1 hr to fix
lib/active_merchant/billing/gateways/pagarme.rb on lines 123..133

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

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

      AVS_CODE_TRANSLATOR = {
        '0' =>  'Approved, Address verification was not requested.',
        'A' =>  'Approved, Address matches only.',
        'B' =>  'Address Match. Street Address math for international transaction Postal Code not verified because of incompatible formats (Acquirer sent both street address and Postal Code)',
        'C' =>  'Serv Unavailable. Street address and Postal Code not verified for international transaction because of incompatible formats (Acquirer sent both street and Postal Code).',
Severity: Major
Found in lib/active_merchant/billing/gateways/pay_hub.rb and 1 other location - About 1 hr to fix
lib/active_merchant/billing/avs_result.rb on lines 11..37

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

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 build_credit_card_request has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def build_credit_card_request(action, money, credit_card, options)
        xml = Builder::XmlMarkup.new
        xml.tag! TRANSACTIONS[action] do
          xml.tag! 'PayData' do
            xml.tag! 'Invoice' do
Severity: Minor
Found in lib/active_merchant/billing/gateways/payflow.rb - About 1 hr to fix

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

          def build_reference_sale_or_authorization_request(action, money, reference, options)
            xml = Builder::XmlMarkup.new
            xml.tag! TRANSACTIONS[action] do
              xml.tag! 'PayData' do
                xml.tag! 'Invoice' do
    Severity: Minor
    Found in lib/active_merchant/billing/gateways/payflow.rb - About 1 hr to fix

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

            def credit(money, creditcard, options = {})
              post = payment_request(money, options)
              post[:amount] = amount_hash(money, options[:currency])
              post[:card] = credit_card_hash(creditcard)
              post[:dateOfBirth] = options[:date_of_birth] if options[:date_of_birth]
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/barclaycard_smartpay.rb - About 1 hr to fix

        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_auth_wallet has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def add_auth_wallet(xml, payment_method, options)
                  commerce_indicator = 'internet' if subsequent_nt_apple_pay_auth(payment_method.source, options)
          
                  brand = card_brand(payment_method).to_sym
          
          
          Severity: Minor
          Found in lib/active_merchant/billing/gateways/cyber_source.rb - About 1 hr to fix

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

                  def parse_element(node)
                    if node.has_elements?
                      response = {}
                      node.elements.each { |e|
                        key = e.name.underscore
            Severity: Major
            Found in lib/active_merchant/billing/gateways/authorize_net_cim.rb and 1 other location - About 1 hr to fix
            lib/active_merchant/billing/gateways/usa_epay_advanced.rb on lines 1589..1609

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

            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 parse_element(node)
                    if node.has_elements?
                      response = {}
                      node.elements.each do |e|
                        key = e.name.underscore
            Severity: Major
            Found in lib/active_merchant/billing/gateways/usa_epay_advanced.rb and 1 other location - About 1 hr to fix
            lib/active_merchant/billing/gateways/authorize_net_cim.rb on lines 947..967

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

            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_addresses has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def add_addresses(post, options)
                    if address = options[:billing_address] || options[:address]
                      post[:card_address1] = address[:address1]
                      post[:card_zip]      = address[:zip]
                      post[:card_city]     = address[:city]
            Severity: Minor
            Found in lib/active_merchant/billing/gateways/plugnpay.rb - About 1 hr to fix

              Method soap_request has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    def soap_request(arguments, action)
                      # eWay demands all fields be sent, but contain an empty string if blank
                      post = case action
                             when 'QueryCustomer'
                               arguments
              Severity: Minor
              Found in lib/active_merchant/billing/gateways/eway_managed.rb - About 1 hr to fix

                Method parse has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                      def parse(action, soap)
                        xml = REXML::Document.new(soap)
                        root = REXML::XPath.first(xml, '//SOAP-ENV:Body')
                        response = root ? parse_element(root[0]) : { response: soap }
                
                
                Severity: Minor
                Found in lib/active_merchant/billing/gateways/usa_epay_advanced.rb - About 1 hr to fix

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

                        def commit(action, money, parameters)
                          case action
                          when 'sale'
                            begin
                              response = call_api(TRANSACTION_API, parameters)
                  Severity: Minor
                  Found in lib/active_merchant/billing/gateways/swipe_checkout.rb - About 1 hr to fix

                    Method update has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                          def update(vault_id, creditcard, options = {})
                            braintree_credit_card = nil
                            commit do
                              braintree_credit_card = @braintree_gateway.customer.find(vault_id).credit_cards.detect(&:default?)
                              return Response.new(false, 'Braintree::NotFoundError') if braintree_credit_card.nil?
                    Severity: Minor
                    Found in lib/active_merchant/billing/gateways/braintree_blue.rb - About 1 hr to fix

                      Method build_create_subscription_request has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                            def build_create_subscription_request(payment_method, options)
                              default_subscription_params = { frequency: 'on-demand', amount: 0, automatic_renew: false }
                              options[:subscription] = default_subscription_params.update(
                                options[:subscription] || {}
                              )
                      Severity: Minor
                      Found in lib/active_merchant/billing/gateways/cyber_source.rb - About 1 hr to fix

                        Method add_pay_data has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                              def add_pay_data(xml, money, options)
                                xml.tag! 'PayData' do
                                  xml.tag! 'Invoice' do
                                    xml.tag! 'CustIP', options[:ip] unless options[:ip].blank?
                                    xml.tag! 'InvNum', options[:order_id] unless options[:order_id].blank?
                        Severity: Minor
                        Found in lib/active_merchant/billing/gateways/payflow_express.rb - About 1 hr to fix

                          Method add_payout_sender_data has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                                def add_payout_sender_data(post, options)
                                  return unless options[:payout] == true
                          
                                  post[:sender] = {
                                    # options for type are individual, corporate, or government
                          Severity: Minor
                          Found in lib/active_merchant/billing/gateways/checkout_v2.rb - About 1 hr to fix

                            Method parse has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                  def parse(body)
                                    response = {}
                            
                                    root = REXML::Document.new(body).root
                            
                            
                            Severity: Minor
                            Found in lib/active_merchant/billing/gateways/cecabank/cecabank_xml.rb - About 1 hr to fix

                              Method avs_mapping has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                    def avs_mapping
                                      {
                                        'street: M, zip: M' => 'M',
                                        'street: M, zip: N' => 'A',
                                        'street: M, zip: U' => 'B',
                              Severity: Minor
                              Found in lib/active_merchant/billing/gateways/braintree_blue.rb - About 1 hr to fix
                                Severity
                                Category
                                Status
                                Source
                                Language