JEG2/highline

View on GitHub

Showing 34 of 34 total issues

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

class HighLine
  include BuiltinStyles
  include CustomErrors

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

    Method get_line_raw_no_echo_mode has a Cognitive Complexity of 32 (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 4 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 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 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

        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

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

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

            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

              File question.rb has 257 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 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

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

                        def ask_once
                          # If in readline mode, let reline take care of the prompt
                          question.show_question(@highline) unless question.readline
                    
                          begin
                    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 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 26 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        def ask_once
                          # If in readline mode, let reline take care of the prompt
                          question.show_question(@highline) unless question.readline
                    
                          begin
                    Severity: Minor
                    Found in lib/highline/question_asker.rb - About 1 hr to fix

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

                            def terminal_size
                              begin
                                require "io/console"
                                winsize = begin
                                            IO.console.winsize.reverse
                      Severity: Minor
                      Found in lib/highline/terminal/unix_stty.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 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 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
                        Severity
                        Category
                        Status
                        Source
                        Language