activemerchant/active_merchant

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

Summary

Maintainability
D
1 day
Test Coverage

Class PaysafeGateway has 44 methods (exceeds 20 allowed). Consider refactoring.
Open

    class PaysafeGateway < Gateway
      self.test_url = 'https://api.test.paysafe.com'
      self.live_url = 'https://api.paysafe.com'

      self.supported_countries = %w(AL AT BE BA BG CA HR CY CZ DK EE FI FR DE GR HU IS IE IT LV LI LT LU MT ME NL MK NO PL PT RO RS SK SI ES SE CH TR GB US)
Severity: Minor
Found in lib/active_merchant/billing/gateways/paysafe.rb - About 6 hrs to fix

    File paysafe.rb has 330 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module ActiveMerchant #:nodoc:
      module Billing #:nodoc:
        class PaysafeGateway < Gateway
          self.test_url = 'https://api.test.paysafe.com'
          self.live_url = 'https://api.paysafe.com'
    Severity: Minor
    Found in lib/active_merchant/billing/gateways/paysafe.rb - About 3 hrs to fix

      Method add_stored_credential has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

            def add_stored_credential(post, options)
              return unless options[:stored_credential]
      
              post[:storedCredential] = {}
      
      
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/paysafe.rb - About 55 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_airline_travel_details has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def add_airline_travel_details(post, options)
              return unless options[:airline_travel_details]
      
              post[:airlineTravelDetails] = {}
              post[:airlineTravelDetails][:passengerName] = options[:airline_travel_details][:passenger_name] if options[:airline_travel_details][:passenger_name]
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/paysafe.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_profile_data has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def add_profile_data(post, payment, options)
              post[:firstName] = payment.first_name
              post[:lastName] = payment.last_name
              post[:dateOfBirth] = {}
              post[:dateOfBirth][:year] = options[:date_of_birth][:year]
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/paysafe.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_split_pay_details has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def add_split_pay_details(post, options)
              return unless options[:split_pay]
      
              split_pay = []
              options[:split_pay].each do |pmnt|
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/paysafe.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 add_travel_agency_details(post, options)
              return unless agency = options[:airline_travel_details][:travel_agency]
      
              post[:airlineTravelDetails][:travelAgency] = {}
              post[:airlineTravelDetails][:travelAgency][:name] = agency[:name] if agency[:name]
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/paysafe.rb and 1 other location - About 55 mins to fix
      lib/active_merchant/billing/gateways/paysafe.rb on lines 226..231

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

      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_ticket_details(post, options)
              return unless ticket = options[:airline_travel_details][:ticket]
      
              post[:airlineTravelDetails][:ticket] = {}
              post[:airlineTravelDetails][:ticket][:ticketNumber] = ticket[:ticket_number] if ticket[:ticket_number]
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/paysafe.rb and 1 other location - About 55 mins to fix
      lib/active_merchant/billing/gateways/paysafe.rb on lines 234..239

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

      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

            self.supported_countries = %w(AL AT BE BA BG CA HR CY CZ DK EE FI FR DE GR HU IS IE IT LV LI LT LU MT ME NL MK NO PL PT RO RS SK SI ES SE CH TR GB US)
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/paysafe.rb and 1 other location - About 50 mins to fix
      lib/active_merchant/billing/gateways/paymill.rb on lines 4..6

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

      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