piotrmurach/tty-prompt

View on GitHub

Showing 43 of 49 total issues

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

        def call(input)
          if pattern.is_a?(String) || pattern.is_a?(Symbol)
            VALIDATORS.key?(pattern.to_sym)
            !VALIDATORS[pattern.to_sym].match(input.to_s).nil?
          elsif pattern.is_a?(Regexp)
Severity: Minor
Found in lib/tty/prompt/question/validation.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 render has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def render
        @input = ""
        until @done
          question = render_question
          @prompt.print(question)
Severity: Minor
Found in lib/tty/prompt/enum_list.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

Consider simplifying this complex logical expression.
Open

        elsif (@first_render && (help_start? || help_always?)) ||
              (help_always? && !@filter.any? && !@done)
          minmax_suffix +
            (print_selected ? "#{selected_names} " : "") +
            instructions
Severity: Major
Found in lib/tty/prompt/multi_list.rb - About 40 mins to fix

    Method render_question has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def render_question
            header = []
            if !Utils.blank?(@prefix) || !Utils.blank?(message)
              header << "#{@prefix}#{message} "
            end
    Severity: Minor
    Found in lib/tty/prompt/question.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 setup_defaults has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def setup_defaults
            infer_default
            @convert = conversion
            return if suffix? && positive?
    
    
    Severity: Minor
    Found in lib/tty/prompt/confirm_question.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 choices has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def choices(values = (not_set = true))
            if not_set
              if !filterable? || @filter.empty?
                @choices
              else
    Severity: Minor
    Found in lib/tty/prompt/list.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 keypress has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def keypress(event)
            if DELETE_KEYS.include?(event.key.name)
              @input.chop! unless @input.empty?
            elsif event.value =~ /^[^\e\n\r]/
              @input += event.value
    Severity: Minor
    Found in lib/tty/prompt/expander.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 validate_defaults has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def validate_defaults
            msg = if @default.nil? || @default.to_s.empty?
                    "default index must be an integer in range (1 - #{choices.size})"
                  elsif @default.to_s !~ INTEGER_MATCHER
                    validate_default_name
    Severity: Minor
    Found in lib/tty/prompt/enum_list.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 while_remaining has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def while_remaining
            start
            remaining = duration
    
            if @duration
    Severity: Minor
    Found in lib/tty/prompt/timer.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 render_question has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def render_question
            header = ["#{@prefix}#{message} "]
            if echo?
              masked = @mask.to_s * @input.to_s.length
              if @done_masked && !@failure
    Severity: Minor
    Found in lib/tty/prompt/mask_question.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 initialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def initialize(prompt, **options)
            super
            @echo    = options.fetch(:echo) { false }
            @keys    = options.fetch(:keys) { UndefinedSetting }
            @timeout = options.fetch(:timeout) { UndefinedSetting }
    Severity: Minor
    Found in lib/tty/prompt/keypress.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 load_auto_hint has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def load_auto_hint
            if @hint.nil? && collapsed?
              if @selected
                @hint = @selected.name
              else
    Severity: Minor
    Found in lib/tty/prompt/expander.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 call has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

              def self.call(question, value)
                if question.convert? && !Utils.blank?(value)
                  result = question.convert_result(value)
                  if result == Const::Undefined
                    tokens = { value: value, type: question.convert }
    Severity: Minor
    Found in lib/tty/prompt/question/checks.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 create_default_labels has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def create_default_labels
            @suffix   = default ? "Y/n" : "y/N"
            @positive = default ? "Yes" : "yes"
            @negative = default ? "no" : "No"
            @validation = /^(y(es)?|no?)$/i
    Severity: Minor
    Found in lib/tty/prompt/confirm_question.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 render_question has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def render_question
            header = ["#{@prefix}#{@question} "]
            if @done
              header << @prompt.decorate(choices[@active].to_s, @active_color)
              header << "\n"
    Severity: Minor
    Found in lib/tty/prompt/slider.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 render has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def render
            @errors = []
            until @done
              result = process_input(render_question)
              if result.failure?
    Severity: Minor
    Found in lib/tty/prompt/question.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 refresh has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def refresh(lines)
            if (@hint && (!@selected || @done)) || (@auto_hint && collapsed?)
              @hint = nil
              @prompt.clear_lines(lines, :down) +
                @prompt.cursor.prev_line
    Severity: Minor
    Found in lib/tty/prompt/expander.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 keyenter has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def keyenter(_)
            if @input.nil? || @input.empty?
              @input = @choices[@default - 1].key
              @default_key = true
            end
    Severity: Minor
    Found in lib/tty/prompt/expander.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 render_question has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def render_question
            header = "#{@prefix}#{message} "
            if !@done
              header += @prompt.decorate("(#{@suffix})", @help_color) + " "
            else
    Severity: Minor
    Found in lib/tty/prompt/confirm_question.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 default_help has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def default_help
            str = []
            str << "(Press "
            str << "#{arrows_help} arrow"
            str << " or 1-#{choices.size} number" if enumerate?
    Severity: Minor
    Found in lib/tty/prompt/multi_list.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