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
- Read upRead up
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
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]
- Read upRead up
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
- Read upRead up
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?
- Read upRead up
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
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]
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?
- Read upRead up
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) {
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?
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
- Read upRead up
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)
Method call
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def self.call(subscription, plan, quantity = 1, coupon_code = nil, trial_end = nil)
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
- Read upRead up
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)
- Read upRead up
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),
- Read upRead up
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) {
- Read upRead up
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) {
- Read upRead up
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|
- Read upRead up
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')
- Read upRead up
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"