Showing 977 of 1,450 total issues
Avoid deeply nested control flow statements. Open
card[:fallback_reason] = 'no_chip' if creditcard.read_method == 'fallback_no_chip'
Method message_from_authorization
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def message_from_authorization(response)
if response[:success]
return SUCCESS_MESSAGE
else
return CARD_CODE_MESSAGES[response[:szCVV2ResponseCode]] if CARD_CODE_ERRORS.include?(response[:szCVV2ResponseCode])
- 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 deeply nested control flow statements. Open
card[:fallback_reason] = 'chip_error' if creditcard.read_method == 'fallback_chip_error'
Method add_payment_method
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def add_payment_method(post, payment_method, options)
if payment_method.is_a?(String)
customer_vault_id, = split_authorization(payment_method)
post[:customer_vault_id] = customer_vault_id
elsif payment_method.is_a?(NetworkTokenizationCreditCard)
- 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_purchase_request
has a Cognitive Complexity of 8 (exceeds 5 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)
- 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 8 (exceeds 5 allowed). Consider refactoring. Open
def commit(action, parameters, auth = nil)
url = url_for(action, auth)
authorization_secret_key = parameters[:authorization_secret_key] if parameters
parameters.merge!(parameters[:payment][:credit_card].delete(:card)).delete(:payment) if action == 'store'
response = if %w[refund void].include? action
- 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 8 (exceeds 5 allowed). Consider refactoring. Open
def commit(action, money, fields, options = {})
fields[:AMOUNT] = amount(money) unless fields[:TRANS_TYPE] == 'VOID' || action == 'rebill'
fields[:MODE] = (test? ? 'TEST' : 'LIVE')
fields[:ACCOUNT_ID] = @options[:login]
fields[:CUSTOMER_IP] = options[:ip] if options[:ip]
- 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
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def message_from(results)
if results[:response_code] == DECLINED
return CVVResult.messages[results[:card_code]] if CARD_CODE_ERRORS.include?(results[:card_code])
return AVSResult.messages[results[:avs_result_code]] if AVS_REASON_CODES.include?(results[:response_reason_code]) && AVS_ERRORS.include?(results[:avs_result_code])
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 message_from
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def message_from(parsed)
message = parsed[:message]
if parsed[:response_code].to_i == 2
if CARD_CODE_ERRORS.include?(parsed[:card_code])
message = CVVResult.messages[parsed[:card_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_basket_product
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def add_basket_product(post, basket_options)
basket = []
basket_options.each do |product|
obj = {}
- 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_token
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def create_token(reusable, name, exp_month, exp_year, number, cvc)
Method url_for
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def url_for(action, post)
if token?(post)
[(test? ? TOKEN_TEST_URL : TOKEN_LIVE_URL), action].join('/')
else
(test? ? POST_TEST_URL : POST_LIVE_URL)
- 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 deeply nested control flow statements. Open
opt_element.add_element('value').text = option[:value] unless option[:value].blank?
Method add_address
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def add_address(doc, options)
address = options[:billing_address] || {}
doc.country(address[:country] ? lookup_country_code(address[:country]) : 'NA')
doc.city(address[:city] || 'City')
doc.line1(address[:address1] || '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 full_messages
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def full_messages
result = []
self.each do |key, messages|
next unless messages && !messages.empty?
- 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 deeply nested control flow statements. Open
opt_element.add_element('name').text = option[:name] unless option[:name].blank?
Method raw_ssl_request
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def raw_ssl_request(method, endpoint, data, headers = {})
logger&.warn "#{self.class} using ssl_strict=false, which is insecure" unless ssl_strict
logger&.warn "#{self.class} posting to plaintext endpoint, which is insecure" unless endpoint.to_s =~ /^https:/
connection = new_connection(endpoint)
- 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 8 (exceeds 5 allowed). Consider refactoring. Open
def add_address(xml, payment_source, options)
return unless (address = get_address(options))
if avs_supported?(address[:country]) || empty?(address[:country])
xml.tag! :AVSzip, byte_limit(format_address_field(address[:zip]), 10)
- 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 remote_url
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def remote_url(url = :primary)
if url == :primary
(self.test? ? self.test_url : self.live_url)
else
(self.test? ? self.secondary_test_url : self.secondary_live_url)
- 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 validate
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def validate
errors = []
%i[name routing_number account_number].each do |attr|
errors << [attr, 'cannot be empty'] if empty?(self.send(attr))
- 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"