Showing 1,005 of 1,501 total issues
Method add_level3_purchase
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
Open
def add_level3_purchase(xml, options = {})
if (level3 = options[:level_3_data])
xml.tag! :PC3FreightAmt, byte_limit(level3[:freight_amount], 12) if level3[:freight_amount]
xml.tag! :PC3DutyAmt, byte_limit(level3[:duty_amount], 12) if level3[:duty_amount]
xml.tag! :PC3DestCountryCd, byte_limit(level3[:dest_country], 3) if level3[:dest_country]
- 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 recurring
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def recurring(money, payment_source, options = {})
ActiveMerchant.deprecated RECURRING_DEPRECATION_MESSAGE
requires!(options, %i[periodicity monthly weekly daily], :payments)
Method normal_refund
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def normal_refund(amount, authorization, options)
transaction_id, card_number, = split_authorization(authorization)
commit(:refund) do |xml|
xml.transactionRequest do
Method build_request
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def build_request(action)
xml = Builder::XmlMarkup.new(encoding: 'UTF-8')
xml.instruct!(:xml, encoding: 'UTF-8')
xml.SOAP :Envelope, {
'xmlns:SOAP' => 'http://schemas.xmlsoap.org/soap/envelope/',
Method parse
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def parse(body)
reply = {}
xml = REXML::Document.new(body)
if root = REXML::XPath.first(xml, '//soap:Fault') then
reply = parse_fault(root)
Method build_change_profile_request
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def build_change_profile_request(profile_id, options)
xml = Builder::XmlMarkup.new :indent => 2
xml.tag! 'UpdateRecurringPaymentsProfileReq', 'xmlns' => PAYPAL_NAMESPACE do
xml.tag! 'UpdateRecurringPaymentsProfileRequest', 'xmlns:n2' => EBAY_NAMESPACE do
xml.tag! 'n2:Version', API_VERSION
Method build_request
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def build_request(payment_code, money, payment, options)
xml = Builder::XmlMarkup.new indent: 2
xml.instruct!
xml.tag! 'Request', 'version' => API_VERSION do
xml.tag! 'Header' do
Method build_credit_card_request
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def build_credit_card_request(action, money, credit_card, options)
xml = Builder::XmlMarkup.new
xml.tag! TRANSACTIONS[action] do
xml.tag! 'PayData' do
xml.tag! 'Invoice' do
Method build_reference_sale_or_authorization_request
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def build_reference_sale_or_authorization_request(action, money, reference, options)
xml = Builder::XmlMarkup.new
xml.tag! TRANSACTIONS[action] do
xml.tag! 'PayData' do
xml.tag! 'Invoice' do
Method credit
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def credit(money, creditcard, options = {})
post = payment_request(money, options)
post[:amount] = amount_hash(money, options[:currency])
post[:card] = credit_card_hash(creditcard)
post[:dateOfBirth] = options[:date_of_birth] if options[:date_of_birth]
Method store
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def store(payment, options = {})
params = {}
post = {}
if payment.is_a?(ApplePayPaymentToken)
Method add_auth_wallet
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def add_auth_wallet(xml, payment_method, options)
commerce_indicator = 'internet' if subsequent_nt_apple_pay_auth(payment_method.source, options)
brand = card_brand(payment_method).to_sym
Method add_addresses
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def add_addresses(post, options)
if address = options[:billing_address] || options[:address]
post[:card_address1] = address[:address1]
post[:card_zip] = address[:zip]
post[:card_city] = address[:city]
Method soap_request
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def soap_request(arguments, action)
# eWay demands all fields be sent, but contain an empty string if blank
post = case action
when 'QueryCustomer'
arguments
Method parse
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def parse(action, soap)
xml = REXML::Document.new(soap)
root = REXML::XPath.first(xml, '//SOAP-ENV:Body')
response = root ? parse_element(root[0]) : { response: soap }
Method commit
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def commit(action, money, parameters)
case action
when 'sale'
begin
response = call_api(TRANSACTION_API, parameters)
Method update
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
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 build_create_subscription_request
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
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] || {}
)
Method add_pay_data
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def add_pay_data(xml, money, options)
xml.tag! 'PayData' do
xml.tag! 'Invoice' do
xml.tag! 'CustIP', options[:ip] unless options[:ip].blank?
xml.tag! 'InvNum', options[:order_id] unless options[:order_id].blank?
Method add_payout_sender_data
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def add_payout_sender_data(post, options)
return unless options[:payout] == true
post[:sender] = {
# options for type are individual, corporate, or government