Cyclomatic complexity for update is too high. [11/6] Open
def update
# check all geometry groubs
mat = nil
geometry.groups.each do |geometry_group|
# TODO: place to put this???
- 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.
Consider simplifying this complex logical expression. Open
if geometry.vertices_need_update || geometry.morph_targets_need_update || geometry.elements_need_update || geometry.uvs_need_update || geometry.normals_need_update || geometry.colors_need_update || geometry.tangents_need_update || custom_attributes_dirty
geometry_group.set_mesh_buffers(self, GL::DYNAMIC_DRAW, !geometry.dynamic, mat)
end
Method render_buffer
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def render_buffer(camera, lights, fog, material, geometry_group, update_buffers)
Method render_buffer
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def render_buffer(camera, lights, fog, material, geometry_group, update_buffers)
type = GL::UNSIGNED_INT # geometry_group.type_array == Uint32Array ? GL::UNSIGNED_INT : GL::UNSIGNED_SHORT
# wireframe
if material.wireframe
- 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, update_buffers)
- 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: place to put this???
- Exclude checks
Unused method argument - lights
. If it's necessary, use _
or _lights
as an argument name to indicate that it won't be used. Open
def render_buffer(camera, lights, fog, material, geometry_group, update_buffers)
- Read upRead up
- Exclude checks
This cop checks for unused method arguments.
Example:
# bad
def some_method(used, unused, _unused_but_allowed)
puts used
end
Example:
# good
def some_method(used, _unused, _unused_but_allowed)
puts used
end
Unused method argument - fog
. If it's necessary, use _
or _fog
as an argument name to indicate that it won't be used. Open
def render_buffer(camera, lights, fog, material, geometry_group, update_buffers)
- Read upRead up
- Exclude checks
This cop checks for unused method arguments.
Example:
# bad
def some_method(used, unused, _unused_but_allowed)
puts used
end
Example:
# good
def some_method(used, _unused, _unused_but_allowed)
puts used
end
Unused method argument - camera
. If it's necessary, use _
or _camera
as an argument name to indicate that it won't be used. Open
def render_buffer(camera, lights, fog, material, geometry_group, update_buffers)
- Read upRead up
- Exclude checks
This cop checks for unused method arguments.
Example:
# bad
def some_method(used, unused, _unused_but_allowed)
puts used
end
Example:
# good
def some_method(used, _unused, _unused_but_allowed)
puts used
end