File braintree_blue.rb
has 927 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'active_merchant/billing/gateways/braintree/braintree_common'
require 'active_merchant/billing/gateways/braintree/token_nonce'
require 'active_support/core_ext/array/extract_options'
begin
Class BraintreeBlueGateway
has 75 methods (exceeds 20 allowed). Consider refactoring. Open
class BraintreeBlueGateway < Gateway
include BraintreeCommon
include Empty
self.display_name = 'Braintree (Blue Platform)'
Method transaction_hash
has 91 lines of code (exceeds 25 allowed). Consider refactoring. Open
def transaction_hash(result)
unless result.success?
return { 'processor_response_code' => response_code_from_result(result),
'additional_processor_response' => additional_processor_response_from_result(result),
'payment_instrument_type' => payment_instrument_type(result.transaction),
Method create_transaction_parameters
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create_transaction_parameters(money, credit_card_or_vault_id, options)
parameters = {
amount: localized_amount(money, options[:currency] || default_currency).to_s,
order_id: options[:order_id],
customer: {
Method add_credit_card_to_customer
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def add_credit_card_to_customer(credit_card, options)
commit do
parameters = {
customer_id: options[:customer],
token: options[:credit_card_token],
- 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 create_transaction_parameters
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def create_transaction_parameters(money, credit_card_or_vault_id, options)
parameters = {
amount: localized_amount(money, options[:currency] || default_currency).to_s,
order_id: options[:order_id],
customer: {
- 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_customer_with_credit_card
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def add_customer_with_credit_card(creditcard, options)
commit do
if options[:payment_method_nonce]
credit_card_params = { payment_method_nonce: options[:payment_method_nonce] }
else
Method verify
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def verify(creditcard, options = {})
if options[:allow_card_verification] == true
options.delete(:allow_card_verification)
exp_month = creditcard.month.to_s
exp_year = creditcard.year.to_s
Method add_customer_with_credit_card
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def add_customer_with_credit_card(creditcard, options)
commit do
if options[:payment_method_nonce]
credit_card_params = { payment_method_nonce: options[:payment_method_nonce] }
else
- 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 verify
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def verify(creditcard, options = {})
if options[:allow_card_verification] == true
options.delete(:allow_card_verification)
exp_month = creditcard.month.to_s
exp_year = creditcard.year.to_s
- 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 update
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update(vault_id, creditcard, options = {})
braintree_credit_card = nil
commit do
braintree_credit_card = @braintree_gateway.customer.find(vault_id).credit_cards.detect(&:default?)
return Response.new(false, 'Braintree::NotFoundError') if braintree_credit_card.nil?
Method avs_mapping
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def avs_mapping
{
'street: M, zip: M' => 'M',
'street: M, zip: N' => 'A',
'street: M, zip: U' => 'B',
Method merge_credit_card_options
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def merge_credit_card_options(parameters, options)
valid_options = {}
options.each do |key, value|
valid_options[key] = value if %i[update_existing_token verify_card verification_merchant_account_id].include?(key)
end
- 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_credit_card_to_customer
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def add_credit_card_to_customer(credit_card, options)
commit do
parameters = {
customer_id: options[:customer],
token: options[:credit_card_token],
Method transaction_hash
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def transaction_hash(result)
unless result.success?
return { 'processor_response_code' => response_code_from_result(result),
'additional_processor_response' => additional_processor_response_from_result(result),
'payment_instrument_type' => payment_instrument_type(result.transaction),
- 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 9 (exceeds 5 allowed). Consider refactoring. Open
def add_payment_method(parameters, credit_card_or_vault_id, options)
if credit_card_or_vault_id.is_a?(String) || credit_card_or_vault_id.is_a?(Integer)
add_third_party_token(parameters, credit_card_or_vault_id, options)
else
parameters[:customer].merge!(
- 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 initialize
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def initialize(options = {})
requires!(options, :merchant_id, :public_key, :private_key)
@merchant_account_id = options[:merchant_account_id]
super
- 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 map_address
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def map_address(address)
mapped = {
street_address: address[:address1],
extended_address: address[:address2],
company: address[:company],
- 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 stored_credentials_v2
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def stored_credentials_v2(parameters, stored_credential)
# Differences between v1 and v2 are
# initial_transaction + recurring/installment should be labeled {{reason_type}}_first
# unscheduled in AM should map to '' at BT because unscheduled here means not on a fixed timeline or fixed amount
case stored_credential[:reason_type]
- 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_3ds_info
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def add_3ds_info(parameters, three_d_secure_opts)
return if empty?(three_d_secure_opts)
pass_thru = {}
- 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 update
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def update(vault_id, creditcard, options = {})
braintree_credit_card = nil
commit do
braintree_credit_card = @braintree_gateway.customer.find(vault_id).credit_cards.detect(&:default?)
return Response.new(false, 'Braintree::NotFoundError') if braintree_credit_card.nil?
- 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 refund
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def refund(*args)
# legacy signature: #refund(transaction_id, options = {})
# new signature: #refund(money, transaction_id, options = {})
money, transaction_id, options = extract_refund_args(args)
money = localized_amount(money, options[:currency] || default_currency).to_s if money
- 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 stored_credentials_v1
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def stored_credentials_v1(parameters, stored_credential)
if stored_credential[:initiator] == 'merchant'
if stored_credential[:reason_type] == 'installment'
parameters[:transaction_source] = 'recurring'
else
- 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"