Showing 1,501 of 1,501 total issues
Method add_stored_credential
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def add_stored_credential(post, options)
return unless (stored_credential = options[:stored_credential])
if stored_credential[:initiator] == 'cardholder'
post[:initiated_by] = '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_data
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def add_customer_data(post, options)
post[:email] = options[:email]
post[:ipaddress] = options[:ip]
post[:customer_id] = options[:customer_id] || options[: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 authorization_from
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def authorization_from(success, url, method, response, options)
return error_id(response, url) unless success
if url == 'customers'
[response['id'], response.dig('sources', 'data').first&.dig('id')].join('|')
- 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 10 (exceeds 5 allowed). Consider refactoring. Open
def commit(action, parameters)
url = (test? ? test_url : live_url) + action
headers = headers(@options[:api_key])
body = parameters.to_query
- 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_sub_merchant
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def add_sub_merchant(xml, submerchant)
xml.tag!('v1:SubMerchant') do
xml.tag!('v1:Mcc', submerchant[:mcc]) if submerchant[:mcc]
xml.tag!('v1:LegalName', submerchant[:legal_name]) if submerchant[:legal_name]
add_address(xml, submerchant[:address]) if submerchant[: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 add_invoice
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def add_invoice(post, money, options)
post[:order_number] = options[:order_id] if options[:order_id].present?
if options[:item_codes].present?
codes_and_amounts = options[:item_codes].transform_keys { |key| key.to_s.delete('_') }
- 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_invoice
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def add_invoice(xml, money, options)
xml.AuthCode options[:force] if options[:force]
if options[:order_items].blank?
xml.Total(amount(money)) unless money.nil? || money < 0.01
xml.Description(options[:description]) unless options[:description].blank?
- 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 10 (exceeds 5 allowed). Consider refactoring. Open
def build_request(body, options = {})
xml = Builder::XmlMarkup.new
xml.instruct!
xml.tag! 'XMLPayRequest', 'Timeout' => timeout.to_s, 'version' => '2.1', 'xmlns' => XMLNS do
xml.tag! 'RequestData' 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 add_mc_ucafind
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def add_mc_ucafind(xml, credit_card, three_d_secure, options)
return unless three_d_secure
if options[:alternate_ucaf_flow]
return unless %w(4 6 7).include?(three_d_secure[:eci])
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
if shipping_address = options[:shipping_address] || options[:address]
post[:ci_shipaddr1] = shipping_address[:address1].to_s
post[:ci_shipaddr2] = shipping_address[:address2].to_s unless shipping_address[:address2].blank?
post[:ci_shipcity] = shipping_address[:city].to_s
post[:ci_shipstate] = shipping_address[:state].to_s
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 50.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Method add_customer_data
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def add_customer_data(post, options)
if options.has_key? :email
post[:email] = options[:email]
post[:email_customer] = false
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
Similar blocks of code found in 2 locations. Consider refactoring. Open
if address = options[:billing_address] || options[:address]
post[:ci_billaddr1] = address[:address1].to_s
post[:ci_billaddr2] = address[:address2].to_s unless address[:address2].blank?
post[:ci_billcity] = address[:city].to_s
post[:ci_billstate] = address[:state].to_s
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 50.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Method add_other_tax
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def add_other_tax(xml, options)
return unless %i[vat_tax_rate local_tax_amount national_tax_amount national_tax_indicator].any? { |gsf| options.include?(gsf) }
xml.tag! 'otherTax' do
xml.tag! 'vatTaxRate', options[:vat_tax_rate] if options[:vat_tax_rate]
- 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 send_initialize
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def send_initialize(amount, is_auth, options = {})
properties = {
accountNumber: @options[:account],
purchaseOperation: is_auth ? 'AUTHORIZATION' : 'SALE',
price: amount,
Method generate_signature
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def generate_signature(action, parameters)
signature_fields =
case action
when CECA_ACTION_REFUND
options[:signature_key].to_s +
Method add_payment_method
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def add_payment_method(post, payment_method)
case payment_method
when String
token, exp_month, exp_year = payment_method.split('|')[2..4]
card = {
Method commit
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def commit(action, request, *success_criteria, options)
xml = ssl_post(url, request, headers(options))
raw = parse(action, xml)
if options[:execute_threed]
Method build_mass_pay_request
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def build_mass_pay_request(*args)
default_options = args.last.is_a?(Hash) ? args.pop : {}
recipients = args.first.is_a?(Array) ? args : [args]
receiver_type = default_options[:receiver_type]
Method add_address
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def add_address(post, creditcard, options)
shipping_address = options[:shipping_address]
if billing_address = options[:billing_address] || options[:address]
post['order']['customer']['billingAddress'] = {
'street' => truncate(split_address(billing_address[:address1])[1], 50),
Method commit
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def commit(action, params: '', iid: '', card_number: nil, jwt: '')
response =
begin
case action
when 'void'