activemerchant/active_merchant

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

Summary

Maintainability
D
1 day
Test Coverage

File jetpay_v2.rb has 380 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module ActiveMerchant #:nodoc:
  module Billing #:nodoc:
    class JetpayV2Gateway < Gateway
      self.test_url = 'https://test1.jetpay.com/jetpay'
      self.live_url = 'https://gateway20.jetpay.com/jetpay'
Severity: Minor
Found in lib/active_merchant/billing/gateways/jetpay_v2.rb - About 5 hrs to fix

    Class JetpayV2Gateway has 35 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class JetpayV2Gateway < Gateway
          self.test_url = 'https://test1.jetpay.com/jetpay'
          self.live_url = 'https://gateway20.jetpay.com/jetpay'
    
          self.money_format = :cents
    Severity: Minor
    Found in lib/active_merchant/billing/gateways/jetpay_v2.rb - About 4 hrs to fix

      Method build_xml_request has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def build_xml_request(transaction_type, options = {}, transaction_id = nil, &block)
              xml = Builder::XmlMarkup.new
              xml.tag! 'JetPay', 'Version' => API_VERSION do
                # Basic values needed for any request
                xml.tag! 'TerminalID', @options[:login]
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/jetpay_v2.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_payment has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def add_payment(xml, payment)
              return unless payment
      
              if payment.is_a? String
                token = payment
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/jetpay_v2.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_addresses has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def add_addresses(xml, options)
              if billing_address = options[:billing_address] || options[:address]
                xml.tag! 'Billing' do
                  xml.tag! 'Address', [billing_address[:address1], billing_address[:address2]].compact.join(' ')
                  xml.tag! 'City', billing_address[:city]
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/jetpay_v2.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 4 locations. Consider refactoring.
      Open

            def add_user_defined_fields(xml, options)
              xml.tag! 'UDField1', options[:ud_field_1] if options[:ud_field_1]
              xml.tag! 'UDField2', options[:ud_field_2] if options[:ud_field_2]
              xml.tag! 'UDField3', options[:ud_field_3] if options[:ud_field_3]
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/jetpay_v2.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/firstdata_e4_v27.rb on lines 294..297
      lib/active_merchant/billing/gateways/jetpay.rb on lines 385..388

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

            def build_sale_request(money, payment, options)
              build_xml_request('SALE', options) do |xml|
                add_payment(xml, payment)
                add_addresses(xml, options)
                add_customer_data(xml, options)
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/jetpay_v2.rb and 2 other locations - About 25 mins to fix
      lib/active_merchant/billing/gateways/jetpay.rb on lines 226..235
      lib/active_merchant/billing/gateways/jetpay_v2.rb on lines 240..249

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

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

            def build_authonly_request(money, payment, options)
              build_xml_request('AUTHONLY', options) do |xml|
                add_payment(xml, payment)
                add_addresses(xml, options)
                add_customer_data(xml, options)
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/jetpay_v2.rb and 2 other locations - About 25 mins to fix
      lib/active_merchant/billing/gateways/jetpay.rb on lines 226..235
      lib/active_merchant/billing/gateways/jetpay_v2.rb on lines 227..236

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

      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(body)
              return {} if body.blank?
      
              xml = REXML::Document.new(body)
      
      
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/jetpay_v2.rb and 1 other location - About 15 mins to fix
      lib/active_merchant/billing/gateways/jetpay.rb on lines 303..312

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

      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