sharetribe/sharetribe

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

Summary

Maintainability
C
7 hrs
Test Coverage

Method create has 56 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def create(community_id:, person_id: nil, order_permission_request_token:, body:, flow: :old)
      if flow == :new
        validation = @onboarding.validate_result_params(body[:onboarding_params])
        unless validation[:success]
          @logger.warn("Failed to connect paypal account for cid: #{community_id}, pid: #{person_id}, onboarding_params: #{body[:onboarding_params]}")
Severity: Major
Found in app/services/paypal_service/api/accounts.rb - About 2 hrs to fix

    Method request has 43 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def request(body:, flow: :old)
          if flow == :new
            # TODO partnerLogoUrl
            onboarding_link = @onboarding.create_onboarding_link({
              returnToPartnerUrl: body[:callback_url]})
    Severity: Minor
    Found in app/services/paypal_service/api/accounts.rb - About 1 hr to fix

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

          def billing_agreement_create(community_id:, person_id:, billing_agreement_request_token:)
            paypal_account = PaypalAccountStore.get_active(person_id: person_id, community_id: community_id)
      
            with_success_merchant(
              PaypalService::DataTypes::Merchant
      Severity: Minor
      Found in app/services/paypal_service/api/accounts.rb - About 1 hr to fix

        Method create_verified_account! has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def create_verified_account!(community_id:, person_id: nil, order_permission_request_token:, order_permission_onboarding_id:, payer_id:, opts:)
              existing = PaypalAccountStore.get(
                community_id: community_id,
                person_id: person_id,
                payer_id: payer_id
        Severity: Minor
        Found in app/services/paypal_service/api/accounts.rb - About 1 hr to fix

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

              def billing_agreement_request(community_id:, person_id:, body:)
                # If a request for new billing agreement is made, delete old (not completely actived) billing agreement
                # Future note: This may not be sufficient solution when we implement the option to
                # switch PayPal account
                PaypalAccountStore.delete_billing_agreement(person_id: body[:person_id], community_id: body[:community_id])
          Severity: Minor
          Found in app/services/paypal_service/api/accounts.rb - About 1 hr to fix

            Method request has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def request(body:, flow: :old)
                  if flow == :new
                    # TODO partnerLogoUrl
                    onboarding_link = @onboarding.create_onboarding_link({
                      returnToPartnerUrl: body[:callback_url]})
            Severity: Minor
            Found in app/services/paypal_service/api/accounts.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