piotrmurach/tty-sparkline

View on GitHub

Showing 3 of 3 total issues

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

    def clamp_and_scale(value, min, max)
      return value unless value.is_a?(Numeric)

      clamped_value = value > max ? max : (value < min ? min : value)
      reduced_value = max == min ? clamped_value : clamped_value - min
Severity: Minor
Found in lib/tty/sparkline.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 render has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def render(min: nil, max: nil)
      return EMPTY if @data.empty?

      buffer = []
      calc_min, calc_max = data_minmax(min, max)
Severity: Minor
Found in lib/tty/sparkline.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 convert_to_bar has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def convert_to_bar(bar_index, offset)
      return convert_non_numeric unless bar_index.is_a?(Numeric)

      if bar_index >= offset * @num_of_bars
        bar_index -= offset * @num_of_bars
Severity: Minor
Found in lib/tty/sparkline.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

Severity
Category
Status
Source
Language