Showing 1,005 of 1,501 total issues
Method add_credit_card
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def add_credit_card(xml, credit_card, address)
xml.tag! :Card do
# DataCash calls the CC number 'pan'
xml.tag! :pan, credit_card.number
xml.tag! :expirydate, format_date(credit_card.month, credit_card.year)
Method add_customer_data
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def add_customer_data(post, payment_method, options)
billing = {}
shipping = {}
customer = {}
device = {}
Method legacy_parse
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def legacy_parse(action, xml)
response = {}
error_messages = []
error_codes = []
Method add_contact
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def add_contact(doc, fullname, options)
doc['v1'].contact do
doc['v1'].fullName fullname unless fullname.blank?
doc['v1'].coName options[:company_name] if options[:company_name]
doc['v1'].title options[:title] if options[:title]
Method commit
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def commit(action, body, options, try_again = true)
credentials = ensure_credentials
payload = encrypt_payload(body, credentials, options)
if options.dig :http, :method
Consider simplifying this complex logical expression. Open
if response['refusalReason'] && response['additionalData'] && (response['additionalData']['merchantAdviceCode'] || response['additionalData']['refusalReasonRaw'])
"#{response['refusalReason']} | #{response['additionalData']['merchantAdviceCode'] || response['additionalData']['refusalReasonRaw']}"
else
response['refusalReason'] || response['resultCode'] || response['message'] || response['result']
end
Consider simplifying this complex logical expression. Open
if address = options[:billing_address] || options[:address]
post[:data][:attributes][:billingAddress] = {
line1: address[:address1] || '',
line2: address[:address2] || '',
city: address[:city] || '',
Method parse_cim
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def parse_cim(body, options)
response = {}
doc = Nokogiri::XML(body).remove_namespaces!
Method parse
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def parse(data, action)
params = {}
success = false
message = ''
options = @options.merge(test: test?)
Method build_purchase_request
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def build_purchase_request(money, payment_method_or_reference, options)
xml = Builder::XmlMarkup.new indent: 2
add_customer_id(xml, options)
add_payment_method_or_subscription(xml, money, payment_method_or_reference, options)
add_threeds_2_ucaf_data(xml, payment_method_or_reference, options)
Method error_code_from
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def error_code_from(response)
unless success_from(response)
case response['result']['code']
when '100.100.101'
STANDARD_ERROR_CODE[:incorrect_number]
Method add_3ds_data
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def add_3ds_data(post, options = {})
three_d_secure = options[:three_ds_2]
# 01 => Challenge requested, 02 => Exemption requested, 03 or not sending parameter => No preference
challenge_preference = if [true, 'true'].include?(options[:force_3d_secure])
'01'
Method add_card_or_token_payment
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def add_card_or_token_payment(xml, card_or_token, options)
xml.hps :CardData do
if card_or_token.respond_to?(:number)
if card_or_token.track_data
xml.tag!('hps:TrackData', 'method' => 'swipe') do
Method add_payment_method_id
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def add_payment_method_id(options)
return options[:payment_method_id].to_i if options[:payment_method_id]
if options[:debit]
case options[:card_brand]
Method commit
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def commit(action, parameters, method = 'POST')
url = (test? ? test_url : live_url)
if no_hmac(action)
request_headers = headers.merge(create_basic(parameters, action))
else
Method localized_amount
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def localized_amount(money, currency)
amount = amount(money)
return amount unless non_fractional_currency?(currency) || three_decimal_currency?(currency)
- 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_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]
- 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_address
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def add_address(post, options)
return unless post[:card]&.kind_of?(Hash)
card_address = {}
if address = options[:billing_address] || options[:address]
- 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 purchase
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def purchase(money, payment_or_customer_id, options = {})
if visa_or_mastercard?(options)
MultiResponse.run(:use_first_response) do |r|
endpoint = customer_id?(payment_or_customer_id) ? ENDPOINTS[:customer_id_sale] : ENDPOINTS[:keyed_sale]
- 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_stored_credentials
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def add_stored_credentials(post, creditcard, options)
return unless stored_credential = options[:stored_credential]
return if options[:exemption_type].blank? && !(stored_credential[:reason_type] && stored_credential[:initiator])
- 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"