danini-the-panini/mittsu

View on GitHub

Showing 659 of 659 total issues

Method set_line_buffers has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def set_line_buffers(hint)
      if @vertices_need_update
        @vertices.each_with_index do |vertex, v|
          offset = v * 3

Severity: Minor
Found in lib/mittsu/renderers/opengl/core/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 build_plane has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def build_plane(u, v, udir, vdir, width, height, depth, material_index)
      grid_x = @width_segments
      grid_y = @height_segments
      width_half = width / 2.0
      height_half = height / 2.0
Severity: Minor
Found in lib/mittsu/extras/geometries/box_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 make_groups has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def make_groups(uses_face_material = false)
      max_vertices_in_group = 65535 # TODO: OES_element_index_uint ???

      hash_map = {}

Severity: Minor
Found in lib/mittsu/renderers/opengl/core/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 update_shadow_camera has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def update_shadow_camera(camera, light)
      shadow_camera = light.shadow_camera
      points_frustum = light.pointa_frustum
      points_world = light.points_world

Severity: Minor
Found in lib/mittsu/renderers/opengl/plugins/shadow_map_plugin.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

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

      if geometry.uvs_need_update && obj_uvs
        @faces3.each do |fi|
          uv = obj_uvs[fi]

          next if uv.nil?
Severity: Major
Found in lib/mittsu/renderers/opengl/opengl_geometry_group.rb and 1 other location - About 1 hr to fix
lib/mittsu/renderers/opengl/opengl_geometry_group.rb on lines 470..490

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

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

    def set_values(values = nil)
      return if values.nil?

      values.each do |(key, new_value)|
        if new_value.nil?
Severity: Minor
Found in lib/mittsu/materials/material.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 hsl has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def hsl(target = nil)
      # h,s,l ranges are in 0.0 - 1.0
      hsl = target || { h: 0.0, s: 0.0, l: 0.0 }
      rr, gg, bb = self.r, self.g, self.b
      max = [r, g, b].max
Severity: Minor
Found in lib/mittsu/math/color.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 compute_morph_normals has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def compute_morph_normals
      # save original normals
      # - create temp variables on first access
      #   otherwise just copy (for faster repeated calls)
      @_original_face_normal ||= []
Severity: Minor
Found in lib/mittsu/core/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

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

      if geometry.uvs_need_update && obj_uvs2
        @faces3.each do |fi|
          uv2 = obj_uvs2[fi]

          next if uv2.nil?
Severity: Major
Found in lib/mittsu/renderers/opengl/opengl_geometry_group.rb and 1 other location - About 1 hr to fix
lib/mittsu/renderers/opengl/opengl_geometry_group.rb on lines 448..468

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

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

    def inverse(m, throw_on_invertable = false)
      # based on http:#www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm
      te = @elements
      me = m.elements
      n11 = me[0]; n12 = me[4]; n13 = me[8];  n14 = me[12]
Severity: Minor
Found in lib/mittsu/math/matrix4.rb - About 1 hr to fix

    Method create_material has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def create_material(material_name)
            mat = @materials_info[material_name]
            params = {
              name: material_name,
              side: @side
    Severity: Minor
    Found in lib/mittsu/loaders/mtl_loader.rb - About 1 hr to fix

      Method initialize has 11 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def initialize(mipmaps = nil, width = nil, height = nil, format = RGBAFormat, type = UnsignedByteType, mapping = DEFAULT_MAPPING, wrap_s = ClampToEdgeWrapping, wrap_t = ClampToEdgeWrapping, mag_filter = LinearFilter, min_filter = LinearMipMapLinearFilter, anisotropy = 1)
      Severity: Major
      Found in lib/mittsu/textures/compressed_texture.rb - About 1 hr to fix

        Method initialize has 11 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def initialize(data = nil, width = nil, height = nil, format = RGBAFormat, type = UnsignedByteType, mapping = DEFAULT_MAPPING, wrap_s = ClampToEdgeWrapping, wrap_t = ClampToEdgeWrapping, mag_filter = LinearFilter, min_filter = LinearMipMapLinearFilter, anisotropy = 1)
        Severity: Major
        Found in lib/mittsu/textures/data_texture.rb - About 1 hr to fix

          Method initialize has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def initialize(radius = 1.0, detail = 0)
                t = (1.0 + ::Math.sqrt(5.0)) / 2.0
                r = 1.0 / t
          
                vertices = [
          Severity: Minor
          Found in lib/mittsu/extras/geometries/dodecahedron_geometry.rb - About 1 hr to fix

            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
            Severity: Critical
            Found in lib/mittsu/renderers/opengl/objects/mesh.rb - About 1 hr to fix

              Method create_virtual_light has 33 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def create_virtual_light(light, cascade)
                    DirectionalLight.new.tap do |virtual_light|
                      virtual_light.is_virtual = true
              
                      virtual_light.only_shadow = true
              Severity: Minor
              Found in lib/mittsu/renderers/opengl/plugins/shadow_map_plugin.rb - About 1 hr to fix

                Method to_json has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def to_json
                      output = {
                        metadata: {
                          version: 4.0,
                          type: 'BufferGeometry',
                Severity: Minor
                Found in lib/mittsu/core/buffer_geometry.rb - About 1 hr to fix

                  Method intersect_box has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def intersect_box(box, target = Mittsu::Vector3.new)
                        # http:#www.scratchapixel.com/lessons/3d-basic-lessons/lesson-7-intersecting-simple-shapes/ray-box-intersection/
                        invdirx = 1.0 / @direction.x
                        invdiry = 1.0 / @direction.y
                        invdirz = 1.0 / @direction.z
                  Severity: Minor
                  Found in lib/mittsu/math/ray.rb - About 1 hr to fix

                    Method create_texture has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        def create_texture(where, name, source_file, repeat, offset, wrap, anisotropy)
                          full_path = File.join(texture_path, source_file)
                    
                          loader = Handlers.get(full_path)
                    
                    
                    Severity: Minor
                    Found in lib/mittsu/loaders/loader.rb - About 1 hr to fix

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

                              for o in 0..theta_segments do # number of segments per circle
                                vertex = Vector3.new
                                segment = theta_start + o.to_f / theta_segments.to_f * theta_length
                                vertex.x = radius * ::Math.cos(segment)
                                vertex.y = radius * ::Math.sin(segment)
                      Severity: Major
                      Found in lib/mittsu/extras/geometries/ring_geometry.rb and 1 other location - About 1 hr to fix
                      lib/mittsu/extras/geometries/circle_geometry.rb on lines 26..34

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

                      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

                      Severity
                      Category
                      Status
                      Source
                      Language