Showing 10 of 10 total issues
Class Grid
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
class Grid
# Track the number of flags remaining
#
# @return [Integer]
#
Method fields_next_to
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def fields_next_to(x, y)
return to_enum(:fields_next_to, x, y) unless block_given?
-1.upto(1) do |offset_x|
-1.upto(1) do |offset_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
Method uncover
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def uncover(x, y)
field = field_at(x, y)
if field.mine?
field.uncover
- 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 fill_with_mines
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def fill_with_mines(x, y, randomiser: DEFAULT_RANDOMISER)
limit = @mines_limit
while limit > 0
mine_x = randomiser[@width]
mine_y = randomiser[@height]
- 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 run
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def run(argv = ARGV, input: $stdin, output: $stdout, env: {}, color: nil,
screen_width: TTY::Screen.width, screen_height: TTY::Screen.height)
parse(argv)
if params[:help]
Method render
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def render(decorator: DEFAULT_DECORATOR)
if !cover?
if mine? then BOMB
elsif flag? && wrong? then decorator[WRONG, :on_red]
elsif !mine_count.zero?
- 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 render
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def render(x, y, decorator: DEFAULT_DECORATOR)
out = []
@height.times do |field_y|
@width.times do |field_x|
- 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 uncover_mines
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def uncover_mines
@fields.each do |field|
if field.mine? && !field.flag? || field.flag? && !field.mine?
field.wrong if field.flag?
field.uncover
- 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 run
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def run(argv = ARGV, input: $stdin, output: $stdout, env: {}, color: nil,
screen_width: TTY::Screen.width, screen_height: TTY::Screen.height)
parse(argv)
if params[:help]
- 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 uncover_around
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def uncover_around(x, y)
field = field_at(x, y)
uncovered_mine = false
if count_flags_next_to(x, y) != field.mine_count
- 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"