Method build_control
has a Cognitive Complexity of 92 (exceeds 5 allowed). Consider refactoring. Open
def build_control
@model_handler = ::LibUI::FFI::TableModelHandler.malloc
@model_handler.NumColumns = fiddle_closure_block_caller(4) { @columns.map {|c| c.is_a?(DualColumn) ? 2 : (c.is_a?(TripleColumn) ? 3 : 1)}.sum }
@model_handler.ColumnType = fiddle_closure_block_caller(4, [1, 1, 4]) do |_, _, column|
# TODO consider refactoring to use Glimmer::LibUI.enum_symbols(:table_value_type)
- 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
File table_proxy.rb
has 612 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'glimmer/libui/control_proxy'
require 'glimmer/libui/control_proxy/dual_column'
require 'glimmer/libui/control_proxy/triple_column'
require 'glimmer/data_binding/observer'
require 'glimmer/fiddle_consumer'
Class TableProxy
has 47 methods (exceeds 20 allowed). Consider refactoring. Open
class TableProxy < ControlProxy
include Glimmer::FiddleConsumer
CUSTOM_LISTENER_NAMES = ['on_changed', 'on_edited']
DEFAULT_COLUMN_SORT_BLOCK = lambda do |table_cell_row, column, table_proxy|
Method register_cell_rows_observer
has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring. Open
def register_cell_rows_observer
# TODO update all the each_with_index calls below to work differently when value is an Enumerator
# Perhaps, call ::LibUI.table_model_row_inserted(model, row) not from here, yet from the place where
# we call `next` on the Enumerator to grab more elements
# There will need to be extra intelligence for figuring out when to delete instead of
- 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 build_control
has 127 lines of code (exceeds 25 allowed). Consider refactoring. Open
def build_control
@model_handler = ::LibUI::FFI::TableModelHandler.malloc
@model_handler.NumColumns = fiddle_closure_block_caller(4) { @columns.map {|c| c.is_a?(DualColumn) ? 2 : (c.is_a?(TripleColumn) ? 3 : 1)}.sum }
@model_handler.ColumnType = fiddle_closure_block_caller(4, [1, 1, 4]) do |_, _, column|
# TODO consider refactoring to use Glimmer::LibUI.enum_symbols(:table_value_type)
Method data_bind_read
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def data_bind_read(property, model_binding)
if model_binding.binding_options[:column_attributes].is_a?(Array)
@column_attributes = model_binding.binding_options[:column_attributes]
else
column_attribute_mapping = model_binding.binding_options[:column_attributes].is_a?(Hash) ? model_binding.binding_options[:column_attributes] : {}
- 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 last_cell_row_for
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def last_cell_row_for(row)
# TODO refactor to share code with cell_row_for
@cached_last_cell_rows ||= []
if @cached_last_cell_rows[row].nil?
last_cell_rows = @last_cell_rows || []
- 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 last_last_cell_row_for
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def last_last_cell_row_for(row)
# TODO refactor to share code with cell_row_for
@cached_last_last_cell_rows ||= []
if @cached_last_last_cell_rows[row].nil?
last_last_cell_rows = @last_last_cell_rows || []
- 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 cell_row_for
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def cell_row_for(row)
@cached_cell_rows ||= []
if @cached_cell_rows[row].nil?
cell_rows = self.cell_rows || []
if cell_rows.is_a?(Enumerator)
- 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 handle_listener
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def handle_listener(listener_name, &listener)
# if content has been added, then you can register listeners immediately (without accumulation)
if CUSTOM_LISTENER_NAMES.include?(listener_name) || @content_added
actual_listener = listener
case listener_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 register_cell_rows_observer
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
def register_cell_rows_observer
# TODO update all the each_with_index calls below to work differently when value is an Enumerator
# Perhaps, call ::LibUI.table_model_row_inserted(model, row) not from here, yet from the place where
# we call `next` on the Enumerator to grab more elements
# There will need to be extra intelligence for figuring out when to delete instead of
Consider simplifying this complex logical expression. Open
if !new_value.is_a?(Enumerator) &&
(
model_binding.binding_options[:column_attributes] ||
(!new_value.nil? && (!new_value.is_a?(String) || !new_value.empty?) && (!new_value.is_a?(Array) || !new_value.first.is_a?(Array)))
)
Avoid deeply nested control flow statements. Open
if new_row_data != last_cell_row_for(row) && model
::LibUI.table_model_row_changed(model, row)
notify_custom_listeners('on_changed', row, :changed, new_row_data)
end
Method cell_rows
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def cell_rows(rows = nil)
if rows.nil?
@cell_rows
else
if !rows.equal?(@cell_rows)
- 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 configure_sorting
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def configure_sorting
if sortable?
columns.each do |column_object|
next unless column_object.is_a?(Column) && !column_object.is_a?(Column::ButtonColumnProxy)
column_object.on_clicked do |column_proxy, column|
- 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 register_column_listeners
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def register_column_listeners
# register accumulated column listeners after table content is closed
return if @columns.nil? || @columns.empty?
if @columns.any? {|column| column.is_a?(Column)}
::LibUI.table_header_on_clicked(@libui) do |_, column_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
Similar blocks of code found in 2 locations. Consider refactoring. Open
def last_last_cell_row_for(row)
# TODO refactor to share code with cell_row_for
@cached_last_last_cell_rows ||= []
if @cached_last_last_cell_rows[row].nil?
last_last_cell_rows = @last_last_cell_rows || []
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 55.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
def last_cell_row_for(row)
# TODO refactor to share code with cell_row_for
@cached_last_cell_rows ||= []
if @cached_last_cell_rows[row].nil?
last_cell_rows = @last_cell_rows || []
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 55.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
if table_cell_row.is_a?(Array)
table_cell_row[column] ||= []
table_cell_row[column][1] = ::LibUI.table_value_string(val).to_s
else
attribute = column_attributes[column]
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 44.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
if table_cell_row.is_a?(Array)
table_cell_row[column] ||= []
table_cell_row[column][0] = ::LibUI.table_value_string(val).to_s
else
attribute = column_attributes[column]
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 44.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76