payolapayments/payola

View on GitHub

Showing 21 of 42 total issues

Method run has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    def run
      begin
        subscription.verify_charge!

        customer = find_or_create_customer
Severity: Minor
Found in app/services/payola/start_subscription.rb - About 2 hrs 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

Method run has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def run
      begin
        subscription.verify_charge!

        customer = find_or_create_customer
Severity: Minor
Found in app/services/payola/start_subscription.rb - About 1 hr to fix

    Method call has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        def self.call(params)
          product   = params[:product]
          affiliate = params[:affiliate]
          coupon    = params[:coupon]
    
    
    Severity: Minor
    Found in app/services/payola/create_sale.rb - About 1 hr 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

    Method find_or_create_customer has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        def find_or_create_customer
          if subscription.stripe_customer_id.present?
            # If an existing Stripe customer id is specified, use it
            stripe_customer_id = subscription.stripe_customer_id
          elsif subscription.owner
    Severity: Minor
    Found in app/services/payola/start_subscription.rb - About 1 hr 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

    Method conditional_stripe_token has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def conditional_stripe_token
          # Don't require a Stripe token if the subscription has an owner - we'll try to reuse the Stripe customer from an existing successful subscription
          return true if owner.present?
          # Don't require a Stripe token if we're creating a subscription for an existing Stripe customer
          return true if stripe_customer_id.present?
    Severity: Minor
    Found in app/models/payola/subscription.rb - About 1 hr 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

    Method find_or_create_customer has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def find_or_create_customer
          if subscription.stripe_customer_id.present?
            # If an existing Stripe customer id is specified, use it
            stripe_customer_id = subscription.stripe_customer_id
          elsif subscription.owner
    Severity: Minor
    Found in app/services/payola/start_subscription.rb - About 1 hr to fix

      Method call has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def self.call(params)
            product   = params[:product]
            affiliate = params[:affiliate]
            coupon    = params[:coupon]
      
      
      Severity: Minor
      Found in app/services/payola/create_sale.rb - About 1 hr to fix

        Method call has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def self.call(params, owner=nil)
              plan = params[:plan]
              affiliate = params[:affiliate]
        
              if params[:stripe_customer_id].present?
        Severity: Minor
        Found in app/services/payola/create_subscription.rb - About 1 hr 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

        Function handleCheckoutButtonClick has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            handleCheckoutButtonClick: function(button) {
                var form = button.parent('form');
                var options = form.data();
        
                if (options.stripe_customer_id) {
        Severity: Minor
        Found in app/assets/javascripts/payola/subscription_checkout_button.js - About 1 hr to fix

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

              def self.call(params, owner=nil)
                plan = params[:plan]
                affiliate = params[:affiliate]
          
                if params[:stripe_customer_id].present?
          Severity: Minor
          Found in app/services/payola/create_subscription.rb - About 1 hr to fix

            Method sync_with! has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def sync_with!(stripe_sub)
                  self.current_period_start = Time.at(stripe_sub.current_period_start)
                  self.current_period_end   = Time.at(stripe_sub.current_period_end)
                  self.ended_at             = Time.at(stripe_sub.ended_at) if stripe_sub.ended_at
                  self.trial_start          = Time.at(stripe_sub.trial_start) if stripe_sub.trial_start
            Severity: Minor
            Found in app/models/payola/subscription.rb - About 45 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

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

                def create_object(object_class, object_creator_class, object_processor_class, product_key, product)
            Severity: Minor
            Found in app/controllers/concerns/payola/async_behavior.rb - About 35 mins to fix

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

                  def self.call(subscription, plan, quantity = 1, coupon_code = nil, trial_end = nil)
              Severity: Minor
              Found in app/services/payola/change_subscription_plan.rb - About 35 mins to fix

                Method receipt has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    def receipt(sale_guid)
                      ActiveRecord::Base.connection_pool.with_connection do
                        @sale = Payola::Sale.find_by(guid: sale_guid)
                        @product = @sale.product
                
                
                Severity: Minor
                Found in app/mailers/payola/receipt_mailer.rb - About 35 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

                Method call has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    def self.call(plan)
                      secret_key = Payola.secret_key_for_sale(plan)
                
                      begin
                        return Stripe::Plan.retrieve(plan.stripe_id, secret_key)
                Severity: Minor
                Found in app/services/payola/create_plan.rb - About 35 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

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

                    def check_modify_permissions
                      subscription = Subscription.find_by!(guid: params[:guid])
                      if self.respond_to?(:payola_can_modify_subscription?)
                        redirect_to(
                          confirm_subscription_path(subscription),
                Severity: Minor
                Found in app/controllers/payola/subscriptions_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

                Function poll has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    poll: function(form, num_retries_left, guid, base_path) {
                        if (num_retries_left === 0) {
                            PayolaSubscriptionForm.showError(form, "This seems to be taking too long. Please contact support and give them transaction ID: " + guid);
                        }
                        var handler = function(data) {
                Severity: Minor
                Found in app/assets/javascripts/payola/subscription_form_twostep.js - 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

                Function poll has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    poll: function(form, num_retries_left, guid, base_path) {
                        if (num_retries_left === 0) {
                            PayolaRegistrationForm.showError(form, "This seems to be taking too long. Please contact support and give them transaction ID: " + guid);
                        }
                        var handler = function(data) {
                Severity: Minor
                Found in app/assets/javascripts/payola/subscription_form_register.js - 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

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

                    def send_email_for(*emails)
                      emails.each do |email|
                        spec = DEFAULT_EMAILS[email].dup
                        if spec
                          Payola.subscribe(spec.shift) do |sale|
                Severity: Minor
                Found in lib/payola.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

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

                    def check_modify_permissions
                      if self.respond_to?(:payola_can_modify_customer?)
                        redirect_to(
                          return_to,
                          alert: t('payola.cards.not_authorized')
                Severity: Minor
                Found in app/controllers/payola/cards_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

                Severity
                Category
                Status
                Source
                Language