abinoam/highline

View on GitHub
lib/highline/style.rb

Summary

Maintainability
B
6 hrs
Test Coverage

Class Style has 24 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Style
    # Index the given style.
    # Uses @code_index (Hash) as repository.
    # @param style [Style]
    # @return [Style] the given style
Severity: Minor
Found in lib/highline/style.rb - About 2 hrs to fix

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

      def self.find_or_create_style(arg)
        if arg.is_a?(Style)
          Style.list[arg.name] || Style.index(arg)
        elsif arg.is_a?(::String) && arg =~ /^\e\[/ # arg is a code
          styles = Style.code_index[arg]
    Severity: Minor
    Found in lib/highline/style.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 create_bright_variant has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def create_bright_variant(variant_name)
          raise "Cannot create a #{name} variant of a style list (#{inspect})" if
            @list
          new_name = ("#{variant_name}_" + @name.to_s).to_sym
          new_rgb =
    Severity: Minor
    Found in lib/highline/style.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 variant has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def variant(new_name, options = {})
          raise "Cannot create a variant of a style list (#{inspect})" if @list
          new_code = options[:code] || code
          if options[:increment]
            raise "Unexpected code in #{inspect}" unless
    Severity: Minor
    Found in lib/highline/style.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 index has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def self.index(style)
          if style.name
            @styles ||= {}
            @styles[style.name] = style
          end
    Severity: Minor
    Found in lib/highline/style.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 initialize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def initialize(defn = {})
          @definition = defn
          @name    = defn[:name]
          @code    = defn[:code]
          @rgb     = defn[:rgb]
    Severity: Minor
    Found in lib/highline/style.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