Shopify/active_merchant

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

Summary

Maintainability
F
5 days
Test Coverage

Method add_address has a Cognitive Complexity of 65 (exceeds 5 allowed). Consider refactoring.
Open

      def add_address(xml, options)
        address = address = options[:billing_address] || options[:address]
        shipping_address = options[:shipping_address]

        if address || shipping_address
Severity: Minor
Found in lib/active_merchant/billing/gateways/vantiv_express.rb - About 1 day 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 has a Cognitive Complexity of 57 (exceeds 5 allowed). Consider refactoring.
Open

      def add_lodging(xml, options)
        if options[:lodging]
          lodging = parse_lodging(options[:lodging])
          xml.ExtendedParameters do
            xml.Lodging do
Severity: Minor
Found in lib/active_merchant/billing/gateways/vantiv_express.rb - About 1 day 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

File vantiv_express.rb has 498 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'nokogiri'
require 'securerandom'

module ActiveMerchant #:nodoc:
  module Billing #:nodoc:
Severity: Minor
Found in lib/active_merchant/billing/gateways/vantiv_express.rb - About 7 hrs to fix

    Class VantivExpressGateway has 37 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class VantivExpressGateway < Gateway
          self.test_url = 'https://certtransaction.elementexpress.com'
          self.live_url = 'https://transaction.elementexpress.com'
    
          self.supported_countries = ['US']
    Severity: Minor
    Found in lib/active_merchant/billing/gateways/vantiv_express.rb - About 4 hrs to fix

      Method add_transaction has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

            def add_transaction(xml, money, options = {}, network_token_eci = nil)
              xml.Transaction do
                xml.ReversalType REVERSAL_TYPE[options[:reversal_type]] || options[:reversal_type] if options[:reversal_type]
                xml.TransactionID options[:trans_id] if options[:trans_id]
                xml.TransactionAmount amount(money.to_i) if money
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/vantiv_express.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 parse_eci has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def parse_eci(payment)
              return nil unless payment.is_a?(NetworkTokenizationCreditCard)
      
              if (eci = payment.eci)
                eci = eci[0] == '0' ? eci.sub!(/^0/, '') : eci
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/vantiv_express.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 url has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def url(action)
              if action == :store
                test? ? SERVICE_TEST_URL : SERVICE_LIVE_URL
              else
                test? ? test_url : live_url
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/vantiv_express.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

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

                    xml.LodgingAgreementNumber lodging[:agreement_number] if lodging[:agreement_number]
                    xml.LodgingCheckInDate lodging[:check_in_date] if lodging[:check_in_date]
                    xml.LodgingCheckOutDate lodging[:check_out_date] if lodging[:check_out_date]
                    xml.LodgingRoomAmount lodging[:room_amount] if lodging[:room_amount]
                    xml.LodgingRoomTax lodging[:room_tax] if lodging[:room_tax]
      Severity: Major
      Found in lib/active_merchant/billing/gateways/vantiv_express.rb and 1 other location - About 3 hrs to fix
      lib/active_merchant/billing/gateways/element.rb on lines 233..246

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

      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 refund(money, authorization, options = {})
              trans_id, _, eci = authorization.split('|')
              options[:trans_id] = trans_id
      
              request = build_xml_request do |xml|
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/vantiv_express.rb and 1 other location - About 50 mins to fix
      lib/active_merchant/billing/gateways/vantiv_express.rb on lines 193..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 42.

      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 capture(money, authorization, options = {})
              trans_id, _, eci = authorization.split('|')
              options[:trans_id] = trans_id
      
              request = build_xml_request do |xml|
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/vantiv_express.rb and 1 other location - About 50 mins to fix
      lib/active_merchant/billing/gateways/vantiv_express.rb on lines 208..220

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

      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_credentials(xml)
              xml.Credentials do
                xml.AccountID @options[:account_id]
                xml.AccountToken @options[:account_token]
                xml.AcceptorID @options[:acceptor_id]
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/vantiv_express.rb and 1 other location - About 45 mins to fix
      lib/active_merchant/billing/gateways/element.rb on lines 163..172

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

      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(xml, payment)
              xml.Card do
                xml.CardNumber payment.number
                xml.ExpirationMonth format(payment.month, :two_digits)
                xml.ExpirationYear format(payment.year, :two_digits)
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/vantiv_express.rb and 1 other location - About 35 mins to fix
      lib/active_merchant/billing/gateways/element.rb on lines 268..274

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

      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_payment_method(xml, payment)
              if payment.is_a?(String)
                add_payment_account_id(xml, payment)
              elsif payment.is_a?(Check)
                add_echeck(xml, payment)
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/vantiv_express.rb and 1 other location - About 15 mins to fix
      lib/active_merchant/billing/gateways/element.rb on lines 176..185

      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