piotrmurach/tenpin

View on GitHub

Showing 5 of 7 total issues

Method bowl has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    def bowl(canvas = $stdout, pins: [], power: nil, hook: nil, delay: 0.1)
      i = 1

      while i <= @distance do
        angle = (hook - 50).abs
Severity: Minor
Found in lib/tenpin/bowler.rb - About 2 hrs 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 run has 66 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def run
      print cursor.hide
      puts cursor.clear_screen

      pos = Position[(cols / 3) - 10, rows / 5]
Severity: Major
Found in lib/tenpin/game.rb - About 2 hrs to fix

    Method bowl has 41 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def bowl(canvas = $stdout, pins: [], power: nil, hook: nil, delay: 0.1)
          i = 1
    
          while i <= @distance do
            angle = (hook - 50).abs
    Severity: Minor
    Found in lib/tenpin/bowler.rb - About 1 hr to fix

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

          def roll(pins)
            return if finish?
      
            current_frame_scores << pins
            @total += pins
      Severity: Minor
      Found in lib/tenpin/score.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 second_roll has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def second_roll(frame)
            scores = @score.frames[frame]
            if scores.nil?
              " "
            elsif strike?(frame)
      Severity: Minor
      Found in lib/tenpin/scoreboard.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