sharetribe/sharetribe

View on GitHub
app/services/paypal_service/api/payments.rb

Summary

Maintainability
D
1 day
Test Coverage

File payments.rb has 380 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module PaypalService::API

  class Payments

    # Include with_success for wrapping requests and responses
Severity: Minor
Found in app/services/paypal_service/api/payments.rb - About 5 hrs to fix

    Class Payments has 27 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Payments
    
        # Include with_success for wrapping requests and responses
        include RequestWrapper
    
    
    Severity: Minor
    Found in app/services/paypal_service/api/payments.rb - About 3 hrs to fix

      Method create_payment has 57 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def create_payment(token)
            @lookup.with_merchant_account(token[:community_id], token) do |m_acc|
              with_success(token[:community_id], token[:transaction_id],
                MerchantData.create_get_express_checkout_details(
                  { receiver_username: m_acc[:payer_id], token: token[:token] }
      Severity: Major
      Found in app/services/paypal_service/api/payments.rb - About 2 hrs to fix

        Method do_request has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def do_request(community_id, create_payment, m_acc)
              create_payment_data = create_payment.merge(
                { receiver_username: m_acc[:payer_id],
                  invnum: Invnum.create(community_id, create_payment[:transaction_id], :payment)})
              request =
        Severity: Minor
        Found in app/services/paypal_service/api/payments.rb - About 1 hr to fix

          Method void_payment has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def void_payment(community_id, transaction_id, payment, flow, m_acc, note = nil)
          Severity: Minor
          Found in app/services/paypal_service/api/payments.rb - About 45 mins to fix

            Method do_void has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def do_void(community_id, transaction_id, info, payment, m_acc)
            Severity: Minor
            Found in app/services/paypal_service/api/payments.rb - About 35 mins to fix

              Method do_full_capture has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def do_full_capture(community_id, transaction_id, info, payment, m_acc)
              Severity: Minor
              Found in app/services/paypal_service/api/payments.rb - About 35 mins to fix

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                        if !force_sync
                          proc_token = Worker.enqueue_payments_op(
                            community_id: community_id,
                            transaction_id: transaction_id,
                            op_name: :do_full_capture,
                Severity: Minor
                Found in app/services/paypal_service/api/payments.rb and 1 other location - About 25 mins to fix
                app/services/paypal_service/api/payments.rb on lines 223..232

                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 29.

                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

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                        if !force_sync
                          proc_token = Worker.enqueue_payments_op(
                            community_id: community_id,
                            transaction_id: transaction_id,
                            op_name: :do_void,
                Severity: Minor
                Found in app/services/paypal_service/api/payments.rb and 1 other location - About 25 mins to fix
                app/services/paypal_service/api/payments.rb on lines 167..176

                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 29.

                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

                Further Reading

                There are no issues that match your filters.

                Category
                Status