Showing 20 of 20 total issues
Method to_a
has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring. Open
def to_a
# puts "--- serializing #{width}x#{height} grid to array!"
#sleep 3
output = []
0.upto(height-1) do |y|
- 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
Class Region
has 26 methods (exceeds 20 allowed). Consider refactoring. Open
class Region < Entity #< Struct.new(:location, :size)
include Support::PositionHelpers
include Support::DirectionHelpers
attr_accessor :location, :size
def_delegators :@size, :height, :width, :area
Class Grid
has 24 methods (exceeds 20 allowed). Consider refactoring. Open
class Grid < Space
include Support::PositionHelpers
include Support::DirectionHelpers
attr_accessor :rows
Method cell
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def cell(pos,path)
output = ""
#pos = Position.new(x,y)
output << if !path.empty? && adjacent_in_path?(pos,pos.translate(WEST),path)
- 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 find_path
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def find_path(start, destination)
# puts "=== finding path from #{start} to #{destination}!"
distance = {}
previous = {}
visited = []
Method build_space!
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def build_space!(space)
space.each_position do |position|
build_passage!(position,position.translate(WEST)) unless position.x <= space.location.x
build_passage!(position,position.translate(NORTH)) unless position.y <= space.location.y
build_passage!(position,position.translate(EAST)) unless position.x >= space.location.x + space.width - 1
- 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 cell
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def cell(pos,path)
output = ""
#pos = Position.new(x,y)
output << if !path.empty? && adjacent_in_path?(pos,pos.translate(WEST),path)
Method carve_passageway!
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def carve_passageway!(room,other_room)
direction = direction_between_rooms(room, other_room)
case direction
when NORTH then
x = adjacent_room_adjoining_edge(room, other_room).sample
Method serialized_value_for
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def serialized_value_for(pos)
if stairs?(pos)
if stairs_up?(pos)
3
else
- 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 find_path
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def find_path(start, destination)
# puts "=== finding path from #{start} to #{destination}!"
distance = {}
previous = {}
visited = []
- 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 recursively_place_adjacent_rooms
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def recursively_place_adjacent_rooms(source,depth=0)
raise "first room not placed" unless source.placed
return if depth <= -MAX_DEPTH
unplaced_rooms.shuffle.take(2).each do |target|
next if target.placed
- 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 diagonal_neighbors
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def diagonal_neighbors
arr = []
all_directions.map do |first_direction|
all_directions.map do |second_direction|
if first_direction != second_direction && first_direction != direction_opposite(second_direction)
- 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 can_contain_adjacent_position?
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def can_contain_adjacent_position?(room,other_room,direction)
case direction
when NORTH then (return false) if other_room.y - room.height <= 1
when SOUTH then (return false) if other_room.y + room.height >= self.height - 1
when EAST then (return false) if other_room.x - room.width <= 1
- 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 place_adjacent_to_room
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def place_adjacent_to_room(room, other_room, direction=nil)
proposed_location = nil
proposed_direction = nil
conflict = true
- 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 initialize
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def initialize(opts={})
if opts.include?(:x) && opts.include?(:y)
self.location = Position.new(opts.delete(:x), opts.delete(:y))
elsif opts.include?(:location)
self.location = opts.delete(:location) #{ origin }
- 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 mutate!
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def mutate!(arr)
return arr if arr.empty? || variance == 0
rounds.times do
arr.each do |one|
- 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 row_separator
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def row_separator(y_coordinate,path)
output = ""
width.times do |x_coordinate|
pos = Position.new(x_coordinate,y_coordinate)
output << if passable?(pos,SOUTH)
- 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 place_first_room!
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def place_first_room!
first_room = self.rooms.sample
if self.up_stairs_location
stairs << Stairwell.new(location: self.up_stairs_location, access: Stairwell::UP)
- 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 cell
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def cell(position)
output = ""
output << (passable?(position,SOUTH) ? " " : "_")
if self.rows[position.y][position.x] & EAST != 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
Method subdivide
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def subdivide(space,opts={})
depth = opts.delete(:depth) { 0 }
depth = depth + 1
return [space] if reached_size_limit?(space) || (recursive && depth > MAX_DEPTH)
- 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"