Showing 146 of 184 total issues
Method update_attendance
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def self.update_attendance(data={})
raise Osm::ArgumentIsInvalid, ':attendance is invalid' unless [:yes, :unadvised_absent, :advised_absent].include?(data[:attendance])
raise Osm::ArgumentIsInvalid, ':section is missing' if data[:section].nil?
raise Osm::ArgumentIsInvalid, ':evening is missing' if data[:evening].nil?
raise Osm::ArgumentIsInvalid, ':members is missing' if data[:members].nil?
- 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 update
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update(api)
raise Osm::ObjectIsInvalid, 'data is invalid' unless valid?
section = Osm::Section.get(api, section_id)
require_ability_to(api, :write, :badge, section)
Method get
has 34 lines of code (exceeds 25 allowed). Consider refactoring. 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_due_badges
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.get_due_badges(api, section, term=nil, options={})
Osm::Model.require_ability_to(api, :read, :badge, section, options)
section = Osm::Section.get(api, section, options) unless section.is_a?(Osm::Section)
term_id = (term.nil? ? Osm::Term.get_current_term_for_section(api, section, options) : term).to_i
cache_key = ['due_badges', section.id, term_id]
Method get_all
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.get_all(api, section, options={})
section_id = section.to_i
cache_key = ['api_access', api.user_id, section_id]
if !options[:no_cache] && cache_exist?(api, cache_key)
Method get_payments_for_members
has 32 lines of code (exceeds 25 allowed). Consider refactoring. 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
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
Method update
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def update(api)
require_ability_to(api, :write, :events, event.section_id)
data = api.perform_query("events.php?action=renameColumn§ionid=#{event.section_id}&eventid=#{event.id}", {
'columnId' => id,
- 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_attendance
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def get_attendance(api, term=nil, options={})
require_ability_to(api, :read, :events, section_id, options)
term_id = term.nil? ? Osm::Term.get_current_term_for_section(api, section_id).id : term.to_i
cache_key = ['event_attendance', id, term_id]
- 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 update
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def update(api)
require_ability_to(api, :write, :finance, invoice.section_id)
raise Osm::ObjectIsInvalid, 'invoice item is invalid' unless valid?
updated = true
- 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_for_section
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.get_for_section(api, section, options={})
require_ability_to(api, :read, :events, section, options)
section_id = section.to_i
cache_key = ['events', section_id]
events = nil
Method update
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update(api)
raise Osm::ObjectIsInvalid, 'data is invalid' unless valid?
require_ability_to(api, :write, :flexi, flexi_record.section_id)
term_id = Osm::Term.get_current_term_for_section(api, flexi_record.section_id).id
Method get_data
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def get_data(api, term=nil, options={})
require_ability_to(api, :read, :flexi, section_id, options)
section = Osm::Section.get(api, self.section_id)
term_id = term.nil? ? Osm::Term.get_current_term_for_section(api, section).id : term.to_i
cache_key = ['flexi_record_data', id, term_id]
Method get_for_section
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.get_for_section(api, section, options={})
require_access_to_section(api, section, options)
section_id = section.to_i
cache_key = ['sms_delivery_reports', section_id]
Method get_list
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.get_list(api, section, options={})
require_ability_to(api, :read, :events, section, options)
section_id = section.to_i
cache_key = ['events_list', section_id]
events_cache_key = ['events', section_id]
Method get_module_completion_data
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.get_module_completion_data(api, options={})
cache_key = ['badge_module_completion_data']
if !options[:no_cache] && cache_exist?(api, cache_key)
return cache_read(api, cache_key)
end
Method earnt?
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def earnt?
if badge.has_levels?
return earnt > awarded
else
return false if (due.eql?(1) && awarded.eql?(1))
Method update
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update(api)
require_ability_to(api, :write, :finance, invoice.section_id)
raise Osm::ObjectIsInvalid, 'invoice item is invalid' unless valid?
updated = true
Method new_event_from_data
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.new_event_from_data(event_data)
event = Osm::Event.new(attributes_from_data(event_data))
event.notepad = event_data['notepad']
columns = []
Method configure
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def self.configure(options)
raise ArgumentError, ":ttl must be a FixNum greater than 0" if options[:ttl] && !(options[:ttl].is_a?(Fixnum) && options[:ttl] > 0)
raise ArgumentError, ":prepend_to_key must be a String" if options[:prepend_to_key] && !options[:prepend_to_key].is_a?(String)
if options[:cache]
[:exist?, :delete, :write, :read].each do |method|
- 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"