Shopify/active_merchant

View on GitHub
lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb

Summary

Maintainability
F
3 days
Test Coverage

File paypal_common_api.rb has 481 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module ActiveMerchant #:nodoc:
  module Billing #:nodoc:
    # This module is included in both PaypalGateway and PaypalExpressGateway
    module PaypalCommonAPI
      include Empty
Severity: Minor
Found in lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb - About 7 hrs to fix

    Method legacy_parse has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
    Open

          def legacy_parse(action, xml)
            response = {}
    
            error_messages = []
            error_codes = []
    Severity: Minor
    Found in lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb - About 6 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_payment_details has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
    Open

          def add_payment_details(xml, money, currency_code, options = {})
            xml.tag! 'n2:PaymentDetails' do
              xml.tag! 'n2:OrderTotal', localized_amount(money, currency_code), 'currencyID' => currency_code
    
              # All of the values must be included together and add up to the order total
    Severity: Minor
    Found in lib/active_merchant/billing/gateways/paypal/paypal_common_api.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 build_mass_pay_request has a Cognitive Complexity of 29 (exceeds 5 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 4 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 build_refund_request has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

          def build_refund_request(money, identification, options)
            xml = Builder::XmlMarkup.new
    
            xml.tag! 'RefundTransactionReq', 'xmlns' => PAYPAL_NAMESPACE do
              xml.tag! 'RefundTransactionRequest', 'xmlns:n2' => EBAY_NAMESPACE do
    Severity: Minor
    Found in lib/active_merchant/billing/gateways/paypal/paypal_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 legacy_parse has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def legacy_parse(action, xml)
            response = {}
    
            error_messages = []
            error_codes = []
    Severity: Minor
    Found in lib/active_merchant/billing/gateways/paypal/paypal_common_api.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 build_transaction_search has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

              def build_transaction_search(options)
                currency_code = options[:currency_code]
                currency_code ||= currency(options[:amount]) if options[:amount]
                transaction_search_optional_fields = %w{ Payer ReceiptID Receiver
                                                         TransactionID InvoiceID CardNumber
        Severity: Minor
        Found in lib/active_merchant/billing/gateways/paypal/paypal_common_api.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_address has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def add_address(xml, element, address)
                return if address.nil?
                xml.tag! element do
                  xml.tag! 'n2:Name', address[:name]
                  xml.tag! 'n2:Street1', address[:address1]
        Severity: Minor
        Found in lib/active_merchant/billing/gateways/paypal/paypal_common_api.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 legacy_parse_element has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def legacy_parse_element(response, node)
                if node.has_elements?
                  node.elements.each{|e| legacy_parse_element(response, e) }
                else
                  response[node.name.underscore.to_sym] = node.text
        Severity: Minor
        Found in lib/active_merchant/billing/gateways/paypal/paypal_common_api.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_optional_fields has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def add_optional_fields(xml, optional_fields, options = {})
                optional_fields.each do |optional_text_field|
                  if optional_text_field =~ /(\w+:)(\w+)/
                    ns = $1
                    field = $2
        Severity: Minor
        Found in lib/active_merchant/billing/gateways/paypal/paypal_common_api.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_payment_details_items_xml has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def add_payment_details_items_xml(xml, options, currency_code)
                options[:items].each do |item|
                  xml.tag! 'n2:PaymentDetailsItem' do
                    xml.tag! 'n2:Name', item[:name]
                    xml.tag! 'n2:Number', item[:number]
        Severity: Minor
        Found in lib/active_merchant/billing/gateways/paypal/paypal_common_api.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

        There are no issues that match your filters.

        Category
        Status