Showing 48 of 54 total issues
Method columns_to_array
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def columns_to_array(nature, options = {})
columns = table.exportable_columns
array = []
record = options[:record] || 'record_of_the_death'
- 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 header_code
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def header_code
code = ''
code << "'<thead><tr>"
if table.selectable?
code << '<th class="list-selector"><input type="checkbox" data-list-selector="all" /></th>'
Method exporting_datum_code
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def exporting_datum_code(record = 'record_of_the_death', noview = false)
datum = datum_code(record)
if datatype == :boolean
datum = "(#{datum} ? ::I18n.translate('list.export.true_value') : ::I18n.translate('list.export.false_value'))"
elsif datatype == :date
- 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 controller_method_code
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def controller_method_code
code = "# encoding: utf-8\n"
code << "def #{controller_method_name}\n"
code << session_initialization_code.dig
code << " respond_to do |format|\n"
Method menu_code
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def menu_code
menu = "<span class=\"list-settings\" data-list-ref=\"#{uid}\">"
menu << "<a class=\"settings-start\"><i></i>' + h('list.menu'.t) + '</a>"
menu << '<ul>'
if table.paginate?
Method conditions_code
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def conditions_code
conditions = @table.options[:conditions]
code = ''
case conditions
when Array
Method session_initialization_code
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def session_initialization_code
code = "options = {} unless options.is_a? Hash\n"
# For Rails 5
code << "options.update(params.to_unsafe_h)\n"
if defined?(User) && User.instance_methods.include?(:preference)
Method add
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def add(type, name, options = {})
klass = begin
"ActiveList::Definition::#{type.to_s.camelcase}Column".constantize
rescue
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 session_initialization_code
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def session_initialization_code
code = "options = {} unless options.is_a? Hash\n"
# For Rails 5
code << "options.update(params.to_unsafe_h)\n"
if defined?(User) && User.instance_methods.include?(:preference)
- 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
Avoid deeply nested control flow statements. Open
currency = :currency if currency.is_a?(TrueClass)
Avoid deeply nested control flow statements. Open
currency = currency[nature] if currency.is_a?(Hash)
Avoid deeply nested control flow statements. Open
column.options[:url] = {} unless column.options[:url].is_a?(Hash)
Avoid deeply nested control flow statements. Open
value_code = (nature == :body ? "text_field_tag(#{form_name.inspect}, #{recordify!(column.options[:value] || column.name, record)}#{column.options[:size] ? ', size: ' + column.options[:size].to_s : ''})" : 'nil') # , id: '#{table.name}_'+#{record}.id.to_s + '_#{column.name}'
Avoid deeply nested control flow statements. Open
elsif column.options[:mode] || column.label_method == :email
value_code = "(#{value_code}.blank? ? '' : mail_to(#{value_code}))"
elsif column.options[:mode] || column.label_method == :website
value_code = "(#{value_code}.blank? ? '' : link_to(" + value_code + ', ' + value_code + '))'
elsif column.label_method == :color
Avoid deeply nested control flow statements. Open
currency = "#{column.record_expr(record)}.#{currency}".c if currency.is_a?(Symbol)
Avoid deeply nested control flow statements. Open
if column.form_value
value = recordify(column.form_value, record)
else
value = 1
value_code << "hidden_field_tag(#{form_name.inspect}, 0, id: nil) + \n"
Avoid deeply nested control flow statements. Open
elsif column.datatype == :decimal
value_code = "(#{value_code}.nil? ? '' : #{value_code}.l)"
elsif column.enumerize?
value_code = "(#{value_code}.nil? ? '' : #{value_code}.text)"
Avoid deeply nested control flow statements. Open
elsif column.is_a?(ActiveList::Definition::ActionColumn)
next unless column.use_single?
value_code = (nature == :body ? column.operation(record) : 'nil')
else
value_code = "' ∅ '.html_safe"
Method send_data_code
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def send_data_code
xml_escape = "to_s.gsub('&', '&').gsub('\\'', ''').gsub('<', '<').gsub('>', '>')"
xml_escape << ".force_encoding('US-ASCII')" if xml_escape.respond_to?(:force_encoding)
record = 'r'
code = generator.select_data_code(paginate: false)
- 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 reflections
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def reflections
hash = []
columns.each do |column|
next unless column.respond_to?(:reflection)
unless hash.detect { |r| r.name == column.reflection.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"