manyfold3d/mittsu-mesh_analysis

View on GitHub

Showing 12 of 12 total issues

Method flatten! has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def flatten!
      @faces = []
      @edges.each do |e0|
        next if e0.nil?
        if e0.left && @faces[e0.left].nil?
Severity: Minor
Found in lib/mittsu/mesh_analysis/winged_edge_geometry.rb - About 1 hr to fix

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 collapse has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def collapse(index, flatten: true)
      # Find edge, reorder vertices and reload
      e0 = edge(index)
      if e0
        move_vertex_to_end(e0.finish)
Severity: Minor
Found in lib/mittsu/mesh_analysis/winged_edge_geometry.rb - About 1 hr to fix

    Method move_vertex_to_end has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def move_vertex_to_end(index)
          return unless @vertices[index]
          # Add move vertex to end of array
          @vertices.push @vertices.slice!(index)
          new_index = @vertices.count - 1
    Severity: Minor
    Found in lib/mittsu/mesh_analysis/winged_edge_geometry.rb - About 1 hr to fix

    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_geometry has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def from_geometry(geometry, merge: true, normalize: true)
          # Merge vertices unless told not to
          geometry.merge_vertices if merge
          # Vertices are the same
          @vertices = geometry.vertices.clone
    Severity: Minor
    Found in lib/mittsu/mesh_analysis/winged_edge_geometry.rb - About 1 hr to fix

    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_geometry has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def from_geometry(geometry, merge: true, normalize: true)
          # Merge vertices unless told not to
          geometry.merge_vertices if merge
          # Vertices are the same
          @vertices = geometry.vertices.clone
    Severity: Minor
    Found in lib/mittsu/mesh_analysis/winged_edge_geometry.rb - About 1 hr to fix

      Method collapse has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def collapse(index, flatten: true)
            # Find edge, reorder vertices and reload
            e0 = edge(index)
            if e0
              move_vertex_to_end(e0.finish)
      Severity: Minor
      Found in lib/mittsu/mesh_analysis/winged_edge_geometry.rb - About 55 mins to fix

      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

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

              if e0.right && @faces[e0.right].nil?
                @faces[e0.right] = Mittsu::Face3.new(e0.finish, e0.start, edge(e0.finish_right)&.other_vertex(e0.start)) if e0.finish && e0.start && edge(e0.finish_right)&.other_vertex(e0.start)
              end
      Severity: Minor
      Found in lib/mittsu/mesh_analysis/winged_edge_geometry.rb and 1 other location - About 45 mins to fix
      lib/mittsu/mesh_analysis/winged_edge_geometry.rb on lines 65..67

      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 39.

      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

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

              if e0.left && @faces[e0.left].nil?
                @faces[e0.left] = Mittsu::Face3.new(e0.start, e0.finish, edge(e0.finish_left)&.other_vertex(e0.finish)) if e0.start && e0.finish && edge(e0.finish_left)&.other_vertex(e0.finish)
              end
      Severity: Minor
      Found in lib/mittsu/mesh_analysis/winged_edge_geometry.rb and 1 other location - About 45 mins to fix
      lib/mittsu/mesh_analysis/winged_edge_geometry.rb on lines 68..70

      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 39.

      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

      Further Reading

      Method stitch has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def stitch(edge)
            # Make sure the edges share a vertex and face
            face = shared_face(edge)
            return nil unless face && edge.coincident_at(edge)
            # Flip incoming edge if it's not pointing the same way
      Severity: Minor
      Found in lib/mittsu/mesh_analysis/winged_edge.rb - About 35 mins to fix

      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

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

      renderer.window.on_mouse_move do |position|
        if renderer.window.mouse_button_down?(GLFW::MOUSE_BUTTON_LEFT)
          mouse_delta.copy(last_mouse_position).sub(position)
          last_mouse_position.copy(position)
          camera_container.rotate_on_axis(Y_AXIS, mouse_delta.x * 0.01)
      Severity: Minor
      Found in examples/decimate.rb and 1 other location - About 35 mins to fix
      examples/progressive_mesh.rb on lines 59..64

      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 34.

      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

      Further Reading

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

      renderer.window.on_mouse_move do |position|
        if renderer.window.mouse_button_down?(GLFW::MOUSE_BUTTON_LEFT)
          mouse_delta.copy(last_mouse_position).sub(position)
          last_mouse_position.copy(position)
          camera_container.rotate_on_axis(Y_AXIS, mouse_delta.x * 0.01)
      Severity: Minor
      Found in examples/progressive_mesh.rb and 1 other location - About 35 mins to fix
      examples/decimate.rb on lines 59..64

      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 34.

      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

      Further Reading

      Method decimate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def decimate(target_face_count, vertex_splits: false)
          @geometry.flatten!
          edge_collapses = edge_collapse_costs.sort_by { |x| x[:cost] }
          splits = []
          loop do
      Severity: Minor
      Found in lib/mittsu/mesh_analysis/modifiers/decimator.rb - About 25 mins to fix

      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

      Severity
      Category
      Status
      Source
      Language