czuger/square-dungeon-gen

View on GitHub

Showing 6 of 6 total issues

Method initialize has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def initialize( top, left, lair, room_data = {} )
    @top = room_data['top'] ? room_data['top'].to_i : top
    @left = room_data['left'] ? room_data['left'].to_i : left
    @content = room_data['content']
    @content_description = room_data['content_description']
Severity: Minor
Found in lib/rooms/room.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 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def draw( gc, width, height, min_x, max_x, min_y, max_y, x_decal: 0, y_decal: 0 )
Severity: Major
Found in lib/hallways/hallway.rb - About 50 mins to fix

    Consider simplifying this complex logical expression.
    Open

          if( room_position != [ top, left ] && top >= 1 && left >= 1 && top <= @dungeon_size && left <= @dungeon_size &&
              @rooms.has_key?( [ top, left ] ) )
            connected_positions << [ top, left ]
          end
    Severity: Major
    Found in lib/dungeon/dungeon_walker.rb - About 40 mins to fix

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

        def delete_rooms
      
          to_delete_rooms_keys = @rooms.keys.shuffle
          puts "Current dungeon size = #{@rooms.count}" if @output
          target_dungeon_size = @rooms.count - ((@dungeon_size**2)*@rooms_removal_coef).ceil
      Severity: Minor
      Found in lib/dungeon/dungeon_generator.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 from_json has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def from_json( data, rooms )
          data.each do |hallway_data|
            # pp hallway_data
            r1 = rooms[hallway_data['hallway_id'][0]]
            r2 = rooms[hallway_data['hallway_id'][1]]
      Severity: Minor
      Found in lib/hallways/hallways_list.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 connect_hallways has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def connect_hallways
          Matrix.build( @dungeon_size ){ |r, c| [ r+1, c+1 ] }.to_a.flatten(1).each do |top, left|
            @hallways.connect_rooms( @rooms[ [ top, left ] ],@rooms[ [ top, left+1 ] ], HorizontalHallway.new ) unless left == @dungeon_size
            @hallways.connect_rooms( @rooms[ [ top, left ] ],@rooms[ [ top+1, left ] ], VerticalHallway.new ) unless top == @dungeon_size
          end
      Severity: Minor
      Found in lib/dungeon/dungeon_generator.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

      Severity
      Category
      Status
      Source
      Language