payolapayments/payola

View on GitHub
app/models/payola/subscription.rb

Summary

Maintainability
A
2 hrs
Test Coverage

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

There are no issues that match your filters.

Category
Status