lib/osm/online_payment.rb
File online_payment.rb
has 305 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
module Osm
class OnlinePayment
class Schedule < Osm::Model
Method get_payments_for_members
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
Open
def get_payments_for_members(api, term=nil, options={})
require_ability_to(api, :read, :finance, section_id, options)
if term.nil?
section = Osm::Section.get(api, section_id, options)
- 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 get
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def self.get(api, section, schedule, options={})
require_ability_to(api, :read, :finance, section, options)
section_id = section.to_i
schedule_id = schedule.to_i
cache_key = ['online_payments', 'schedule', schedule_id]
Method get_payments_for_members
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def get_payments_for_members(api, term=nil, options={})
require_ability_to(api, :read, :finance, section_id, options)
if term.nil?
section = Osm::Section.get(api, section_id, options)
Method update_payment_status
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
Open
def update_payment_status(api, payment, status, gift_aid=false)
payment_id = payment.to_i
fail ArgumentError, "#{payment_id} is not a valid payment for the schedule." unless schedule.payments.map(&:id).include?(payment_id)
fail ArgumentError, "status must be either :required, :not_required or :paid_manually. You passed in #{status.inspect}" unless [:required, :not_required, :paid_manually].include?(status)
- 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
Avoid too many return
statements within this method. Open
Open
return true