smalruby/dxruby_sdl

View on GitHub

Showing 29 of 29 total issues

Method check has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
Open

      def check(o_sprites, d_sprites, shot = :shot, hit = :hit)
        res = false
        o_sprites = [o_sprites].flatten.select { |s| s.is_a?(self) }
        d_sprites = [d_sprites].flatten.select { |s| s.is_a?(self) }
        discards = []
Severity: Minor
Found in lib/dxruby_sdl/sprite.rb - About 5 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

Consider simplifying this complex logical expression.
Open

      if button_code == P_BUTTON0 && sdl_key_press?(SDL::Key::Z) ||
          button_code == P_BUTTON1 && sdl_key_press?(SDL::Key::X) ||
          button_code == P_BUTTON2 && sdl_key_press?(SDL::Key::C) ||
          button_code == P_LEFT && sdl_key_press?(SDL::Key::LEFT) ||
          button_code == P_RIGHT && sdl_key_press?(SDL::Key::RIGHT) ||
Severity: Critical
Found in lib/dxruby_sdl/input.rb - About 4 hrs to fix

    Consider simplifying this complex logical expression.
    Open

          if button_code == P_BUTTON0 && sdl_key_push?(SDL::Key::Z) ||
              button_code == P_BUTTON1 && sdl_key_push?(SDL::Key::X) ||
              button_code == P_BUTTON2 && sdl_key_push?(SDL::Key::C) ||
              button_code == P_LEFT && sdl_key_push?(SDL::Key::LEFT) ||
              button_code == P_RIGHT && sdl_key_push?(SDL::Key::RIGHT) ||
    Severity: Critical
    Found in lib/dxruby_sdl/input.rb - About 4 hrs to fix

      Method pad_down? has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          def pad_down?(button_code, pad_number = 0)
            if button_code == P_BUTTON0 && sdl_key_press?(SDL::Key::Z) ||
                button_code == P_BUTTON1 && sdl_key_press?(SDL::Key::X) ||
                button_code == P_BUTTON2 && sdl_key_press?(SDL::Key::C) ||
                button_code == P_LEFT && sdl_key_press?(SDL::Key::LEFT) ||
      Severity: Minor
      Found in lib/dxruby_sdl/input.rb - About 2 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 pad_push? has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          def pad_push?(button_code, pad_number = 0)
            if button_code == P_BUTTON0 && sdl_key_push?(SDL::Key::Z) ||
                button_code == P_BUTTON1 && sdl_key_push?(SDL::Key::X) ||
                button_code == P_BUTTON2 && sdl_key_push?(SDL::Key::C) ||
                button_code == P_LEFT && sdl_key_push?(SDL::Key::LEFT) ||
      Severity: Minor
      Found in lib/dxruby_sdl/input.rb - About 2 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

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

          def pad_push?(button_code, pad_number = 0)
            if button_code == P_BUTTON0 && sdl_key_push?(SDL::Key::Z) ||
                button_code == P_BUTTON1 && sdl_key_push?(SDL::Key::X) ||
                button_code == P_BUTTON2 && sdl_key_push?(SDL::Key::C) ||
                button_code == P_LEFT && sdl_key_push?(SDL::Key::LEFT) ||
      Severity: Major
      Found in lib/dxruby_sdl/input.rb and 1 other location - About 2 hrs to fix
      lib/dxruby_sdl/input.rb on lines 35..46

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

      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

          def pad_down?(button_code, pad_number = 0)
            if button_code == P_BUTTON0 && sdl_key_press?(SDL::Key::Z) ||
                button_code == P_BUTTON1 && sdl_key_press?(SDL::Key::X) ||
                button_code == P_BUTTON2 && sdl_key_press?(SDL::Key::C) ||
                button_code == P_LEFT && sdl_key_press?(SDL::Key::LEFT) ||
      Severity: Major
      Found in lib/dxruby_sdl/input.rb and 1 other location - About 2 hrs to fix
      lib/dxruby_sdl/input.rb on lines 49..60

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

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

            def check(o_sprites, d_sprites, shot = :shot, hit = :hit)
              res = false
              o_sprites = [o_sprites].flatten.select { |s| s.is_a?(self) }
              d_sprites = [d_sprites].flatten.select { |s| s.is_a?(self) }
              discards = []
      Severity: Minor
      Found in lib/dxruby_sdl/sprite.rb - About 1 hr to fix

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

            def draw
              if !@visible || vanished?
                return
              end
              [:blend, :shader].each do |method|
        Severity: Minor
        Found in lib/dxruby_sdl/sprite.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 draw has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def draw
              if !@visible || vanished?
                return
              end
              [:blend, :shader].each do |method|
        Severity: Minor
        Found in lib/dxruby_sdl/sprite.rb - About 1 hr to fix

          Method draw_scale has 8 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def draw_scale(x, y, image, scalex, scaley, centerx = nil, centery = nil, z = 0)
          Severity: Major
          Found in lib/dxruby_sdl/window.rb - About 1 hr to fix

            Method draw has 7 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def draw(x, y, image, x1 = 0, y1 = 0, width = image.width, height = image.height)
            Severity: Major
            Found in lib/dxruby_sdl/image.rb - About 50 mins to fix

              Method play has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                    def play
                      @last_played_channel = SDL::Mixer.play_channel(-1, @wave, @_loop_count)
                    rescue SDL::Error => e
                      if /No free channels available/ =~ e.message
                        SDL::Mixer.halt(@last_played_channel == 0 ? 1 : 0)
              Severity: Minor
              Found in lib/dxruby_sdl/sound.rb - About 45 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

              Consider simplifying this complex logical expression.
              Open

                    if !@collision_enable || vanished? ||
                        !other.collision_enable || other.vanished? ||
                        !other.image && !other.collision
                      return false
                    end
              Severity: Major
              Found in lib/dxruby_sdl/sprite.rb - About 40 mins to fix

                Method box_fill has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def box_fill(x1, y1, x2, y2, color)
                Severity: Minor
                Found in lib/dxruby_sdl/image.rb - About 35 mins to fix

                  Method box has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      def box(x1, y1, x2, y2, color)
                  Severity: Minor
                  Found in lib/dxruby_sdl/image.rb - About 35 mins to fix

                    Method load has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        def self.load(filename, x = nil, y = nil, width = nil, height = nil)
                    Severity: Minor
                    Found in lib/dxruby_sdl/image.rb - About 35 mins to fix

                      Method draw_font has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          def draw_font(x, y, string, font, option = {})
                      Severity: Minor
                      Found in lib/dxruby_sdl/render_target.rb - About 35 mins to fix

                        Method draw_font has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                            def draw_font(x, y, string, font, hash = {})
                        Severity: Minor
                        Found in lib/dxruby_sdl/window.rb - About 35 mins to fix

                          Method line has 5 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                              def line(x1, y1, x2, y2, color)
                          Severity: Minor
                          Found in lib/dxruby_sdl/image.rb - About 35 mins to fix
                            Severity
                            Category
                            Status
                            Source
                            Language