piotrmurach/tty-progressbar

View on GitHub
lib/tty/progressbar.rb

Summary

Maintainability
D
1 day
Test Coverage

Class ProgressBar has 35 methods (exceeds 20 allowed). Consider refactoring.
Open

  class ProgressBar
    extend Forwardable
    include MonitorMixin

    ECMA_CSI = "\e["
Severity: Minor
Found in lib/tty/progressbar.rb - About 4 hrs to fix

    File progressbar.rb has 312 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require "io/console"
    require "forwardable"
    require "monitor"
    require "tty-cursor"
    require "tty-screen"
    Severity: Minor
    Found in lib/tty/progressbar.rb - About 3 hrs to fix

      Method move_to_row has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          def move_to_row
            if @multibar
              CURSOR_LOCK.synchronize do
                if @first_render
                  @row = @multibar.next_row
      Severity: Minor
      Found in lib/tty/progressbar.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 advance has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def advance(progress = 1, tokens = {})
            return if done?
      
            synchronize do
              emit(:progress, progress)
      Severity: Minor
      Found in lib/tty/progressbar.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 ratio has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def ratio
            synchronize do
              proportion = if total
                             total > 0 ? (@current.to_f / total) : 0
                           else
      Severity: Minor
      Found in lib/tty/progressbar.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 finish has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def finish
            return if done?
      
            @current = total unless indeterminate?
            render
      Severity: Minor
      Found in lib/tty/progressbar.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 write has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def write(data, clear_first = false)
            return unless tty? # write only to terminal
      
            move_to_row do
              output.print(TTY::Cursor.column(1)) if clear_first
      Severity: Minor
      Found in lib/tty/progressbar.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

      There are no issues that match your filters.

      Category
      Status