sharetribe/sharetribe

View on GitHub
app/controllers/preauthorize_transactions_controller.rb

Summary

Maintainability
C
1 day
Test Coverage

File preauthorize_transactions_controller.rb has 383 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class PreauthorizeTransactionsController < ApplicationController

  before_action do |controller|
   controller.ensure_logged_in t("layouts.notifications.you_must_log_in_to_do_a_transaction")
  end
Severity: Minor
Found in app/controllers/preauthorize_transactions_controller.rb - About 5 hrs to fix

    Class PreauthorizeTransactionsController has 23 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class PreauthorizeTransactionsController < ApplicationController
    
      before_action do |controller|
       controller.ensure_logged_in t("layouts.notifications.you_must_log_in_to_do_a_transaction")
      end
    Severity: Minor
    Found in app/controllers/preauthorize_transactions_controller.rb - About 2 hrs to fix

      Method create_preauth_transaction has 53 lines of code (exceeds 25 allowed). Consider refactoring.
      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])
      Severity: Major
      Found in app/controllers/preauthorize_transactions_controller.rb - About 2 hrs to fix

        Method initiation_success has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def initiation_success(tx_params)
            record_event(
              flash.now,
              "InitiatePreauthorizedTransaction",
              { listing_id: listing.id,
        Severity: Minor
        Found in app/controllers/preauthorize_transactions_controller.rb - About 1 hr to fix

          Method stripe_confirm_intent has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def stripe_confirm_intent
              tx = Transaction.where(community: @current_community).find(params[:id])
              unless tx.participations.include?(@current_user)
                return
              end
          Severity: Minor
          Found in app/controllers/preauthorize_transactions_controller.rb - About 1 hr to fix

            Method ensure_can_receive_payment has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            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,
            Severity: Minor
            Found in app/controllers/preauthorize_transactions_controller.rb - About 25 mins to fix

            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

            There are no issues that match your filters.

            Category
            Status