JEG2/highline

View on GitHub

Showing 31 of 31 total issues

Class HighLine has 43 methods (exceeds 20 allowed). Consider refactoring.
Open

class HighLine
  include BuiltinStyles
  include CustomErrors

  extend SingleForwardable
Severity: Minor
Found in lib/highline.rb - About 5 hrs to fix

    Class ListRenderer has 31 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class ListRenderer
        # Items list
        # @return [Array]
        attr_reader :items
    
    
    Severity: Minor
    Found in lib/highline/list_renderer.rb - About 3 hrs to fix

      Class Question has 30 methods (exceeds 20 allowed). Consider refactoring.
      Open

        class Question
          include CustomErrors
      
          #
          # If _template_or_question_ is already a Question object just return it.
      Severity: Minor
      Found in lib/highline/question.rb - About 3 hrs to fix

        Class Menu has 30 methods (exceeds 20 allowed). Consider refactoring.
        Open

          class Menu < Question
            # Pass +false+ to _color_ to turn off HighLine::Menu's
            # index coloring.
            # Pass a color and the Menu's indices will be colored.
            class << self
        Severity: Minor
        Found in lib/highline/menu.rb - About 3 hrs to fix

          File highline.rb has 311 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          require "English"
          require "erb"
          require "optparse"
          require "stringio"
          require "abbrev"
          Severity: Minor
          Found in lib/highline.rb - About 3 hrs to fix

            Method get_line_raw_no_echo_mode has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
            Open

              def get_line_raw_no_echo_mode(question)
                line = ""
            
                terminal.raw_no_echo_mode_exec do
                  loop do
            Severity: Minor
            Found in lib/highline.rb - About 3 hrs 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

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

                  def self.define_style_support_methods(base)
                    base.class_eval do
                      undef :color if method_defined? :color
                      undef :foreground if method_defined? :foreground
                      def color(*args)
              Severity: Minor
              Found in lib/highline/string_extensions.rb - About 2 hrs 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

              File menu.rb has 253 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              require "highline/question"
              require "highline/menu/item"
              
              class HighLine
                #
              Severity: Minor
              Found in lib/highline/menu.rb - About 2 hrs to fix

                Method define_style_support_methods has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def self.define_style_support_methods(base)
                      base.class_eval do
                        undef :color if method_defined? :color
                        undef :foreground if method_defined? :foreground
                        def color(*args)
                Severity: Major
                Found in lib/highline/string_extensions.rb - About 2 hrs to fix

                  File question.rb has 251 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  require "English"
                  require "optparse"
                  require "date"
                  require "pathname"
                  require "highline/question/answer_converter"
                  Severity: Minor
                  Found in lib/highline/question.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 choose has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def choose(*items, &details)
                        menu = Menu.new(&details)
                        menu.choices(*items) unless items.empty?
                    
                        # Set auto-completion
                    Severity: Minor
                    Found in lib/highline.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 ask_once has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def ask_once
                          question.show_question(@highline)
                    
                          begin
                            question.get_response_or_default(@highline)
                    Severity: Minor
                    Found in lib/highline/question_asker.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 value_for_selected_item has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def value_for_selected_item(item, details)
                          if item.action
                            result = if @shell
                                       item.action.call(item.name, details)
                                     else
                    Severity: Minor
                    Found in lib/highline/menu.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 6 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                      def initialize(input = $stdin, output = $stdout,
                                     wrap_at = nil, page_at = nil,
                                     indent_size = 3, indent_level = 0)
                    Severity: Minor
                    Found in lib/highline.rb - About 45 mins to fix

                      Method wrap has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def self.wrap(text, wrap_at)
                            return text unless wrap_at
                            wrap_at = Integer(wrap_at)
                      
                            wrapped = []
                      Severity: Minor
                      Found in lib/highline/wrapper.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 setup_color_code has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                              def setup_color_code(*colors)
                                color_code = colors.map do |color|
                                  if color.is_a?(Numeric)
                                    format("%02x", color)
                                  else
                      Severity: Minor
                      Found in lib/highline/string_extensions.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 const_missing has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                            def const_missing(name)
                              raise NameError, "Bad color or uninitialized constant #{name}" unless
                                name.to_s =~ RGB_COLOR_PATTERN
                      
                              on = Regexp.last_match(1)
                      Severity: Minor
                      Found in lib/highline/builtin_styles.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