activemerchant/active_merchant

View on GitHub

Showing 1,478 of 1,478 total issues

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

          post[:address] = {}
          post[:address][:street1] = address[:address1] if address[:address1]
          post[:address][:street2] = address[:address2] if address[:address2]
          post[:address][:street3] = address[:address3] if address[:address3]
          post[:address][:city] = address[:city] if address[:city]
Severity: Major
Found in lib/active_merchant/billing/gateways/conekta.rb and 1 other location - About 2 hrs to fix
lib/active_merchant/billing/gateways/conekta.rb on lines 146..153

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

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

          post[:address] = {}
          post[:address][:street1] = address[:address1] if address[:address1]
          post[:address][:street2] = address[:address2] if address[:address2]
          post[:address][:street3] = address[:address3] if address[:address3]
          post[:address][:city] = address[:city] if address[:city]
Severity: Major
Found in lib/active_merchant/billing/gateways/conekta.rb and 1 other location - About 2 hrs to fix
lib/active_merchant/billing/gateways/conekta.rb on lines 109..116

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

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

Class DataCashGateway has 22 methods (exceeds 20 allowed). Consider refactoring.
Open

    class DataCashGateway < Gateway
      self.default_currency = 'GBP'
      self.supported_countries = ['GB']

      self.supported_cardtypes = %i[visa master american_express discover diners_club jcb maestro]
Severity: Minor
Found in lib/active_merchant/billing/gateways/data_cash.rb - About 2 hrs to fix

    Class WorldpayUsGateway has 22 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class WorldpayUsGateway < Gateway
          class_attribute :backup_url
    
          self.display_name = 'Worldpay US'
          self.homepage_url = 'http://www.worldpay.com/us'
    Severity: Minor
    Found in lib/active_merchant/billing/gateways/worldpay_us.rb - About 2 hrs to fix

      Class DatatransGateway has 22 methods (exceeds 20 allowed). Consider refactoring.
      Open

          class DatatransGateway < Gateway
            self.test_url = 'https://api.sandbox.datatrans.com/v1/transactions/'
            self.live_url = 'https://api.datatrans.com/v1/transactions/'
      
            self.supported_countries = %w(CH GR US) # to confirm the countries supported.
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/datatrans.rb - About 2 hrs to fix

        Class BamboraApacGateway has 22 methods (exceeds 20 allowed). Consider refactoring.
        Open

            class BamboraApacGateway < Gateway
              self.live_url = 'https://www.bambora.co.nz/interface/api'
              self.test_url = 'https://demo.bambora.co.nz/interface/api'
        
              self.supported_countries = %w[AU NZ]
        Severity: Minor
        Found in lib/active_merchant/billing/gateways/bambora_apac.rb - About 2 hrs to fix

          Class AlliedWalletGateway has 22 methods (exceeds 20 allowed). Consider refactoring.
          Open

              class AlliedWalletGateway < Gateway
                self.display_name = 'Allied Wallet'
                self.homepage_url = 'https://www.alliedwallet.com'
          
                self.live_url = 'https://api.alliedwallet.com/merchants/'
          Severity: Minor
          Found in lib/active_merchant/billing/gateways/allied_wallet.rb - About 2 hrs to fix

            Class ConektaGateway has 22 methods (exceeds 20 allowed). Consider refactoring.
            Open

                class ConektaGateway < Gateway
                  self.live_url = 'https://api.conekta.io/'
            
                  self.supported_countries = ['MX']
                  self.supported_cardtypes = %i[visa master american_express carnet]
            Severity: Minor
            Found in lib/active_merchant/billing/gateways/conekta.rb - About 2 hrs to fix

              Class ClearhausGateway has 22 methods (exceeds 20 allowed). Consider refactoring.
              Open

                  class ClearhausGateway < Gateway
                    self.test_url = 'https://gateway.test.clearhaus.com'
                    self.live_url = 'https://gateway.clearhaus.com'
              
                    self.supported_countries = %w[DK NO SE FI DE CH NL AD AT BE BG HR CY CZ FO GL EE FR GR
              Severity: Minor
              Found in lib/active_merchant/billing/gateways/clearhaus.rb - About 2 hrs to fix

                Class ProPayGateway has 22 methods (exceeds 20 allowed). Consider refactoring.
                Open

                    class ProPayGateway < Gateway
                      self.test_url = 'https://xmltest.propay.com/API/PropayAPI.aspx'
                      self.live_url = 'https://epay.propay.com/api/propayapi.aspx'
                
                      self.supported_countries = %w[US CA]
                Severity: Minor
                Found in lib/active_merchant/billing/gateways/pro_pay.rb - About 2 hrs to fix

                  Class FirstPayJsonGateway has 22 methods (exceeds 20 allowed). Consider refactoring.
                  Open

                      class FirstPayJsonGateway < Gateway
                        include FirstPayCommon
                  
                        ACTIONS = {
                          purchase: 'Sale',
                  Severity: Minor
                  Found in lib/active_merchant/billing/gateways/first_pay/first_pay_json.rb - About 2 hrs to fix

                    Class EfsnetGateway has 22 methods (exceeds 20 allowed). Consider refactoring.
                    Open

                        class EfsnetGateway < Gateway
                          self.supported_countries = ['US']
                          self.supported_cardtypes = %i[visa master american_express discover]
                          self.homepage_url = 'http://www.concordefsnet.com/'
                          self.display_name = 'Efsnet'
                    Severity: Minor
                    Found in lib/active_merchant/billing/gateways/efsnet.rb - About 2 hrs to fix

                      Class Flo2cashGateway has 22 methods (exceeds 20 allowed). Consider refactoring.
                      Open

                          class Flo2cashGateway < Gateway
                            self.display_name = 'Flo2Cash'
                            self.homepage_url = 'http://www.flo2cash.co.nz/'
                      
                            self.test_url = 'https://demo.flo2cash.co.nz/ws/paymentws.asmx'
                      Severity: Minor
                      Found in lib/active_merchant/billing/gateways/flo2cash.rb - About 2 hrs to fix

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

                                  params[:Sname]        = address[:name] || creditcard.name
                                  params[:Saddress1]    = address[:address1] unless address[:address1].blank?
                                  params[:Saddress2]    = address[:address2] unless address[:address2].blank?
                                  params[:Scity]        = address[:city]     unless address[:city].blank?
                                  params[:Sprovince]    = address[:state]    unless address[:state].blank?
                        Severity: Major
                        Found in lib/active_merchant/billing/gateways/psigate.rb and 1 other location - About 2 hrs to fix
                        lib/active_merchant/billing/gateways/psigate.rb on lines 187..194

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

                        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

                                  params[:Bname] = address[:name] || creditcard.name
                                  params[:Baddress1]    = address[:address1] unless address[:address1].blank?
                                  params[:Baddress2]    = address[:address2] unless address[:address2].blank?
                                  params[:Bcity]        = address[:city]     unless address[:city].blank?
                                  params[:Bprovince]    = address[:state]    unless address[:state].blank?
                        Severity: Major
                        Found in lib/active_merchant/billing/gateways/psigate.rb and 1 other location - About 2 hrs to fix
                        lib/active_merchant/billing/gateways/psigate.rb on lines 198..205

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

                        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

                        File safe_charge.rb has 263 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        require 'nokogiri'
                        
                        module ActiveMerchant #:nodoc:
                          module Billing #:nodoc:
                            class SafeChargeGateway < Gateway
                        Severity: Minor
                        Found in lib/active_merchant/billing/gateways/safe_charge.rb - About 2 hrs to fix

                          Method request has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                          Open

                              def request(method, body, headers = {})
                                request_start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
                          
                                headers = headers.dup
                                headers['connection'] ||= 'close'
                          Severity: Minor
                          Found in lib/active_merchant/connection.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 17 (exceeds 5 allowed). Consider refactoring.
                          Open

                                def add_address(params, options)
                                  address = options[:billing_address] || options[:address]
                          
                                  if address
                                    params[:address]   = address[:address1] unless address[:address1].blank?
                          Severity: Minor
                          Found in lib/active_merchant/billing/gateways/pay_junction.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_3ds has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                          Open

                                def add_3ds(post, options)
                                  if three_ds_2_options = options[:three_ds_2]
                                    device_channel = three_ds_2_options[:channel]
                                    if device_channel == 'app'
                                      post[:threeDS2RequestData] = { deviceChannel: device_channel }
                          Severity: Minor
                          Found in lib/active_merchant/billing/gateways/barclaycard_smartpay.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_billing_address has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                          Open

                                def add_billing_address(post, payment, options)
                                  return unless billing = options[:billing_address]
                          
                                  billing_address = {}
                                  if payment.is_a?(CreditCard)
                          Severity: Minor
                          Found in lib/active_merchant/billing/gateways/commerce_hub.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

                          Severity
                          Category
                          Status
                          Source
                          Language