activemerchant/active_merchant

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

Summary

Maintainability
D
1 day
Test Coverage

File blue_pay.rb has 379 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'digest/md5'

module ActiveMerchant #:nodoc:
  module Billing #:nodoc:
    class BluePayGateway < Gateway
Severity: Minor
Found in lib/active_merchant/billing/gateways/blue_pay.rb - About 5 hrs to fix

    Class BluePayGateway has 33 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class BluePayGateway < Gateway
          class_attribute :rebilling_url, :ignore_http_status
    
          self.live_url      = 'https://secure.bluepay.com/interfaces/bp20post'
          self.rebilling_url = 'https://secure.bluepay.com/interfaces/bp20rebadmin'
    Severity: Minor
    Found in lib/active_merchant/billing/gateways/blue_pay.rb - About 4 hrs to fix

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

            def commit(action, money, fields, options = {})
              fields[:AMOUNT] = amount(money) unless fields[:TRANS_TYPE] == 'VOID' || action == 'rebill'
              fields[:MODE] = (test? ? 'TEST' : 'LIVE')
              fields[:ACCOUNT_ID] = @options[:login]
              fields[:CUSTOMER_IP] = options[:ip] if options[:ip]
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/blue_pay.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 message_from has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def message_from(parsed)
              message = parsed[:message]
              if parsed[:response_code].to_i == 2
                if CARD_CODE_ERRORS.include?(parsed[:card_code])
                  message = CVVResult.messages[parsed[:card_code]]
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/blue_pay.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 parse has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def parse(body)
              # The bp20api has max one value per form field.
              response_fields = CGI::parse(body).map { |k, v| [k.upcase, v.first] }.to_h
      
              return parse_recurring(response_fields) if response_fields.include? 'REBILL_ID'
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/blue_pay.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 refund has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def refund(money, identification, options = {})
              if identification && !identification.kind_of?(String)
                ActiveMerchant.deprecated 'refund should only be used to refund a referenced transaction'
                return credit(money, identification, options)
              end
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/blue_pay.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 2 locations. Consider refactoring.
      Open

            def purchase(money, payment_object, options = {})
              post = {}
              add_payment_method(post, payment_object)
              add_invoice(post, options)
              add_address(post, options)
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/blue_pay.rb and 1 other location - About 45 mins to fix
      lib/active_merchant/billing/gateways/blue_pay.rb on lines 79..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 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 authorize(money, payment_object, options = {})
              post = {}
              add_payment_method(post, payment_object)
              add_invoice(post, options)
              add_address(post, options)
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/blue_pay.rb and 1 other location - About 45 mins to fix
      lib/active_merchant/billing/gateways/blue_pay.rb on lines 103..113

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

            def add_invoice(post, options)
              post[:ORDER_ID]    = options[:order_id]
              post[:INVOICE_ID]  = options[:invoice]
              post[:invoice_num] = options[:order_id]
              post[:MEMO]        = options[:description]
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/blue_pay.rb and 2 other locations - About 30 mins to fix
      lib/active_merchant/billing/gateways/be2bill.rb on lines 59..64
      lib/active_merchant/billing/gateways/verifi.rb on lines 160..165

      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 add_creditcard(post, creditcard)
              post[:PAYMENT_TYPE]    = 'CREDIT'
              post[:PAYMENT_ACCOUNT] = creditcard.number
              post[:CARD_CVV2]       = creditcard.verification_value
              post[:CARD_EXPIRE]     = expdate(creditcard)
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/blue_pay.rb and 2 other locations - About 25 mins to fix
      lib/active_merchant/billing/gateways/inspire.rb on lines 151..157
      lib/active_merchant/billing/gateways/pay_conex.rb on lines 137..143

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

      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