Showing 401 of 401 total issues
Method orientation=
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def orientation=(value)
if top_left_cell
if value == :horizontal
if top_left_cell.column_index + length > Grid::WIDTH
raise "Top left cell #{top_left_cell} cannot fit ship #{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 post_add_content
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def post_add_content
shown = false
unless @initialize_tabs_on_select
@show_listener = parent_proxy.on_swt_show do
unless shown
- 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 11 (exceeds 5 allowed). Consider refactoring. Open
def initialize(parent, *swt_style_symbols, options, &content)
SWT::DisplayProxy.current_custom_widgets_and_shapes << self
@parent_proxy = @parent = parent
@parent_proxy = @parent&.get_data('proxy') if @parent.respond_to?(:get_data) && @parent.get_data('proxy')
@swt_style_symbols = swt_style_symbols
- 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 can_interpret?
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def can_interpret?(parent, keyword, *args, &block)
Glimmer::Config.logger.debug {"keyword starts with on_: #{keyword.start_with?('on_')}"}
return false unless keyword.start_with?('on_')
proper_parent = parent.respond_to?(:swt_widget) || parent.is_a?(Glimmer::SWT::DisplayProxy) || parent.is_a?(Glimmer::SWT::Custom::Shape) || parent.is_a?(Glimmer::UI::CustomShape)
Glimmer::Config.logger.debug {"parent #{parent} is a widget, shape, or display: #{proper_parent}"}
- 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 method_name
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def method_name(keyword, method_arg_options)
keyword = keyword.to_s
method_arg_options = method_arg_options.select {|key, value| %w[fill gradient round].include?(key.to_s)}
unless flyweight_method_names.keys.include?([keyword, method_arg_options])
gradient = 'Gradient' if method_arg_options[:gradient]
- 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 regenerate
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def regenerate
@thread = Thread.new do
@button.enabled = false
@path1.clear
@path2.clear
Method print
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def print(gc=nil, job_name: nil)
if gc.is_a?(org.eclipse.swt.graphics.GC)
@swt_widget.print(gc)
else
image = Image.new(DisplayProxy.instance.swt_display, bounds)
Method initialize
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(*init_args, swt_widget: nil)
auto_exec do
@image_double_buffered = !!(init_args&.last&.include?(:image_double_buffered) && init_args&.last&.delete(:image_double_buffered))
if swt_widget.nil?
underscored_widget_name, parent, args = init_args
Method setup_shape_painting
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def setup_shape_painting
# TODO consider performance optimization relating to order of shape rendering (affecting only further shapes not previous ones)
if @paint_listener_proxy.nil?
shape_painter = lambda do |paint_event|
shape_painting_work = lambda do |paint_event|
Method position_options
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def position_options
[
'CEO',
'CFO',
'CIO',
Method countdown_group_field_composite
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def countdown_group_field_composite
composite {
row_layout {
margin_width 0
margin_height 0
Method configure_sorting
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def configure_sorting
@table_proxy.sort_strategy = lambda do
new_sort = @table_proxy.sort_block || @table_proxy.sort_by_block || @table_proxy.sort_property
new_sort_direction = @table_proxy.sort_direction
return if new_sort == @last_sort && new_sort_direction == @last_sort_direction
Method same_table_data?
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def same_table_data?(new_model_collection)
(["text"] + TABLE_ITEM_PROPERTIES).all? do |table_item_property|
table_cells = @table.swt_widget.items.map do |item|
model = item.get_data
@table.column_properties.each_with_index.map do |column_property, i|
Method for
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def for(underscored_custom_shape_name)
unless flyweight_custom_shape_classes.keys.include?(underscored_custom_shape_name)
begin
extracted_namespaces = underscored_custom_shape_name.
to_s.
Method for
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def for(underscored_custom_widget_name)
unless flyweight_custom_widget_classes.keys.include?(underscored_custom_widget_name)
begin
extracted_namespaces = underscored_custom_widget_name.
to_s.
Method paint_self
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def paint_self(paint_event)
@painting = true
unless container?
calculate_paint_args!
@original_gc_properties = {} # this stores GC properties before making calls to updates TODO avoid using in pixel graphics
Method paint_pixel_by_pixel
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def paint_pixel_by_pixel(width = nil, height = nil, &each_pixel_color)
if @image_double_buffered
work = lambda do |paint_event|
width ||= swt_drawable.bounds.width
height ||= swt_drawable.bounds.height
Similar blocks of code found in 3 locations. Consider refactoring. Open
:selection => lambda do |observer|
on_widget_selected { |event|
observer.call(@swt_widget.getSelection) unless @swt_widget.getCaretOffset == 0 && @last_modify_text != text
}
on_swt_keyup { |event|
- 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 52.
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 3 locations. Consider refactoring. Open
:selection_range => lambda do |observer|
on_widget_selected { |event|
observer.call(@swt_widget.getSelectionRange) unless @swt_widget.getCaretOffset == 0 && @last_modify_text != text
}
on_swt_keyup { |event|
- 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 52.
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 3 locations. Consider refactoring. Open
:selection_count => lambda do |observer|
on_widget_selected { |event|
observer.call(@swt_widget.getSelectionCount) unless @swt_widget.getCaretOffset == 0 && @last_modify_text != text
}
on_swt_keyup { |event|
- 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 52.
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