Showing 992 of 1,478 total issues
Method get_msg_type
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def get_msg_type(parameters)
return parameters[:mit_msg_type] if parameters[:mit_msg_type]
return 'CSTO' if parameters[:stored_credential][:initial_transaction]
return unless parameters[:stored_credential][:initiator] && parameters[: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_stored_credentials
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def add_stored_credentials(xml, parameters)
return unless parameters[:mit_stored_credential_ind] == 'Y' || parameters[:stored_credential] && !parameters[:stored_credential].values.all?(&:nil?)
if msg_type = get_msg_type(parameters)
xml.tag! :MITMsgType, msg_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 commit
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def commit(action, post, authorization = nil, method = :post)
MultiResponse.run do |r|
r.process { fetch_access_token } unless access_token_valid?
r.process do
api_request(action, post, authorization, method).tap do |response|
- 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 build_void_request_xml
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def build_void_request_xml(authorization, parameters = {})
tx_ref_num, order_id = split_authorization(authorization)
xml = xml_envelope
xml.tag! :Request do
xml.tag! :Reversal do
- 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 build_create_subscription_request
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def build_create_subscription_request(payment_method, options)
default_subscription_params = { frequency: 'on-demand', amount: 0, automatic_renew: false }
options[:subscription] = default_subscription_params.update(
options[:subscription] || {}
)
- 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 do_authorize
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def do_authorize(params)
headers = {}
headers['Referer'] = (options[:password] || 'activemerchant.org')
response = raw_ssl_request(:post, live_url + 'auth/default.aspx', authorize_post_data(params), headers)
- 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 7 (exceeds 5 allowed). Consider refactoring. Open
def initialize(attrs)
attrs ||= {}
@code = attrs[:code].upcase unless attrs[:code].blank?
@message = self.class.messages[code]
- 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_ews_details
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def add_ews_details(xml, payment_source, parameters = {})
split_name = payment_source.first_name.split if payment_source.first_name
xml.tag! :EWSFirstName, split_name[0]
xml.tag! :EWSMiddleName, split_name[1..-1].join(' ')
xml.tag! :EWSLastName, payment_source.last_name
- 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[:szAuthorizationDeclinedMessage]
Avoid too many return
statements within this method. Open
return base + 'payments/refund'
Avoid too many return
statements within this method. Open
return base + 'vault/payment-instrument/token'
Avoid too many return
statements within this method. Open
return response_code if response_code
Avoid too many return
statements within this method. Open
return base + 'noaction'
Avoid too many return
statements within this method. Open
return base + 'vault/token'
Method add_invoice
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def add_invoice(post, money, options)
post[:amount] = localized_amount(money, options[:currency])
post[:reference] = options[:order_id]
post[:currency] = options[:currency] || currency(money)
if options[:descriptor_name] || options[:descriptor_city]
- 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 amount
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def amount(money)
return nil if money.nil?
cents =
if money.respond_to?(:cents)
- 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 6 (exceeds 5 allowed). Consider refactoring. Open
def add_address(post, options)
if address = options[:billing_address] || options[:address]
post[:payment][:address] = address[:address1].split[1..-1].join(' ') if address[:address1]
post[:payment][:street_number] = address[:address1].split.first if address[:address1]
post[:payment][:city] = address[:city]
- 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 parse
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def parse(xml)
response = {}
doc = Nokogiri::XML(xml)
doc.xpath('//response/*').each do |node|
- 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 build_request
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def build_request(action, post, options = {})
mode = action == 'void' ? 'cancel' : 'get'
transaction_type = action == '3ds_preauth' ? '3DSAuthentication' : 'Authorization'
xml = Builder::XmlMarkup.new indent: 18
xml.instruct!(:xml, version: '1.0', encoding: 'utf-8')
- 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 acquire_access_token
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def acquire_access_token
post = {}
base_url = (test? ? test_url : live_url)
post[:grant_type] = 'password'
post[:username] = @options[:username]
- 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"