piotrmurach/tty-progressbar

View on GitHub

Showing 14 of 14 total issues

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 308 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 register has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

            def register(format, options = {})
              observable = options.delete(:observable) { true }
              bar = TTY::ProgressBar.new(format, @options.merge(options))
      
              synchronize do
      Severity: Minor
      Found in lib/tty/progressbar/multi.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 format_determinate has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def format_determinate(value, width)
              complete_bar_length    = (width * @progress.ratio).round
              complete_char_length   = ProgressBar.display_columns(@progress.complete)
              incomplete_char_length = ProgressBar.display_columns(@progress.incomplete)
              head_char_length       = ProgressBar.display_columns(@progress.head)
      Severity: Minor
      Found in lib/tty/progressbar/formatter/bar.rb - About 1 hr to fix

        Method observe has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

              def observe(bar)
                bar.on(:progress, &progress_handler)
                   .on(:done) { emit(:done) if complete? }
                   .on(:stopped) { emit(:stopped) if stopped? }
                   .on(:paused) { emit(:paused) if paused? }
        Severity: Minor
        Found in lib/tty/progressbar/multi.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 call has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

              def call(value)
                if @progress.indeterminate? ||
                   (@progress.elapsed_time.zero? && @progress.ratio.zero?)
                  return value.gsub(matcher, "--:--:--")
                end
        Severity: Minor
        Found in lib/tty/progressbar/formatter/estimated_time.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 initialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def initialize(*args)
                super()
                @options = args.last.is_a?(::Hash) ? args.pop : {}
                format = args.empty? ? nil : args.pop
                @inset_opts = @options.delete(:style) { DEFAULT_INSET }
        Severity: Minor
        Found in lib/tty/progressbar/multi.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 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 format_determinate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def format_determinate(value, width)
                complete_bar_length    = (width * @progress.ratio).round
                complete_char_length   = ProgressBar.display_columns(@progress.complete)
                incomplete_char_length = ProgressBar.display_columns(@progress.incomplete)
                head_char_length       = ProgressBar.display_columns(@progress.head)
        Severity: Minor
        Found in lib/tty/progressbar/formatter/bar.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 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

        Method call has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def call(value)
                if @progress.indeterminate? ||
                   (@progress.elapsed_time.zero? && @progress.ratio.zero?)
                  return value.gsub(matcher, "--s")
                end
        Severity: Minor
        Found in lib/tty/progressbar/formatter/estimated.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