lib/osm/model.rb
Class Model
has 25 methods (exceeds 20 allowed). Consider refactoring. Open
Open
class Model
include ActiveModel::MassAssignmentSecurity if ActiveModel::VERSION::MAJOR < 4
include ActiveAttr::Model
SORT_BY = [:id]
Method configure
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
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"
Further reading
Method get_from_ids
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def self.get_from_ids(api, ids, key, arguments=[], options, get_all_method)
Method require_permission
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def self.require_permission(api, to, on, section, options={})
Method has_permission?
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def self.has_permission?(api, to, on, section, options={})
Method user_has_permission?
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def self.user_has_permission?(api, to, on, section, options={})
Method require_ability_to
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def self.require_ability_to(api, to, on, section, options={})
Method api_has_permission?
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def self.api_has_permission?(api, to, on, section, options={})
Method require_permission
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
def self.require_permission(api, to, on, section, options={})
section = Osm::Section.get(api, section.to_i, options) unless section.is_a?(Osm::Section)
section_name = section.try(:name)
unless user_has_permission?(api, to, on, section, options)
raise Osm::Forbidden, "Your OSM user does not have permission to #{to} on #{on} for #{section_name}."
- 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"