Class PayuLatamGateway
has 44 methods (exceeds 20 allowed). Consider refactoring. Open
class PayuLatamGateway < Gateway
self.display_name = 'PayU Latam'
self.homepage_url = 'http://www.payulatam.com'
self.test_url = 'https://sandbox.api.payulatam.com/payments-api/4.0/service.cgi'
File payu_latam.rb
has 410 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'digest/md5'
module ActiveMerchant #:nodoc:
module Billing #:nodoc:
class PayuLatamGateway < Gateway
Method add_buyer
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def add_buyer(post, payment_method, options)
buyer = {}
if buyer_hash = options[:buyer]
buyer[:fullName] = buyer_hash[:name]
buyer[:dniNumber] = buyer_hash[:dni_number]
- Read upRead up
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_payment_method
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def add_payment_method(post, payment_method, options)
if payment_method.is_a?(String)
brand, token = split_authorization(payment_method)
credit_card = {}
credit_card[:securityCode] = options[:cvv] if options[:cvv]
- Read upRead up
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 auth_or_sale
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def auth_or_sale(post, transaction_type, amount, payment_method, options)
Method commit
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def commit(action, params)
raw_response = ssl_post(url, post_data(params), headers)
response = parse(raw_response)
rescue ResponseError => e
raw_response = e.response.body
- Read upRead up
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
Avoid too many return
statements within this method. Open
return response_code if response_code
Method add_payer
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def add_payer(post, payment_method, options)
address = options[:billing_address]
payer = {}
payer[:fullName] = payment_method.name.strip
payer[:contactPhone] = address[:phone] if address && address[:phone]
- Read upRead up
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_transaction_response
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def message_from_transaction_response(success, response)
response_code = response.dig('transactionResponse', 'responseCode') || response.dig('transactionResponse', 'pendingReason')
return response_code if success
return response_code + ' | ' + response.dig('transactionResponse', 'paymentNetworkResponseErrorMessage') if response.dig('transactionResponse', 'paymentNetworkResponseErrorMessage')
return response.dig('transactionResponse', 'responseMessage') if response.dig('transactionResponse', 'responseMessage')
- Read upRead up
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 error_from
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def error_from(action, response)
case action
when 'store'
response['creditCardToken']['errorDescription'] if response['creditCardToken']
when 'verify_credentials'
- Read upRead up
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"