piotrmurach/minehunter

View on GitHub
lib/minehunter/grid.rb

Summary

Maintainability
C
1 day
Test Coverage

Class Grid has 22 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Grid
    # Track the number of flags remaining
    #
    # @return [Integer]
    #
Severity: Minor
Found in lib/minehunter/grid.rb - About 2 hrs to fix

    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|
    Severity: Minor
    Found in lib/minehunter/grid.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 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]
    Severity: Minor
    Found in lib/minehunter/grid.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 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
    Severity: Minor
    Found in lib/minehunter/grid.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 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|
    Severity: Minor
    Found in lib/minehunter/grid.rb - About 55 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 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
    Severity: Minor
    Found in lib/minehunter/grid.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

    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
    Severity: Minor
    Found in lib/minehunter/grid.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

    There are no issues that match your filters.

    Category
    Status