Showing 14 of 38 total issues
Method request_hash
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
def request_hash options
hash = {}
options[:keys] ||= []
value_options = CliMiami.get_options(options[:value_options] || {})
required_keys_set = false
- 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 request_multiple_choice
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
def request_multiple_choice options
selected_choices = nil
selected_choice_indexes = []
while selected_choice_indexes.length < options[:max]
- 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
Class Validation
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
class CliMiami::Validation
attr_reader :error, :valid, :value
# validates string provided by the user
#
Method request_multiple_choice
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
def request_multiple_choice options
selected_choices = nil
selected_choice_indexes = []
while selected_choice_indexes.length < options[:max]
Method get_options
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.get_options user_options = {}
# lookup preset if passed in as a symbol, or as a :preset key in an options hash
if user_options.is_a? Hash
user_options.deep_symbolize_keys!
options = @@presets[user_options.delete(:preset)] || {}
Method convert_type_to_string
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def convert_type_to_string value
case value
when Array
value.map do |e|
- 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 request_hash
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def request_hash options
hash = {}
options[:keys] ||= []
value_options = CliMiami.get_options(options[:value_options] || {})
required_keys_set = false
Method request_until_valid
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def request_until_valid options, allow_empty_string = false
response = nil
while response.nil?
# get user input based on given file type
- 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 request_range
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def request_range options
start_value = nil
end_value = nil
range_value_options = CliMiami.get_options type: :float
- 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 request_array
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def request_array options
array = []
value_options = CliMiami.get_options(options[:value_options] || {})
# build the array by prompting the user
- 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 get_options
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def self.get_options user_options = {}
# lookup preset if passed in as a symbol, or as a :preset key in an options hash
if user_options.is_a? Hash
user_options.deep_symbolize_keys!
options = @@presets[user_options.delete(:preset)] || {}
- 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
Avoid deeply nested control flow statements. Open
if options[:keys].include? user_key
# prevent deleting required keys
CliMiami::S.ay I18n.t('cli_miami.errors.multiple_choice.delete_required_key', key: user_key), :cli_miami_fail
redo
else
Method initialize
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def initialize initial_value, options
@options = CliMiami.get_options options
@value = initial_value
@valid = true
@error = nil
- 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 validate_hash
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def validate_hash hash, options
hash.deep_symbolize_keys!
validate_length hash, hash.keys.length, options
- 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"