Showing 16 of 18 total issues
Class Relation
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
class Relation < Criteria
include ActiveModel::Dirty
class << self
def to_parse( object )
Class Criteria
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
class Criteria
include Opium::Model::Queryable::ClassMethods
include Enumerable
class_attribute :models
Method create_field_setter_for
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def create_field_setter_for( field )
class_eval do
define_method("#{ field.name }=") do |value|
converted = field.type.to_ruby(value)
send( "#{ field.name }_will_change!" ) unless self.attributes[field.name] == converted
- 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_header_for
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def get_header_for( method, context, owner = nil )
return {} unless added_headers[method]
eval_only = !added_headers[method][:options][:only].empty?
eval_except = !added_headers[method][:options][:except].empty?
- 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 check_for_error
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def check_for_error( options = {}, &block )
fail ArgumentError, 'no block given' unless block_given?
result = yield
if options[:raw_response] || options[:sent_headers]
result
- 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 each
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def each(&block)
if !block_given?
to_enum(:each)
elsif cached? && @cache
@cache.each(&block)
- 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 schedulize!
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def schedulize!( hash )
fail ArgumentError, 'No scheduled time for #push_at specified!' if expiration_interval && !push_at
if push_at
fail ArgumentError, 'Can only schedule a push up to 2 weeks in advance!' if push_at > ( Time.now + ( 2 * 604800 ) )
fail ArgumentError, 'Cannot schedule pushes in the past... unless you are the Doctor' if push_at < Time.now
- 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
Consider simplifying this complex logical expression. Open
if value && ( ( !eval_only && !eval_except ) || ( eval_only && within_only ) || ( eval_except && !within_except ) )
{ headers: { added_headers[method][:header] => value } }
else
{}
end
Method targetize!
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def targetize!( hash )
if criteria
c = criteria
c = Installation.where( c ) unless c.is_a?( Opium::Model::Criteria )
c = c.and( channels: channels ) unless channels.empty?
- 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 to_ruby
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def to_ruby( object )
return if object.nil? || object == ''
return object if object.is_a?( self )
object = ::JSON.parse( object ) if object.is_a?( String )
if object.is_a?( Hash ) && (has_key_of_value( object, :__type, 'File' ) || has_keys( object, :url, :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"
Further reading
Method initialize
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def initialize(name, type, default, readonly, as)
Method validate_fields_exist
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def validate_fields_exist( field_names )
field_names = field_names.keys if field_names.respond_to? :keys
unless field_names.all? {|field_name| model.fields.key?( field_name ) || field_name =~ /^\$/ }
not_fields = field_names.reject {|field_name| model.fields.key? field_name }
raise ArgumentError, "#{not_fields.join(', ')} #{not_fields.length > 1 ? 'are not fields' : 'is not a field'} on this model"
- 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 apply_headers_to_request
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def apply_headers_to_request( method, options, &further_operations )
lambda do |request|
request.headers.update options[:headers] if options[:headers]
if use_master_key?( request, 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 to_parse
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def to_parse
{ '$regex' => self.source }.tap do |h|
ops = ''
{ IGNORECASE => 'i', MULTILINE => 'm', EXTENDED => 'x' }.each do |option, value|
ops += value unless ( self.options & option ) == 0
- 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 each
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def each(&block)
if !block_given?
to_enum(:each)
else
super() {|model| block.call( model ) unless __deletions__.include?( model ) }
- 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 scope
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def scope( scope_name, criteria = nil, &block )
class_eval do
method_body = if block_given? || criteria.is_a?(Proc)
block || criteria
elsif criteria.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"