smalruby/dxruby_sdl

View on GitHub

Showing 25 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

      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

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

                                def draw_font(x, y, string, font, color = [255, 255, 255])
                            Severity: Minor
                            Found in lib/dxruby_sdl/image.rb - About 35 mins to fix

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

                                    def clean(sprites)
                                      sprites.size.times do |i|
                                        s = sprites[i]
                                        if s.kind_of?(Array)
                                          clean(s)
                              Severity: Minor
                              Found in lib/dxruby_sdl/sprite.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

                              Severity
                              Category
                              Status
                              Source
                              Language