sickill/rainbow

View on GitHub

Showing 3 of 3 total issues

Class NullPresenter has 21 methods (exceeds 20 allowed). Consider refactoring.
Open

  class NullPresenter < ::String
    def color(*_values)
      self
    end

Severity: Minor
Found in lib/rainbow/null_presenter.rb - About 2 hrs to fix

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

        def self.build(ground, values)
          unless [1, 3].include?(values.size)
            raise ArgumentError,
                  "Wrong number of arguments for color definition, should be 1 or 3"
          end
    Severity: Minor
    Found in lib/rainbow/color.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 wrap_with_sgr has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def self.wrap_with_sgr(string, codes)
          return string if codes.empty?
    
          seq = "\e[" + codes.join(";") + "m"
    
    
    Severity: Minor
    Found in lib/rainbow/string_utils.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