lib/tty/prompt/question.rb
Class Question
has 28 methods (exceeds 20 allowed). Consider refactoring. Open
Open
class Question
include Checks
UndefinedSetting = Class.new do
def to_s
Method initialize
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def initialize(prompt, **options)
# Option deprecation
if options[:validation]
warn "[DEPRECATION] The `:validation` option is deprecated. Use `:validate` instead."
options[:validate] = options[:validation]
Method render_question
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
def render_question
header = []
if !Utils.blank?(@prefix) || !Utils.blank?(message)
header << "#{@prefix}#{message} "
end
- 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 render
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
def render
@errors = []
until @done
result = process_input(render_question)
if result.failure?
- 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"