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.
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"
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?
- Read upRead up
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)
- Read upRead up
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)
- Read upRead up
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))
- Read upRead up
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"