Showing 250 of 250 total issues
Method after_load
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def after_load
super
# range is the hard limit: we won't return values outside the range
@options[:range] ||= DEFAULT_RANGE
- 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 on_key_press
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def on_key_press(key)
return super if key.control?
case key
when 'space'
# ignore
- 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 render
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def render
# Copy Cairo surface to OpenGL texture
if @last_copy_to_texture_frame_number != $env[:frame_number]
cc = cairo_canvas
Method build_editor_for
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def build_editor_for(user_object, options={})
return unless user_object
# extract options
grab_keyboard_focus = options.delete(:grab_keyboard_focus)
Method from_hsl
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def from_hsl(hue, sat, lum, ignored = nil)
return set([0.0,0.0,0.0]) if lum == 0.0 # if luminosity is zero, the colour is always black
return set([1.0,1.0,1.0]) if lum == 1.0 # if luminosity is one, the colour is always white
return set([lum, lum, lum]) if sat <= 1e-5 # if saturation is zero, the colour is always a greyscale colour
Method render!
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def render!
user_object_try {
if (offscreen_render_actor.present? && !$env[:hit_test])
with_offscreen_buffer { |buffer|
# render scene to offscreen buffer
Method append_from_file
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def append_from_file(file)
loaded_objects = Syck.load(file)
raise "version number '#{loaded_objects[:version]}' should be '#{FILE_VERSION}'" unless loaded_objects[:version] == FILE_VERSION
Method gui_render_styles
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def gui_render_styles
@object.gui_render_styles_list = GL.RenderCached(@object.gui_render_styles_list) {
if @object.effects.size > 8
num_rows = 4
else
Method decode_io
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.decode_io(io, &proc)
# Packets start with OSC address
address = decode_string(io)
# Special BUNDLE address
Method on_key_press
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def on_key_press(key)
return super if key.control?
case key
when 'space'
# ignore
Method create!
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create!
self << @cancel_button = GuiButton.new.set(:scale_x => 0.05, :scale_y => 0.06, :offset_x => -0.475, :offset_y => 0.47, :background_image => $engine.load_image('images/buttons/main-menu-close.png'), :background_image_hover => $engine.load_image('images/buttons/main-menu-close-hover.png'), :background_image_click => $engine.load_image('images/buttons/main-menu-close-click.png'))
@cancel_button.on_clicked { close_notify }
self << @open_button = GuiButton.new.set(:scale_x => 0.05, :scale_y => 0.06, :offset_x => 0.475, :offset_y => 0.47, :background_image => $engine.load_image('images/buttons/main-menu-open.png'), :background_image_hover => $engine.load_image('images/buttons/main-menu-open-hover.png'), :background_image_click => $engine.load_image('images/buttons/main-menu-open-click.png'))
Similar blocks of code found in 2 locations. Consider refactoring. Open
snippets_with_variables = snippets.collect_with_index { |snippet, index|
object = objects[index]
object.settings.each { |setting|
if setting.shader?
# TODO: improve find-and-replace
- 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 46.
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
snippets_with_variables = snippets.collect_with_index { |snippet, index|
object = objects[index]
object.settings.each { |setting|
if setting.shader?
# TODO: improve find-and-replace
- 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 46.
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 tick
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def tick
@from_director ||= starting_director.one
@to_directors_queue ||= []
if forwards.now?
- 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 on_key_press
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def on_key_press(key)
if key.control?
case key
when 'n'
add_new_director!
- 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 gui_tick
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def gui_tick
super
if allow_scrolling?
starting_scroll = @scroll
- 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 with_texture_of_previous_frame
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def with_texture_of_previous_frame(number_back)
if $previous_frames and $previous_frames.size >= number_back
index = $previous_frames_current_frame_index - number_back
index += $previous_frames.size if index < 0
#puts "chosen index=#{index} which has fbo_id=#{$previous_frames[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 fill_from_category!
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def fill_from_category!
clear_list!
find_valid_effect_classes.each { |object|
next unless (@category.nil? || object.in_category?(@category))
- 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 immediate_value
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def immediate_value
@last_value = @current_value
# Get raw value, as reported by physical input (MIDI slider, mouse x/y, joystick axis, etc.)
v = $engine.slider_value(@slider)
- 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 from_bgra8_partial
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def from_bgra8_partial(data, data_width, data_height, x, y, width, height)