smalruby/dxruby_sdl

View on GitHub
lib/dxruby_sdl/sprite.rb

Summary

Maintainability
C
1 day
Test Coverage

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

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

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

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

            def ===(other)
              if !@collision_enable || vanished? ||
                  !other.collision_enable || other.vanished? ||
                  !other.image && !other.collision
                return false
        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

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

              def update(sprites)
                [sprites].flatten.each do |s|
                  if !s.respond_to?(:vanished?) or !s.vanished?
                    if s.respond_to?(:update)
                      s.update
        Severity: Minor
        Found in lib/dxruby_sdl/sprite.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

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

              def draw(sprites)
                [sprites].flatten.each do |s|
                  if !s.respond_to?(:vanished?) or !s.vanished?
                    if s.respond_to?(:draw)
                      s.draw
        Severity: Minor
        Found in lib/dxruby_sdl/sprite.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

        There are no issues that match your filters.

        Category
        Status