Shopify/active_merchant

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

Summary

Maintainability
D
2 days
Test Coverage

Class FirstdataE4V27Gateway has 50 methods (exceeds 20 allowed). Consider refactoring.
Open

    class FirstdataE4V27Gateway < Gateway
      self.test_url = 'https://api.demo.globalgatewaye4.firstdata.com/transaction/v28'
      self.live_url = 'https://api.globalgatewaye4.firstdata.com/transaction/v28'

      TRANSACTIONS = {
Severity: Minor
Found in lib/active_merchant/billing/gateways/firstdata_e4_v27.rb - About 7 hrs to fix

    File firstdata_e4_v27.rb has 409 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module ActiveMerchant #:nodoc:
      module Billing #:nodoc:
        class FirstdataE4V27Gateway < Gateway
          self.test_url = 'https://api.demo.globalgatewaye4.firstdata.com/transaction/v28'
          self.live_url = 'https://api.globalgatewaye4.firstdata.com/transaction/v28'
    Severity: Minor
    Found in lib/active_merchant/billing/gateways/firstdata_e4_v27.rb - About 5 hrs to fix

      Method add_stored_credentials has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

            def add_stored_credentials(xml, card, options)
              return unless options[:stored_credential]
      
              xml.tag! 'StoredCredentials' do
                xml.tag! 'Indicator', stored_credential_indicator(xml, card, options)
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/firstdata_e4_v27.rb - About 3 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_credit_card_eci has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

            def add_credit_card_eci(xml, credit_card, options)
              eci = if credit_card.is_a?(NetworkTokenizationCreditCard) && credit_card.source == :apple_pay && card_brand(credit_card) == 'discover'
                      # Payeezy requires an ECI of 5 for apple pay transactions
                      # See: https://support.payeezy.com/hc/en-us/articles/203730589-Ecommerce-Flag-Values
                      '05'
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/firstdata_e4_v27.rb - About 55 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 message_from has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def message_from(response)
              if response[:faultcode] && response[:faultstring]
                response[:faultstring]
              elsif response[:error_number] && response[:error_number] != '0'
                response[:error_description]
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/firstdata_e4_v27.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

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

            STANDARD_ERROR_CODE_MAPPING = {
              # Bank error codes: https://support.payeezy.com/hc/en-us/articles/203730509-First-Data-Global-Gateway-e4-Bank-Response-Codes
              '201' => STANDARD_ERROR_CODE[:incorrect_number],
              '531' => STANDARD_ERROR_CODE[:invalid_cvc],
              '503' => STANDARD_ERROR_CODE[:invalid_cvc],
      Severity: Major
      Found in lib/active_merchant/billing/gateways/firstdata_e4_v27.rb and 3 other locations - About 1 hr to fix
      lib/active_merchant/billing/gateways/firstdata_e4.rb on lines 45..63
      lib/active_merchant/billing/gateways/pay_hub.rb on lines 50..66
      lib/active_merchant/billing/gateways/usa_epay_transaction.rb on lines 23..39

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

      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 message_from(response)
              if response[:faultcode] && response[:faultstring]
                response[:faultstring]
              elsif response[:error_number] && response[:error_number] != '0'
                response[:error_description]
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/firstdata_e4_v27.rb and 1 other location - About 55 mins to fix
      lib/active_merchant/billing/gateways/firstdata_e4.rb on lines 413..422

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

      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

            def add_credit_card_eci(xml, credit_card, options)
              eci = if credit_card.is_a?(NetworkTokenizationCreditCard) && credit_card.source == :apple_pay && card_brand(credit_card) == 'discover'
                      # Payeezy requires an ECI of 5 for apple pay transactions
                      # See: https://support.payeezy.com/hc/en-us/articles/203730589-Ecommerce-Flag-Values
                      '05'
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/firstdata_e4_v27.rb and 1 other location - About 55 mins to fix
      lib/active_merchant/billing/gateways/firstdata_e4.rb on lines 247..259

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

      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 add_network_tokenization_credit_card(xml, credit_card)
              case card_brand(credit_card).to_sym
              when :american_express
                cryptogram = Base64.decode64(credit_card.payment_cryptogram)
                xml.tag!('XID', Base64.encode64(cryptogram[20...40]))
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/firstdata_e4_v27.rb and 1 other location - About 55 mins to fix
      lib/active_merchant/billing/gateways/firstdata_e4.rb on lines 281..289

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

      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

              Response.new(
                successful?(response),
                message_from(response),
                response,
                test: test?,
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/firstdata_e4_v27.rb and 1 other location - About 30 mins to fix
      lib/active_merchant/billing/gateways/firstdata_e4.rb on lines 357..366

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

      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 4 locations. Consider refactoring.
      Open

            def add_customer_data(xml, options)
              xml.tag! 'Customer_Ref', options[:customer] if options[:customer]
              xml.tag! 'Client_IP', options[:ip] if options[:ip]
              xml.tag! 'Client_Email', options[:email] if options[:email]
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/firstdata_e4_v27.rb and 3 other locations - About 30 mins to fix
      lib/active_merchant/billing/gateways/firstdata_e4.rb on lines 315..318
      lib/active_merchant/billing/gateways/jetpay.rb on lines 385..388
      lib/active_merchant/billing/gateways/jetpay_v2.rb on lines 422..425

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

      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 authorization_from(response)
              if response[:authorization_num] && response[:transaction_tag]
                [
                  response[:authorization_num],
                  response[:transaction_tag],
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/firstdata_e4_v27.rb and 1 other location - About 20 mins to fix
      lib/active_merchant/billing/gateways/firstdata_e4.rb on lines 381..390

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

      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 build_request(action, body)
              xml = Builder::XmlMarkup.new
      
              xml.instruct!
              xml.tag! 'Transaction', xmlns: 'http://secure2.e-xact.com/vplug-in/transaction/rpc-enc/encodedTypes' do
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/firstdata_e4_v27.rb and 1 other location - About 15 mins to fix
      lib/active_merchant/billing/gateways/firstdata_e4.rb on lines 158..168

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

      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