piotrmurach/tty-prompt

View on GitHub
lib/tty/prompt/enum_list.rb

Summary

Maintainability
B
5 hrs
Test Coverage

Class EnumList has 33 methods (exceeds 20 allowed). Consider refactoring.
Open

    class EnumList
      PAGE_HELP = "(Press tab/right or left to reveal more choices)"

      # Checks type of default parameter to be integer
      INTEGER_MATCHER = /\A[-+]?\d+\Z/.freeze
Severity: Minor
Found in lib/tty/prompt/enum_list.rb - About 4 hrs to fix

    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

    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

    There are no issues that match your filters.

    Category
    Status