app/controllers/preauthorize_transactions_controller.rb
File preauthorize_transactions_controller.rb
has 383 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
class PreauthorizeTransactionsController < ApplicationController
before_action do |controller|
controller.ensure_logged_in t("layouts.notifications.you_must_log_in_to_do_a_transaction")
end
Class PreauthorizeTransactionsController
has 23 methods (exceeds 20 allowed). Consider refactoring. Open
Open
class PreauthorizeTransactionsController < ApplicationController
before_action do |controller|
controller.ensure_logged_in t("layouts.notifications.you_must_log_in_to_do_a_transaction")
end
Method create_preauth_transaction
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def create_preauth_transaction(opts)
case opts[:payment_type].to_sym
when :paypal
# PayPal doesn't like images with cache buster in the URL
logo_url = Maybe(opts[:community])
Method initiation_success
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def initiation_success(tx_params)
record_event(
flash.now,
"InitiatePreauthorizedTransaction",
{ listing_id: listing.id,
Method stripe_confirm_intent
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def stripe_confirm_intent
tx = Transaction.where(community: @current_community).find(params[:id])
unless tx.participations.include?(@current_user)
return
end
Method ensure_can_receive_payment
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
def ensure_can_receive_payment
payment_type = @current_community.active_payment_types || :none
ready = TransactionService::Transaction.can_start_transaction(transaction: {
payment_gateway: payment_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"