danini-the-panini/mittsu-opengl

View on GitHub
lib/mittsu/opengl/plugins/shadow_map_plugin.rb

Summary

Maintainability
D
2 days
Test Coverage
F
52%

Method has too many lines. [120/30]
Open

    def render(scene, camera)
      return unless @renderer.shadow_map_enabled

      lights = []
      fog = nil

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.

Class has too many lines. [263/250]
Open

  class ShadowMapPlugin
    def initialize(renderer, lights, opengl_objects, opengl_objects_immediate)
      @renderer, @lights = renderer, lights
      @opengl_objects = opengl_objects
      @opengl_objects_immediate = opengl_objects_immediate

This cop checks if the length a class exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method render has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
Open

    def render(scene, camera)
      return unless @renderer.shadow_map_enabled

      lights = []
      fog = nil
Severity: Minor
Found in lib/mittsu/opengl/plugins/shadow_map_plugin.rb - About 6 hrs 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 render has 120 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def render(scene, camera)
      return unless @renderer.shadow_map_enabled

      lights = []
      fog = nil
Severity: Major
Found in lib/mittsu/opengl/plugins/shadow_map_plugin.rb - About 4 hrs to fix

    Cyclomatic complexity for render is too high. [22/6]
    Open

        def render(scene, camera)
          return unless @renderer.shadow_map_enabled
    
          lights = []
          fog = nil

    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. [39/30]
    Open

        def initialize(renderer, lights, opengl_objects, opengl_objects_immediate)
          @renderer, @lights = renderer, lights
          @opengl_objects = opengl_objects
          @opengl_objects_immediate = opengl_objects_immediate
    
    

    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.

    File shadow_map_plugin.rb has 268 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'mittsu/math'
    
    module Mittsu
      class ShadowMapPlugin
        def initialize(renderer, lights, opengl_objects, opengl_objects_immediate)
    Severity: Minor
    Found in lib/mittsu/opengl/plugins/shadow_map_plugin.rb - About 2 hrs to fix

      Method has too many lines. [33/30]
      Open

          def create_virtual_light(light, cascade)
            DirectionalLight.new.tap do |virtual_light|
              virtual_light.is_virtual = true
      
              virtual_light.only_shadow = true

      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.

      Cyclomatic complexity for update_shadow_camera is too high. [7/6]
      Open

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

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

          def initialize(renderer, lights, opengl_objects, opengl_objects_immediate)
            @renderer, @lights = renderer, lights
            @opengl_objects = opengl_objects
            @opengl_objects_immediate = opengl_objects_immediate
      
      
      Severity: Minor
      Found in lib/mittsu/opengl/plugins/shadow_map_plugin.rb - About 1 hr to fix

        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/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

        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/opengl/plugins/shadow_map_plugin.rb - About 1 hr to fix

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

              def project_object(scene, object, shadow_camera)
                if object.visible
                  opengl_objects = @opengl_objects[object.id]
          
                  if opengl_objects && object.cast_shadow && (object.frustum_culled == false || @frustum.intersects_object?(object) == true)
          Severity: Minor
          Found in lib/mittsu/opengl/plugins/shadow_map_plugin.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

          TODO found
          Open

                    # TODO: SkinnedMesh/morph_targets

          TODO found
          Open

                    # TODO: SkinnedMesh/morph_targets

          Use == if you meant to do a comparison or wrap the expression in parentheses to indicate you meant to assign in a condition.
          Open

                if @renderer.shadow_map_cull_face = CullFaceFront

          This cop checks for assignments in the conditions of if/while/until.

          Example:

          # bad
          
          if some_var = true
            do_something
          end

          Example:

          # good
          
          if some_var == true
            do_something
          end

          There are no issues that match your filters.

          Category
          Status