payolapayments/payola

View on GitHub

Showing 42 of 42 total issues

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

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

            initialize: function() {
                $(document).off('submit.payola-payment-form').on(
                    'submit.payola-payment-form', '.payola-payment-form',
                    function() {
                        return PayolaPaymentForm.handleSubmit($(this));
        Severity: Major
        Found in app/assets/javascripts/payola/form.js and 2 other locations - About 1 hr to fix
        app/assets/javascripts/payola/subscription_form_onestep.js on lines 2..9
        app/assets/javascripts/payola/subscription_form_twostep.js on lines 2..9

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

        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 3 locations. Consider refactoring.
        Open

            initialize: function() {
                $(document).off('submit.payola-subscription-form').on(
                    'submit.payola-subscription-form', '.payola-subscription-form',
                    function() {
                        return PayolaSubscriptionForm.handleSubmit($(this));
        Severity: Major
        Found in app/assets/javascripts/payola/subscription_form_twostep.js and 2 other locations - About 1 hr to fix
        app/assets/javascripts/payola/form.js on lines 2..9
        app/assets/javascripts/payola/subscription_form_onestep.js on lines 2..9

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

        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 3 locations. Consider refactoring.
        Open

            initialize: function() {
                $(document).off('submit.payola-onestep-subscription-form').on(
                    'submit.payola-onestep-subscription-form', '.payola-onestep-subscription-form',
                    function() {
                        return PayolaOnestepSubscriptionForm.handleSubmit($(this));
        Severity: Major
        Found in app/assets/javascripts/payola/subscription_form_onestep.js and 2 other locations - About 1 hr to fix
        app/assets/javascripts/payola/form.js on lines 2..9
        app/assets/javascripts/payola/subscription_form_twostep.js on lines 2..9

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

        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

        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

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

            def create
              if params[:customer_id].present? && params[:stripeToken].present?
                Payola::CreateCard.call(params[:customer_id], params[:stripeToken])
                flash_options = { notice: t('payola.cards.created') }
              else
        Severity: Minor
        Found in app/controllers/payola/cards_controller.rb and 1 other location - About 40 mins to fix
        app/controllers/payola/cards_controller.rb on lines 16..24

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

        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

            def destroy
              if params[:id].present? && params[:customer_id].present?
                Payola::DestroyCard.call(params[:id], params[:customer_id])
                flash_options = { notice: t('payola.cards.destroyed') }
              else
        Severity: Minor
        Found in app/controllers/payola/cards_controller.rb and 1 other location - About 40 mins to fix
        app/controllers/payola/cards_controller.rb on lines 6..14

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

        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

        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

            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.customers.not_authorized')
            Severity: Minor
            Found in app/controllers/payola/customers_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