integrallis/stripe_saas

View on GitHub
app/concerns/stripe_saas/subscription.rb

Summary

Maintainability
C
7 hrs
Test Coverage

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

    def processing!
      # if their package level has changed ..
      if changing_plans?
        # and a customer exists in stripe ..
        if stripe_id.present?
Severity: Minor
Found in app/concerns/stripe_saas/subscription.rb - About 4 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 processing! has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def processing!
      # if their package level has changed ..
      if changing_plans?
        # and a customer exists in stripe ..
        if stripe_id.present?
Severity: Major
Found in app/concerns/stripe_saas/subscription.rb - About 2 hrs to fix

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

      def self.find_customer(subscription_or_owner)
        if subscription_or_owner.class.to_s.downcase.to_sym == StripeSaas.subscriptions_owned_by
          owner = subscription_or_owner
        else
          owner = subscription_or_owner.send StripeSaas.subscriptions_owned_by
    Severity: Minor
    Found in app/concerns/stripe_saas/subscription.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

    There are no issues that match your filters.

    Category
    Status