Shopify/active_merchant

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

Summary

Maintainability
F
5 days
Test Coverage

Method add_lodging has a Cognitive Complexity of 71 (exceeds 5 allowed). Consider refactoring.
Open

      def add_lodging(xml, options)
        if lodging = options[:lodging]
          xml.extendedParameters do
            xml.ExtendedParameters do
              xml.Key 'Lodging'
Severity: Minor
Found in lib/active_merchant/billing/gateways/element.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_address has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
Open

      def add_address(xml, options)
        if address = options[:billing_address] || options[:address]
          address[:email] ||= options[:email]
          xml.address do
            xml.BillingAddress1 address[:address1] if address[:address1]
Severity: Minor
Found in lib/active_merchant/billing/gateways/element.rb - About 7 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_transaction has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
Open

      def add_transaction(xml, money, options = {})
        xml.transaction do
          xml.ReversalType 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/element.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

File element.rb has 373 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/element.rb - About 4 hrs to fix

    Class ElementGateway has 36 methods (exceeds 20 allowed). Consider refactoring.
    Open

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

      Method url has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def url(action)
              if action == 'PaymentAccountCreate'
                test? ? SERVICE_TEST_URL : SERVICE_LIVE_URL
              else
                test? ? test_url : live_url
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/element.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/element.rb and 1 other location - About 3 hrs to fix
      lib/active_merchant/billing/gateways/vantiv_express.rb on lines 372..385

      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

                xml.address do
                  xml.BillingAddress1 address[:address1] if address[:address1]
                  xml.BillingAddress2 address[:address2] if address[:address2]
                  xml.BillingCity address[:city] if address[:city]
                  xml.BillingState address[:state] if address[:state]
      Severity: Major
      Found in lib/active_merchant/billing/gateways/element.rb and 1 other location - About 1 hr to fix
      lib/active_merchant/billing/gateways/element.rb on lines 312..319

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

      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

                xml.address do
                  xml.ShippingAddress1 shipping_address[:address1] if shipping_address[:address1]
                  xml.ShippingAddress2 shipping_address[:address2] if shipping_address[:address2]
                  xml.ShippingCity shipping_address[:city] if shipping_address[:city]
                  xml.ShippingState shipping_address[:state] if shipping_address[:state]
      Severity: Major
      Found in lib/active_merchant/billing/gateways/element.rb and 1 other location - About 1 hr to fix
      lib/active_merchant/billing/gateways/element.rb on lines 301..308

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

      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/element.rb and 1 other location - About 45 mins to fix
      lib/active_merchant/billing/gateways/vantiv_express.rb on lines 297..306

      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 capture(money, authorization, options = {})
              trans_id, = split_authorization(authorization)
              options[:trans_id] = trans_id
      
              request = build_soap_request do |xml|
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/element.rb and 1 other location - About 40 mins to fix
      lib/active_merchant/billing/gateways/element.rb on lines 77..89

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

      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, = split_authorization(authorization)
              options[:trans_id] = trans_id
      
              request = build_soap_request do |xml|
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/element.rb and 1 other location - About 40 mins to fix
      lib/active_merchant/billing/gateways/element.rb on lines 62..74

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

      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/element.rb and 1 other location - About 35 mins to fix
      lib/active_merchant/billing/gateways/vantiv_express.rb on lines 408..414

      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/element.rb and 1 other location - About 15 mins to fix
      lib/active_merchant/billing/gateways/vantiv_express.rb on lines 310..319

      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