Showing 146 of 184 total issues
Method update
has a Cognitive Complexity of 15 (exceeds 5 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)
- 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_summary_for_section
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.get_summary_for_section(api, section, term=nil, options={})
raise Error, 'This method must NOT be called on one of the subclasses(CoreBadge, ChallengeBadge, StagedBadge or ActivityBadge)' unless type.nil?
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
Method update
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update(api, member, force=false)
raise Osm::ObjectIsInvalid, 'member is invalid' unless valid?
require_ability_to(api, :write, :member, member.section_id)
attribute_map = {
Method get_payments_for_members
has a Cognitive Complexity of 14 (exceeds 5 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)
- 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_module_completion_data
has a Cognitive Complexity of 14 (exceeds 5 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
- 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_due_badges
has a Cognitive Complexity of 14 (exceeds 5 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]
- 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 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.get_for_section(api, section, options={})
Osm::Model.require_access_to_section(api, section, options)
section_id = section.to_i
cache_key = ['email_delivery_reports', section_id]
Method perform_query
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.perform_query(site, url, api_data={}, raw=false)
raise ArgumentError, 'site is invalid, this should be set to either :osm or :ogm' unless Osm::Api::BASE_URLS.keys.include?(site)
data = api_data.merge({
'apiid' => @@api_details[site][:id],
Method update
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update(api, section, secret_update=false)
raise Osm::ObjectIsInvalid, 'activity is invalid' unless valid?
raise Osm::Forbidden, "You are not allowed to update this activity" unless self.editable
data = api.perform_query("programme.php?action=update", {
Method get_structure
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def self.get_structure(api, section, term=nil, options={})
Osm::Model.require_ability_to(api, :read, :register, section, options)
section_id = section.to_i
term_id = term.nil? ? Osm::Term.get_current_term_for_section(api, section).id : term.to_i
cache_key = ['register_structure', section_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 get_donations
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def self.get_donations(api, section, term=nil, options={})
Osm::Model.require_ability_to(api, :read, :finance, section, options)
section_id = section.to_i
term_id = term.nil? ? Osm::Term.get_current_term_for_section(api, section).id : term.to_i
cache_key = ['gift_aid_donations', section_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 earnt
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def earnt
unless badge.has_levels?
return earnt? ? 1 : 0
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 get_attendance
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.get_attendance(api, section, term=nil, options={})
Osm::Model.require_ability_to(api, :read, :register, section, options)
section_id = section.to_i
term_id = term.nil? ? Osm::Term.get_current_term_for_section(api, section).id : term.to_i
cache_key = ['register_attendance', section_id, term_id]
Method get_attendance
has 39 lines of code (exceeds 25 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]
Method get_audit_trail
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def get_audit_trail(api, options={})
require_ability_to(api, :read, :events, event.section_id, options)
cache_key = ['event\_attendance\_audit', event.id, member_id]
if !options[:no_cache] && cache_exist?(api, cache_key)
Method get_data
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.get_data(api, section, term=nil, options={})
Osm::Model.require_ability_to(api, :read, :finance, section, options)
section_id = section.to_i
term_id = term.nil? ? Osm::Term.get_current_term_for_section(api, section).id : term.to_i
cache_key = ['gift_aid_data', section_id, term_id]
Method get_badge_requirements
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def get_badge_requirements(api, options={})
section = Osm::Section.get(api, section_id)
cache_key = ['badge_requirements', section.id, id]
if !options[:no_cache] && cache_exist?(api, cache_key)
return cache_read(api, cache_key)
Method create
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.create(api, parameters)
require_ability_to(api, :write, :events, parameters[:section_id])
event = new(parameters)
raise Osm::ObjectIsInvalid, 'event is invalid' unless event.valid?
Method update
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def update(api)
require_ability_to(api, :write, :events, event.section_id)
payment_values = {
:manual => 'Manual',
- 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_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"