Showing 23 of 23 total issues
File model.rb
has 546 lines of code (exceeds 250 allowed). Consider refactoring. Open
module MotionModel
class PersistFileError < Exception; end
class RelationIsNilError < Exception; end
class AdapterNotFoundError < Exception; end
class RecordNotSaved < Exception; end
Method reset
has 80 lines of code (exceeds 25 allowed). Consider refactoring. Open
def reset
# Put singular-form to plural form transformations here
@plurals = [
[/^person$/, 'people'],
[/^man$/, 'men'],
File ext.rb
has 298 lines of code (exceeds 250 allowed). Consider refactoring. Open
class String
unless String.instance_methods.include?(:humanize)
def humanize
self.split(/_|-| /).join(' ')
end
Class ArrayFinderQuery
has 24 methods (exceeds 20 allowed). Consider refactoring. Open
class ArrayFinderQuery
attr_accessor :field_name
def initialize(*args)#nodoc
@field_name = args[0] if args.length > 1
Method deserialize_from_file
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def deserialize_from_file(file_name = nil, directory = nil)
if schema_version != '1.0.0'
migrate
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 initialize
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def initialize(options = {})
raise AdapterNotFoundError.new("You must specify a persistence adapter.") unless self.respond_to? :adapter
@data ||= {}
before_initialize(options) if respond_to?(:before_initialize)
- 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_formotion
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def to_formotion(form_title = nil, expose_auto_date_fields = false, first_section_title = nil)
return new_to_formotion(form_title) if form_title.is_a? Hash
@expose_auto_date_fields = expose_auto_date_fields
- 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 destroy
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def destroy(options = {})
call_hooks 'destroy' do
options = options.dup
options[:omit_model_identifiers] ||= {}
options[:omit_model_identifiers][model_identifier] = self
- 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_formotion
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def to_formotion(form_title = nil, expose_auto_date_fields = false, first_section_title = nil)
return new_to_formotion(form_title) if form_title.is_a? Hash
@expose_auto_date_fields = expose_auto_date_fields
Method deserialize_from_file
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def deserialize_from_file(file_name = nil, directory = nil)
if schema_version != '1.0.0'
migrate
end
Method set_belongs_to_attr
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def set_belongs_to_attr(col, owner, options = {})
_col = column(col)
unless belongs_to_synced?(_col, owner)
_set_attr(_col.name, owner)
rebuild_relation(_col, owner, set_inverse: options[:set_inverse])
- 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 validate_for
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def validate_for(field, value)
@messages = []
key = field.to_sym
result = true
each_validation_for(key) do |validation|
- 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 classify
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def classify
fail "Column#classify indeterminate for polymorphic associations" if type == :belongs_to && polymorphic
if @klass
@klass
else
- 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 from_formotion!
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def from_formotion!(data)
self.returnable_columns.each{|column|
if data[column] && column_type(column) == :date || column_type(column) == :time
data[column] = Time.at(data[column]) unless data[column].nil?
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 validate_presence
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def validate_presence(field, value, setting)
if(value.is_a?(Numeric))
return true
elsif value.is_a?(String) || value.nil?
result = value.nil? || ((value.length == 0) == setting)
- 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 inflect
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def inflect(word, direction) #nodoc
return word if uncountable?(word)
subject = word.dup
- 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 fill_section
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def fill_section(section)
new_section = {}
section.each_pair do |key, value|
case key
- 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 camelize
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def camelize(uppercase_first_letter = true)
string = self.dup
string.gsub!(/(?:_|(\/))([a-z\d]*)/i) do
new_word = $2.downcase
new_word[0] = new_word[0].upcase
- 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 find
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def find(*args, &block)
if block_given?
matches = collection.collect do |item|
item if yield(item)
end.compact
- 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 encodeWithCoder
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def encodeWithCoder(coder)
columns.each do |attr|
# Serialize attributes except the proxy has_many and belongs_to ones.
unless [:belongs_to, :has_many, :has_one].include? column(attr).type
value = self.send(attr)
- 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"