Showing 401 of 401 total issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
radio: {
widget_value_property: :selection,
editor_gui: lambda do |args, model, property, table_proxy|
first_time = true
table_proxy.table_editor.minimumHeight = 25
- 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 2 locations. Consider refactoring. Open
checkbox: {
widget_value_property: :selection,
editor_gui: lambda do |args, model, property, table_proxy|
first_time = true
table_proxy.table_editor.minimumHeight = 25
- 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
Method games
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def games
if @games.nil?
@games = []
baseball_team_combinations = BaseballTeam.all.combination(2).to_a
current_day = first_day
Method launch
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def launch(application, jruby_options: [], env_vars: {}, glimmer_options: {})
jruby_options_string = jruby_options.join(' ') + ' ' if jruby_options.any?
env_vars = env_vars.merge(glimmer_option_env_vars(glimmer_options))
env_vars.each do |k,v|
ENV[k] = v
Method drag_and_move=
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def drag_and_move=(drag_and_move_value)
deregister_drag_listeners if @drag_source
drag_and_move_old_value = @drag_and_move
@drag_and_move = drag_and_move_value
if @drag_and_move && !drag_and_move_old_value
Method can_handle_drag_observation_request?
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def can_handle_drag_observation_request?(observation_request)
auto_exec do
return false unless swt_widget.is_a?(Control)
potential_drag_source = @drag_source_proxy.nil?
ensure_drag_source_proxy
- 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_attribute
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def set_attribute(attribute_name, *args)
swt_widget_operation = false
result = nil
Glimmer::SWT::DisplayProxy.instance.auto_exec do
result = if proxy_source_object&.respond_to?(attribute_setter(attribute_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 interpret
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def interpret(parent, keyword, *args, &block)
options = args.last.is_a?(Hash) ? args.last : {}
coordinate_args = args.size == (options.empty? ? 2 : 3)
args.unshift(parent) unless parent.nil? || options[:top_level]
@create_pixel_by_pixel = coordinate_args && block&.parameters&.count == 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 rotate!
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def rotate!(direction)
return if stopped?
can_rotate = nil
new_blocks = nil
game.hypothetical do
- 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_missing
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def method_missing(method_name, *args, &block)
dsl_mode = @dsl_mode || args.last.is_a?(Hash) && args.last[:dsl]
if dsl_mode
args.pop if args.last.is_a?(Hash) && args.last[:dsl]
super(method_name, *args, &block)
- 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 config
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def config
project_name = File.basename(File.expand_path('.'))
if !File.exists?('config/warble.rb')
puts 'Generating JAR configuration (config/warble.rb) to use with Warbler...'
FileUtils.mkdir_p('config')
Method place_ship!
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def place_ship!(ship)
begin
old_ship_top_left_cell = ship.top_left_cell
old_ship_orientation = ship.orientation
ship.top_left_cell = self
Method populate_table
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def populate_table(model_collection, parent, column_properties, internal_sort: false)
selected_table_item_models = parent.swt_widget.getSelection.map(&:get_data)
parent.finish_edit!
dispose_start_index = @last_model_collection_attribute_values &&
(model_collection.count < @last_model_collection_attribute_values.count) &&
Method calculate_paint_args!
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def calculate_paint_args!
unless @calculated_paint_args
if @name == 'pixel'
@name = 'point'
# optimized performance calculation for pixel points
Method delegate_observation_request_to_radios
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def delegate_observation_request_to_radios(observation_request, &block)
if observation_request != 'on_widget_disposed'
radios.count.times do |index|
radio = radios[index]
label = labels[index]
Method calculate_points
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def calculate_points
puts "Background calculation activated at zoom #{zoom}" if @background
if @points_calculated
puts "Points calculated already. Returning previously calculated points..."
return @points
Method countdown_group_button_composite
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def countdown_group_button_composite
composite {
row_layout {
margin_width 0
margin_height 0
Method enemy_attack!
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def enemy_attack!
begin
cell = nil
if @enemy_moves.any? && @enemy_moves.last.hit? && !@enemy_moves.last.ship.sunk?
if @enemy_moves[-2].nil? || !@enemy_moves[-2].hit?
Method drag_source=
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def drag_source=(drag_source_value)
deregister_drag_listeners if @drag_and_move
drag_source_old_value = @drag_source
@drag_source = drag_source_value
if @drag_source && !drag_source_old_value
Method apply_shape_arg_conversions!
has 26 lines of code (exceeds 25 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