Shopify/active_merchant

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

Summary

Maintainability
D
2 days
Test Coverage

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

    class SimetrikGateway < Gateway
      self.test_url = 'https://payments.sta.simetrik.com/v1'
      self.live_url = 'https://payments.simetrik.com/v1'

      class_attribute :test_auth_url, :live_auth_url, :test_audience, :live_audience
Severity: Minor
Found in lib/active_merchant/billing/gateways/simetrik.rb - About 4 hrs to fix

    File simetrik.rb has 312 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module ActiveMerchant #:nodoc:
      module Billing #:nodoc:
        class SimetrikGateway < Gateway
          self.test_url = 'https://payments.sta.simetrik.com/v1'
          self.live_url = 'https://payments.simetrik.com/v1'
    Severity: Minor
    Found in lib/active_merchant/billing/gateways/simetrik.rb - About 3 hrs to fix

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

            def add_address(tag, post, options)
              return unless address_options = options[:shipping_address]
      
              address = {}
              address[:name] = address_options[:name] if address_options[:name]
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/simetrik.rb - About 1 hr 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_three_ds_fields has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

            def add_three_ds_fields(post, three_ds_options)
              three_ds = {}
              three_ds[:version] = three_ds_options[:version] if three_ds_options[:version]
              three_ds[:eci] = three_ds_options[:eci] if three_ds_options[:eci]
              three_ds[:cavv] = three_ds_options[:cavv] if three_ds_options[:cavv]
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/simetrik.rb - About 1 hr 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_forward_payload has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

            def add_forward_payload(post, money, payment, options)
              forward_payload = {}
              add_user(forward_payload, options[:user]) if options[:user]
              add_order(forward_payload, money, options)
              add_payment_method(forward_payload, payment, options[:payment_method]) if options[:payment_method] || payment
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/simetrik.rb - About 1 hr 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_sub_merchant has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def add_sub_merchant(post, sub_merchant_options)
              sub_merchant = {}
              sub_merchant[:merchant_id] = sub_merchant_options[:merchant_id] if sub_merchant_options[:merchant_id]
              sub_merchant[:extra_params] = sub_merchant_options[:extra_params] if sub_merchant_options[:extra_params]
              sub_merchant[:mcc] =  sub_merchant_options[:mcc] if sub_merchant_options[:mcc]
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/simetrik.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_order has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def add_order(post, money, options)
              return unless options[:order] || money
      
              order = {}
              order_options = options[:order] || {}
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/simetrik.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 add_stored_credential has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def add_stored_credential(post, options)
              return unless options[:stored_credential]
      
              check_initiator = %w[merchant cardholder].any? { |item| item == options[:stored_credential][:initiator] }
              check_reason_type = %w[recurring installment unscheduled].any? { |item| item == options[:stored_credential][:reason_type] }
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/simetrik.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

            STANDARD_ERROR_CODE_MAPPING = {
              'R101' => STANDARD_ERROR_CODE[:incorrect_number],
              'R102' => STANDARD_ERROR_CODE[:invalid_number],
              'R103' => STANDARD_ERROR_CODE[:invalid_expiry_date],
              'R104' => STANDARD_ERROR_CODE[:invalid_cvc],
      Severity: Major
      Found in lib/active_merchant/billing/gateways/simetrik.rb and 1 other location - About 2 hrs to fix
      lib/active_merchant/billing/gateways/authorize_net.rb on lines 38..57

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

      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, options = {})
              requires!(options, :token_acquirer)
      
              post = {}
              add_forward_route(post, options)
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/simetrik.rb and 1 other location - About 20 mins to fix
      lib/active_merchant/billing/gateways/simetrik.rb on lines 115..123

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

      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 purchase(money, payment, options = {})
              requires!(options, :token_acquirer)
      
              post = {}
              add_forward_route(post, options)
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/simetrik.rb and 1 other location - About 20 mins to fix
      lib/active_merchant/billing/gateways/simetrik.rb on lines 51..58

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

      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

              post = {
                forward_payload: {
                  amount: {
                    total_amount: amount(money).to_f,
                    currency: (options[:currency] || currency(money))
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/simetrik.rb and 1 other location - About 20 mins to fix
      lib/active_merchant/billing/gateways/simetrik.rb on lines 83..94

      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

              post = {
                forward_payload: {
                  amount: {
                    total_amount: amount(money).to_f,
                    currency: (options[:currency] || currency(money))
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/simetrik.rb and 1 other location - About 20 mins to fix
      lib/active_merchant/billing/gateways/simetrik.rb on lines 63..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 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

      There are no issues that match your filters.

      Category
      Status