Showing 401 of 401 total issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
def evaluate_sw_ne_diagonal_win
sw_ne_coordinates = [
[[3, 0], [2, 1], [1, 2], [0, 3]],
[[4, 0], [3, 1], [2, 2], [1, 3], [0, 4]],
[[5, 0], [4, 1], [3, 2], [2, 3], [1, 4], [0, 5]],
- 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 102.
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 evaluate_se_nw_diagonal_win
sw_ne_coordinates = [
[[0, 3], [1, 4], [2, 5], [3, 6]],
[[0, 2], [1, 3], [2, 4], [3, 5], [4, 6]],
[[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6]],
- 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 102.
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
Method print
has a Cognitive Complexity of 20 (exceeds 5 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)
- 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 same_table_data?
has a Cognitive Complexity of 20 (exceeds 5 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|
- 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 Path
has 24 methods (exceeds 20 allowed). Consider refactoring. Open
class Path < Shape
include PathSegment # a path may behave as a path segment in another path
attr_reader :swt_path, :path_segments
attr_accessor :calculated_path_args
Method custom_shell_gem
has 65 lines of code (exceeds 25 allowed). Consider refactoring. Open
def custom_shell_gem(custom_shell_name, namespace)
gem_name = "glimmer-cs-#{compact_name(custom_shell_name)}"
gem_summary = "#{human_name(custom_shell_name)} - Glimmer Custom Shell"
begin
custom_shell_keyword = dsl_widget_name(custom_shell_name)
Method apply_shape_arg_conversions!
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def apply_shape_arg_conversions!
if @args.size > 1 && (['polygon', 'polyline'].include?(@name))
@args[0] = @args.dup
@args[1..-1] = []
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 start
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def start
return if @start_number > 0 && started?
@start_number += 1
@start_time = Time.now
@duration = 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
File tetromino.rb
has 271 lines of code (exceeds 250 allowed). Consider refactoring. Open
require_relative 'block'
require 'matrix'
class Tetris
Method initialize
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def initialize(parent, *args, swt_transform: nil, multiply: false)
Glimmer::SWT::DisplayProxy.instance.auto_exec do
@parent = parent
@multiply = multiply
if swt_transform.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 handle_observation_request
has 60 lines of code (exceeds 25 allowed). Consider refactoring. Open
def handle_observation_request(observation_request, source_observation_request: nil, &block)
if observation_request.to_s == 'on_shape_disposed'
@on_shape_disposed_handlers ||= []
@on_shape_disposed_handlers << block
return ShapeListenerProxy.new(shape: self, drawable: drawable, shape_listener_block: block, observation_request: 'on_shape_disposed')
File hello_table.rb
has 266 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'glimmer-dsl-swt'
class HelloTable
class BaseballGame
class << self
Method call
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
def call(*args)
options = args.last.is_a?(Hash) ? args.pop : {}
internal_sort = options[:internal_sort] || false
new_model_collection = args.first
Glimmer::SWT::DisplayProxy.instance.auto_exec(override_sync_exec: @model_binding.binding_options[:sync_exec], override_async_exec: @model_binding.binding_options[:async_exec]) do
Class Polygon
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
class Polygon < Shape
def parameter_names
[:point_array]
end
Method for
has a Cognitive Complexity of 17 (exceeds 5 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.
- 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 for
has a Cognitive Complexity of 17 (exceeds 5 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.
- 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 custom_shell_gem
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def custom_shell_gem(custom_shell_name, namespace)
gem_name = "glimmer-cs-#{compact_name(custom_shell_name)}"
gem_summary = "#{human_name(custom_shell_name)} - Glimmer Custom Shell"
begin
custom_shell_keyword = dsl_widget_name(custom_shell_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 initialize
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def initialize(parent, args)
index = args.delete(args.last) if args.last.is_a?(Numeric)
styles = args.map(&:to_sym)
if !styles.include?(:bar) && !parent.swt_widget.is_a?(Menu)
styles = styles.unshift(:pop_up)
- 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 delegate_observation_request_to_checkboxes
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def delegate_observation_request_to_checkboxes(observation_request, &block)
if observation_request != 'on_widget_disposed'
checkboxes.count.times do |index|
checkbox = checkboxes[index]
label = labels[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 configure_sorting
has a Cognitive Complexity of 17 (exceeds 5 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
- 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"