Showing 3 of 3 total issues
Method parent
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def parent
if parent_data.is_a?(Hash) && (parent_data[:model_class]).present?
@parent ||= parent_data[:model_class].send("find_by_#{ parent_data[:find_by] }", params["#{ resource.model_name }_id"])
raise ActiveRecord::RecordNotFound unless @parent
instance_variable_set("@#{ resource.model_name }", @parent)
- 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 invalidate_old_payments
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def invalidate_old_payments
return if store_credit? || by_loyalty_points?
order.payments.with_state('checkout').where("id != ?", self.id).each do |payment|
payment.invalidate! unless payment.store_credit?
end
- 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 validate_transactions_total_range
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def validate_transactions_total_range(trans_type, relation)
net_transactions_total = net_transactions_sum(trans_type, relation)
first_transaction = relation.loyalty_points_transactions.first
if first_transaction.transaction_type == "Debit"
errors.add :base, "Loyalty Points Net Debit Total should be in the range [0, #{ first_transaction.loyalty_points }]" if net_transactions_total > 0 || net_transactions_total < -first_transaction.loyalty_points
- 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"