Class has too many lines. [701/250] Open
class OpenGL::Renderer
attr_accessor :auto_clear, :auto_clear_color, :auto_clear_depth, :auto_clear_stencil, :sort_objects, :gamma_factor, :gamma_input,
:gamma_output, :shadow_map_enabled, :shadow_map_type, :shadow_map_cull_face, :shadow_map_debug, :shadow_map_cascade,
:max_morph_targets, :max_morph_normals, :info, :pixel_ratio, :window, :width, :height, :state
- Read upRead up
- Exclude checks
This cop checks if the length a class exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
File renderer.rb
has 729 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'opengl'
require 'glfw'
require 'fiddle'
require 'mittsu/opengl/version'
Class Renderer
has 77 methods (exceeds 20 allowed). Consider refactoring. Open
class OpenGL::Renderer
attr_accessor :auto_clear, :auto_clear_color, :auto_clear_depth, :auto_clear_stencil, :sort_objects, :gamma_factor, :gamma_input,
:gamma_output, :shadow_map_enabled, :shadow_map_type, :shadow_map_cull_face, :shadow_map_debug, :shadow_map_cascade,
:max_morph_targets, :max_morph_normals, :info, :pixel_ratio, :window, :width, :height, :state
Method has too many lines. [97/30] Open
def load_uniforms_generic(uniforms)
uniforms.each do |(uniform, location)|
# needs_update property is not added to all uniforms.
next if uniform.needs_update == false || location == -1
- Read upRead up
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Method load_uniforms_generic
has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring. Open
def load_uniforms_generic(uniforms)
uniforms.each do |(uniform, location)|
# needs_update property is not added to all uniforms.
next if uniform.needs_update == false || location == -1
- 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
Cyclomatic complexity for load_uniforms_generic is too high. [33/6] Open
def load_uniforms_generic(uniforms)
uniforms.each do |(uniform, location)|
# needs_update property is not added to all uniforms.
next if uniform.needs_update == false || location == -1
- Read upRead up
- Exclude checks
This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.
An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.
Method has too many lines. [57/30] Open
def set_program(camera, lights, fog, material, object)
@_used_texture_units = 0
if material.needs_update?
deallocate_material(material) if material.program
- Read upRead up
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Method load_uniforms_generic
has 97 lines of code (exceeds 25 allowed). Consider refactoring. Open
def load_uniforms_generic(uniforms)
uniforms.each do |(uniform, location)|
# needs_update property is not added to all uniforms.
next if uniform.needs_update == false || location == -1
Method set_program
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
def set_program(camera, lights, fog, material, object)
@_used_texture_units = 0
if material.needs_update?
deallocate_material(material) if material.program
- 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 update_object
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
def update_object(object)
geometry = object.geometry
if geometry.is_a? BufferGeometry
# TODO: geometry vertex array ?????
- 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
Cyclomatic complexity for set_program is too high. [18/6] Open
def set_program(camera, lights, fog, material, object)
@_used_texture_units = 0
if material.needs_update?
deallocate_material(material) if material.program
- Read upRead up
- Exclude checks
This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.
An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.
Method set_program
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
def set_program(camera, lights, fog, material, object)
@_used_texture_units = 0
if material.needs_update?
deallocate_material(material) if material.program
Cyclomatic complexity for render_buffer is too high. [10/6] Open
def render_buffer(camera, lights, fog, material, geometry_group, object)
puts "--- RENDER #{object.name}" if DEBUG
return unless material.visible
geometry_group.renderer = self
- Read upRead up
- Exclude checks
This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.
An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.
Method render_objects
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def render_objects(render_list, camera, lights, fog, override_material)
material = nil
render_list.each do |opengl_object|
puts "-- RENDER_OBJECT #{opengl_object.name}" if DEBUG
object = opengl_object.object
- 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_objects_immediate
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def render_objects_immediate(render_list, material_type, camera, lights, fog, override_material)
material = nil
render_list.each do |opengl_object|
object = opengl_object.object
if object.visible
- 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
Cyclomatic complexity for update_object is too high. [9/6] Open
def update_object(object)
geometry = object.geometry
if geometry.is_a? BufferGeometry
# TODO: geometry vertex array ?????
- Read upRead up
- Exclude checks
This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.
An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.
Cyclomatic complexity for render is too high. [7/6] Open
def render(scene, camera, render_target = default_target, force_clear = false)
raise "ERROR: Mittsu::OpenGL::Renderer#render: camera is not an instance of Mittsu::Camera" unless camera.is_a?(Camera)
reset_cache_for_this_frame
- Read upRead up
- Exclude checks
This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.
An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.
Method unroll_buffer_material
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def unroll_buffer_material(opengl_object)
object = opengl_object.object
buffer = opengl_object.buffer
geometry = object.geometry
- 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_buffer
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def render_buffer(camera, lights, fog, material, geometry_group, object)
puts "--- RENDER #{object.name}" if DEBUG
return unless material.visible
geometry_group.renderer = self
- 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_buffer
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def render_buffer(camera, lights, fog, material, geometry_group, object)
Method render_objects_immediate
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def render_objects_immediate(render_list, material_type, camera, lights, fog, override_material)
Method set_program
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def set_program(camera, lights, fog, material, object)
Method render_objects
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def render_objects(render_list, camera, lights, fog, override_material)
Method render
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def render(scene, camera, render_target = default_target, force_clear = false)
raise "ERROR: Mittsu::OpenGL::Renderer#render: camera is not an instance of Mittsu::Camera" unless camera.is_a?(Camera)
reset_cache_for_this_frame
- 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
Avoid parameter lists longer than 5 parameters. [6/5] Open
def render_buffer(camera, lights, fog, material, geometry_group, object)
- Read upRead up
- Exclude checks
This cop checks for methods with too many parameters. The maximum number of parameters is configurable. Keyword arguments can optionally be excluded from the total count.
Avoid parameter lists longer than 5 parameters. [6/5] Open
def render_objects_immediate(render_list, material_type, camera, lights, fog, override_material)
- Read upRead up
- Exclude checks
This cop checks for methods with too many parameters. The maximum number of parameters is configurable. Keyword arguments can optionally be excluded from the total count.
TODO found Open
# TODO: load extensions??
- Exclude checks
TODO found Open
# TODO: get_context ???
- Exclude checks
TODO found Open
# TODO framebuffer logic for render target cube
- Exclude checks
TODO found Open
# TODO: when morphing is implemented
- Exclude checks
TODO found Open
# TODO: force_context_loss ???
- Exclude checks
FIXME found Open
# FIXME: refactor
- Exclude checks
TODO found Open
# TODO: supports[half|standard|compressed|blend min max] ... ???
- Exclude checks
TODO found Open
# TODO: scale the image ...
- Exclude checks
TODO found Open
# TODO: geometry vertex array ?????
- Exclude checks
TODO found Open
# TODO: supports_float_textures? ???
- Exclude checks
TODO found Open
# TODO
- Exclude checks
TODO found Open
# TODO: when OpenGLRenderTargetCube exists
- Exclude checks
TODO found Open
# TODO: needs extensions.get ...
- Exclude checks
TODO found Open
# TODO: get max anisotropy ????
- Exclude checks
TODO found Open
# TODO: when skinning is implemented. Then also refactor
- Exclude checks
TODO found Open
# TODO: when all of these things exist
- Exclude checks
TODO found Open
@_supports_bone_textures = @_supports_vertex_textures && false # TODO: extensions.get('OES_texture_float') ????
- Exclude checks
TODO found Open
# TODO: when SkinnedMesh is defined
- Exclude checks
TODO found Open
uniform.array ||= value.flat_map(&:to_a) # TODO: Float32Array
- Exclude checks
TODO found Open
# TODO: make a GL.BufferSubData_easy method
- Exclude checks
TODO found Open
# TODO: handle losing opengl context??
- Exclude checks
TODO found Open
# TODO: when fog is implemented
- Exclude checks
TODO found Open
# TODO: when these custom plugins are implemented
- Exclude checks
TODO found Open
uniform.array ||= value.flat_map(&:to_a) # TODO: Float32Array
- Exclude checks
FIXME found Open
# FIXME: refactor
- Exclude checks
TODO found Open
# TODO: when OpenGLRenderTargetCube is defined
- Exclude checks
TODO found Open
uniform.array ||= value.flat_map(&:to_a) # TODO: Float32Array
- Exclude checks
TODO found Open
# TODO: when these custom plugins are implemented
- Exclude checks
FIXME found Open
# FIXME: REFACTOR!?!?!?!?!???
- Exclude checks
Similar blocks of code found in 2 locations. Consider refactoring. Open
when :'mat3[]'
if value.first.is_a? Matrix3
uniform.array ||= Array.new(9 * value.length) # Float32Array
value.each_with_index do |v, i|
- 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 51.
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
when :'mat4[]'
if value.first.is_a? Matrix4
uniform.array ||= Array.new(16 * value.length) # Float32Array
value.each_with_index do |v, i|
- 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 51.
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
end
at 392, 12 is not aligned with case
at 388, 23. Open
end
- Read upRead up
- Exclude checks
This cop checks whether the end keywords are aligned properly.
Three modes are supported through the EnforcedStyleAlignWith
configuration parameter:
If it's set to keyword
(which is the default), the end
shall be aligned with the start of the keyword (if, class, etc.).
If it's set to variable
the end
shall be aligned with the
left-hand-side of the variable assignment, if there is one.
If it's set to start_of_line
, the end
shall be aligned with the
start of the line where the matching keyword appears.
Example: EnforcedStyleAlignWith: keyword (default)
# bad
variable = if true
end
# good
variable = if true
end
Example: EnforcedStyleAlignWith: variable
# bad
variable = if true
end
# good
variable = if true
end
Example: EnforcedStyleAlignWith: startofline
# bad
variable = if true
end
# good
puts(if true
end)
Unused block argument - v
. If it's necessary, use _
or _v
as an argument name to indicate that it won't be used. Open
value.each_with_index do |v, i|
- Read upRead up
- Exclude checks
This cop checks for unused block arguments.
Example:
# bad
do_something do |used, unused|
puts used
end
do_something do |bar|
puts :foo
end
define_method(:foo) do |bar|
puts :baz
end
Example:
#good
do_something do |used, _unused|
puts used
end
do_something do
puts :foo
end
define_method(:foo) do |_bar|
puts :baz
end
Unused block argument - v
. If it's necessary, use _
or _v
as an argument name to indicate that it won't be used. Open
value.each_with_index do |v, i|
- Read upRead up
- Exclude checks
This cop checks for unused block arguments.
Example:
# bad
do_something do |used, unused|
puts used
end
do_something do |bar|
puts :foo
end
define_method(:foo) do |bar|
puts :baz
end
Example:
#good
do_something do |used, _unused|
puts used
end
do_something do
puts :foo
end
define_method(:foo) do |_bar|
puts :baz
end