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["
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"
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
- Read upRead up
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)
- Read upRead up
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
- Read upRead up
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
- Read upRead up
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)
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? }
- Read upRead up
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
- Read upRead up
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
- Read upRead up
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 }
- Read upRead up
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
- Read upRead up
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
- Read upRead up
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)
- Read upRead up
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"