JEG2/highline

View on GitHub
lib/highline/question.rb

Summary

Maintainability
C
7 hrs
Test Coverage

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

          def append_default_to_template
            return unless default.respond_to? :to_s
      
            default_str = default.to_s
            return if default_str.empty?
      Severity: Minor
      Found in lib/highline/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 remove_whitespace has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def remove_whitespace(answer_string)
            if !whitespace
              answer_string
            elsif [:strip, :chomp].include?(whitespace)
              answer_string.send(whitespace)
      Severity: Minor
      Found in lib/highline/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 confirm_question has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def confirm_question(highline)
            if confirm == true
              "Are you sure?  "
            elsif confirm.is_a?(Proc)
              confirm.call(answer)
      Severity: Minor
      Found in lib/highline/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 valid_answer? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def valid_answer?
            !validate ||
              (validate.is_a?(Regexp) && answer =~ validate) ||
              (validate.is_a?(Proc)   && validate[answer]) ||
              (validate.respond_to?(:valid?) && validate.valid?(answer))
      Severity: Minor
      Found in lib/highline/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

      There are no issues that match your filters.

      Category
      Status