Shopify/active_merchant

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

Summary

Maintainability
F
4 days
Test Coverage

File global_collect.rb has 508 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module ActiveMerchant #:nodoc:
  module Billing #:nodoc:
    class GlobalCollectGateway < Gateway
      class_attribute :preproduction_url
      class_attribute :ogone_direct_test
Severity: Major
Found in lib/active_merchant/billing/gateways/global_collect.rb - About 1 day to fix

    Class GlobalCollectGateway has 49 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class GlobalCollectGateway < Gateway
          class_attribute :preproduction_url
          class_attribute :ogone_direct_test
          class_attribute :ogone_direct_live
    
    
    Severity: Minor
    Found in lib/active_merchant/billing/gateways/global_collect.rb - About 6 hrs to fix

      Method add_flight_legs has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
      Open

            def add_flight_legs(airline_options)
              flight_legs = []
              airline_options[:flight_legs]&.each do |fl|
                leg = {}
                leg['airlineClass'] = fl[:airline_class] if fl[:airline_class]
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/global_collect.rb - About 5 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_rooms has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

            def add_rooms(lodging_options)
              rooms = []
              lodging_options[:rooms]&.each do |item|
                room = {}
                room['dailyRoomRate'] = item[:daily_room_rate] if item[:daily_room_rate]
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/global_collect.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_lodging_data has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

            def add_lodging_data(post, options)
              return unless lodging_options = options[:lodging_data]
      
              lodging_data = {}
      
      
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/global_collect.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_airline_data has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

            def add_airline_data(post, options)
              return unless airline_options = options[:airline_data]
      
              airline_data = {}
      
      
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/global_collect.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 11 (exceeds 5 allowed). Consider refactoring.
      Open

            def add_customer_data(post, options, payment = nil)
              if payment
                post['order']['customer']['personalInformation']['name']['firstName'] = payment.first_name[0..14] if payment.first_name
                post['order']['customer']['personalInformation']['name']['surname'] = payment.last_name[0..69] if payment.last_name
              end
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/global_collect.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_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 add_passengers has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

              def add_passengers(airline_options)
                passengers = []
                airline_options[:passengers]&.each do |flyer|
                  passenger = {}
                  passenger['firstName'] = flyer[:first_name] if flyer[:first_name]
        Severity: Minor
        Found in lib/active_merchant/billing/gateways/global_collect.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_mobile_credit_card has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

              def add_mobile_credit_card(post, payment, options, specifics_inputs, expirydate)
        Severity: Minor
        Found in lib/active_merchant/billing/gateways/global_collect.rb - About 35 mins to fix

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

                def auth_digest(method, action, post, authorization = nil, options = {})
          Severity: Minor
          Found in lib/active_merchant/billing/gateways/global_collect.rb - About 35 mins to fix

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

                  def headers(method, action, post, authorization = nil, options = {})
            Severity: Minor
            Found in lib/active_merchant/billing/gateways/global_collect.rb - About 35 mins to fix

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

                    def add_payment(post, payment, options)
                      year  = format(payment.year, :two_digits)
                      month = format(payment.month, :two_digits)
                      expirydate = "#{month}#{year}"
                      pre_authorization = options[:pre_authorization] ? 'PRE_AUTHORIZATION' : 'FINAL_AUTHORIZATION'
              Severity: Minor
              Found in lib/active_merchant/billing/gateways/global_collect.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 add_creator_info has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                    def add_creator_info(post, options)
                      post['sdkIdentifier'] = options[:sdk_identifier] if options[:sdk_identifier]
                      post['sdkCreator'] = options[:sdk_creator] if options[:sdk_creator]
                      post['integrator'] = options[:integrator] if options[:integrator]
                      post['shoppingCartExtension'] = {}
              Severity: Minor
              Found in lib/active_merchant/billing/gateways/global_collect.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 add_refund_customer_data has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                    def add_refund_customer_data(post, options)
                      if address = options[:billing_address] || options[:address]
                        post['customer']['address'] = {
                          'countryCode' => address[:country]
                        }
              Severity: Minor
              Found in lib/active_merchant/billing/gateways/global_collect.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 add_external_cardholder_authentication_data has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                    def add_external_cardholder_authentication_data(post, options)
                      return unless threeds_2_options = options[:three_d_secure]
              
                      authentication_data = {
                        priorThreeDSecureData: { acsTransactionId: threeds_2_options[:acs_transaction_id] }.compact,
              Severity: Minor
              Found in lib/active_merchant/billing/gateways/global_collect.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 uri has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                    def uri(action, authorization)
                      version = ogone_direct? ? 'v2' : 'v1'
                      uri = "/#{version}/#{@options[:merchant_id]}/"
                      case action
                      when :authorize
              Severity: Minor
              Found in lib/active_merchant/billing/gateways/global_collect.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_charges has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                    def add_charges(lodging_options)
                      charges = []
                      lodging_options[:charges]&.each do |item|
                        charge = {}
                        charge['chargeAmount'] = item[:charge_amount] if item[:charge_amount]
              Severity: Minor
              Found in lib/active_merchant/billing/gateways/global_collect.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['order']['customer']['shippingAddress'] = {
                          'street' => truncate(split_address(shipping_address[:address1])[1], 50),
                          'houseNumber' => split_address(shipping_address[:address1])[0],
                          'additionalInfo' => truncate(shipping_address[:address2], 50),
                          'zip' => shipping_address[:zip],
              Severity: Major
              Found in lib/active_merchant/billing/gateways/global_collect.rb and 1 other location - About 1 hr to fix
              lib/active_merchant/billing/gateways/global_collect.rb on lines 352..359

              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

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

                        post['order']['customer']['billingAddress'] = {
                          'street' => truncate(split_address(billing_address[:address1])[1], 50),
                          'houseNumber' => split_address(billing_address[:address1])[0],
                          'additionalInfo' => truncate(billing_address[:address2], 50),
                          'zip' => billing_address[:zip],
              Severity: Major
              Found in lib/active_merchant/billing/gateways/global_collect.rb and 1 other location - About 1 hr to fix
              lib/active_merchant/billing/gateways/global_collect.rb on lines 363..370

              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

              There are no issues that match your filters.

              Category
              Status