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 = []
- Read upRead up
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) ||
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) ||
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) ||
- Read upRead up
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) ||
- Read upRead up
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 = []
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|
- Read upRead up
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|
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)
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)
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)
- Read upRead up
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
Method box_fill
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def box_fill(x1, y1, x2, y2, color)
Method box
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def box(x1, y1, x2, y2, color)
Method load
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def self.load(filename, x = nil, y = nil, width = nil, height = nil)
Method draw_font
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def draw_font(x, y, string, font, option = {})
Method draw_font
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def draw_font(x, y, string, font, hash = {})
Method line
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def line(x1, y1, x2, y2, color)
Method draw_font
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def draw_font(x, y, string, font, color = [255, 255, 255])
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)
- Read upRead up
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"