Showing 65 of 65 total issues
Method clear_models
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
def clear_models
Dir[Rails.root.join("app","models","*.rb")].each do |file_name|
matched = false
gsub_file file_name, /^\s*include\s+#{INCLUDE_MODULE}.*/ do |match|
matched = 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 use_default_format
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
def use_default_format(value,*optional_values)
if value
if value.is_a?(String)
@format ? (@format % value) : value
elsif value.is_a?(Numeric)
- 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
Class List
has 26 methods (exceeds 20 allowed). Consider refactoring. Open
class List < Lolita::Configuration::Base
include Observable
include Lolita::Builder
attr_reader :initialized_attributes,:page_criteria
Method lolita_for
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def lolita_for *resources
options = resources.extract_options!
options[:as] ||= @scope[:as] if @scope[:as].present?
options[:module] ||= @scope[:module] if @scope[:module].present?
- 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
Class Branch
has 24 methods (exceeds 20 allowed). Consider refactoring. Open
class Branch
attr_accessor :name,:object
attr_reader :level,:options,:tree,:parent
attr_writer :title
Method will_use_component
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def will_use_component component_name
helpers_for_component(component_name) do |possible_component_name|
@used_component_helpers||={}
unless @used_component_helpers.include?(possible_component_name)
if path=component_helper_path(possible_component_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 fix_rails_date_attributes
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def fix_rails_date_attributes attributes
#{"created_at(1i)"=>"2011", "created_at(2i)"=>"4", "created_at(3i)"=>"19", "created_at(4i)"=>"16", "created_at(5i)"=>"14"}
date_attributes = {}
attributes.each_pair do |k,v|
if k.to_s =~ /(.+)\((\d)i\)$/
- 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 create
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def create(dbi,*args,&block)
options = args ? args.extract_options! : {}
dbi_field = options[:dbi_field]
name = args[0] || options[:name] || (dbi_field ? dbi_field.name : 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 nested_options_for
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def nested_options_for(record)
if self.parent
association = self.association
attr_name = [:one,:many_to_many].include?(association.macro) ? :id : association.foreign_key
association_record = if association.through? && record.send(association.through)
- 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 clear_models
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
def clear_models
Dir[Rails.root.join("app","models","*.rb")].each do |file_name|
matched = false
gsub_file file_name, /^\s*include\s+#{INCLUDE_MODULE}.*/ do |match|
matched = true
Method extract_args
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def extract_args(*args)
if args && args.any?
options = args.extract_options! || {}
if args[0] && args[0].is_a?(self)
args[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 sort_params
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def sort_params(params)
if @sortable
pairs = sort_pairs(params)
found_pair = false
pairs.each_with_index do|pair, index|
- 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 search
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def search(query, options = {})
#TODO raise error or warn when there are lot of records and no index on field
unless query.blank?
resources = self.klass.arel_table
content_fields = @dbi.fields.map{|field| field.type!="string" ? nil : field.name.to_sym}.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
Function apply_param_to_url
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
function apply_param_to_url(name,new_value,url){
var value = (url.match(RegExp(name+"=([^&]*)(&|$)")) || [])
if(new_value){
if(value[0]){
replace_value = !new_value ? "" : (name + "=" + new_value + value[2])
- 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 set_state_for
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def set_state_for(record)
unless record.respond_to?(:read_state!)
class << record
def set_state(new_state)
Method map_reduce_search
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def map_reduce_search(content_fields,query)
keys = "[" + @dbi.fields.map{|f|
f.primary? || f.name.to_s.match(/^_/) ? nil : "'#{f.name}'"
}.compact.join(",").to_s + "]"
content_keys = "[" + content_fields.map{|f| "'#{f.name}'"}.join(",").to_s + "]"
Method lolita_for
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def lolita_for *resources
options = resources.extract_options!
options[:as] ||= @scope[:as] if @scope[:as].present?
options[:module] ||= @scope[:module] if @scope[:module].present?
Method add_to_navigation_tree
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def add_to_navigation_tree
tree = Lolita.navigation
if self.visible
if self.append_to
parent_branch = tree.branches.detect{|b| b.options[:system_name] == self.append_to}
- 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 active?
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def active?(view)
resource = view.respond_to?(:resource_class) ? view.send(:resource_class) : nil rescue nil
request = view.send(:request)
self_active = if self.object.is_a?(Lolita::Mapping) && self.object && self.object.to == resource
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 search
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def search(query, options = {})
unless query.blank?
content_fields = @dbi.fields.map{|field|
if field.type!="string" || field.name.match(/^_/)
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"