danini-the-panini/mittsu

View on GitHub

Showing 659 of 659 total issues

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

      for i in 0..segments do
        vertex = Vector3.new
        segment = theta_start + i.to_f / segments.to_f * theta_length

        vertex.x = radius * ::Math.cos(segment)
Severity: Major
Found in lib/mittsu/extras/geometries/circle_geometry.rb and 1 other location - About 1 hr to fix
lib/mittsu/extras/geometries/ring_geometry.rb on lines 28..35

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

Method set_from_rotation_matrix has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def set_from_rotation_matrix(m)
      # http:#www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm
      # assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)
      te = m.elements
      m11 = te[0]; m12 = te[4]; m13 = te[8]
Severity: Minor
Found in lib/mittsu/math/quaternion.rb - About 1 hr to fix

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

        def initialize(parameters = {})
          super()
    
            @type = 'MeshPhongMaterial'
    
    
    Severity: Minor
    Found in lib/mittsu/materials/mesh_phong_material.rb - About 1 hr to fix

      Method clone has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def clone
            material = MeshPhongMaterial.new
      
            super(material)
      
      
      Severity: Minor
      Found in lib/mittsu/materials/mesh_phong_material.rb - About 1 hr to fix

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

              def load_uniforms(uniforms, uniforms_lib)
                uniform_strings = nil;
                in_uniform = false
        
                uniforms.lines.map(&:strip).each_with_object({}) { |line, hash|
        Severity: Minor
        Found in lib/mittsu/renderers/shaders/rbsl_loader.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 raycast has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def raycast(raycaster, intersects)
              threshold = raycaster.params[:point_cloud][:threshold]
              @_inverse_matrix.inverse(self.matrix_world)
              @_ray.copy(raycaster.ray).apply_matrix4(@_inverse_matrix)
        
        
        Severity: Minor
        Found in lib/mittsu/objects/point_cloud.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

        Avoid parameter lists longer than 5 parameters. [16/5]
        Open

            def set(n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44)
        Severity: Minor
        Found in lib/mittsu/math/matrix4.rb by rubocop

        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.

        Method decompose has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def decompose(position, quaternion, scale)
              vector = Mittsu::Vector3.new
              matrix = Mittsu::Matrix4.new
              te = self.elements
              sx = vector.set(te[0], te[1],  te[2]).length
        Severity: Minor
        Found in lib/mittsu/math/matrix4.rb - About 1 hr to fix

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

              def initialize(color = nil, intensity = 1.0)
                super(color)
          
                @type = 'DirectionalLight'
          
          
          Severity: Minor
          Found in lib/mittsu/lights/directional_light.rb - About 1 hr to fix

            Method make_groups has 30 lines of code (exceeds 25 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

              Method compute_vertex_normals has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def compute_vertex_normals(area_weighted = false)
                    vertices = Array.new(@vertices.length)
                    @vertices.length.times do |v|
                      vertices[v] = Mittsu::Vector3.new
                    end
              Severity: Minor
              Found in lib/mittsu/core/geometry.rb - About 1 hr to fix

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

                    def initialize
                      super
                      @id = (@@id ||= 1).tap { @@id += 1 }
                
                      @uuid = SecureRandom.uuid
                Severity: Minor
                Found in lib/mittsu/core/object_3d.rb - About 1 hr to fix

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

                      def initialize(near, far, cube_resolution)
                        super()
                  
                        @type = 'CubeCamera'
                  
                  
                  Severity: Minor
                  Found in lib/mittsu/cameras/cube_camera.rb - About 1 hr to fix

                    Method set has 9 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        def set(n11, n12, n13, n21, n22, n23, n31, n32, n33)
                    Severity: Major
                    Found in lib/mittsu/math/matrix3.rb - About 1 hr to fix

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

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

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

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

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

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

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

                                def initialize(radius = 50.0, segments = 8, theta_start = 0.0, theta_length = (::Math::PI * 2.0))
                                  super()
                            
                                  @type = 'CircleGeometry'
                            
                            
                            Severity: Minor
                            Found in lib/mittsu/extras/geometries/circle_geometry.rb - About 1 hr to fix

                              Method cache_uniform_locations has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  def cache_uniform_locations(uniforms, parameters)
                                    identifiers = [
                                      'viewMatrix',
                                      'modelViewMatrix',
                                      'projectionMatrix',
                              Severity: Minor
                              Found in lib/mittsu/renderers/opengl/opengl_program.rb - About 1 hr to fix

                                Method multiply_matrices has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    def multiply_matrices(a, b)
                                      ae = a.elements
                                      be = b.elements
                                      te = self.elements
                                      a11 = ae[0]; a12 = ae[4]; a13 = ae[8];  a14 = ae[12]
                                Severity: Minor
                                Found in lib/mittsu/math/matrix4.rb - About 1 hr to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language