Showing 16 of 44 total issues
Method process_token
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def process_token(tokens)
return '' if tokens.empty?
token = tokens.shift
- 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 url
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def url(*args, size: '300x300', format: 'png', bg_color: :random, text_color: :random, text: nil)
if args.any?
warn "Positional arguments for Image##{__method__} are deprecated. Please use keyword arguments."
size = args[0]
format = args[1] if args.size > 1
- 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 body
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def body
body = content_tag_for(:h1, words(2).capitalize)
rand(0..3).times do
body << content_tag_for(:p, fancy_string)
end
Method image
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def image(*args, slug: nil, size: '300x300', format: 'png', bgset: nil)
if args.any?
warn "Positional arguments for Avatar##{__method__} are deprecated. Please use keyword arguments."
slug = args[0]
size = args[1] if args.size > 1
- 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 file
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def file(*args, size: '300x300', format: 'png', bg_color: :random, text_color: :random, text: nil)
if args.any?
warn "Positional arguments for Image##{__method__} are deprecated. Please use keyword arguments."
size = args[0]
format = args[1] if args.size > 1
- 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 cover
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def cover(*args, slug: nil, size: '300x300', format: 'png', bgset: nil)
if args.any?
warn "Positional arguments for Book##{__method__} are deprecated. Please use keyword arguments."
slug = args[0]
size = args[1] if args.size > 1
- 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 check_passed_params
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def check_passed_params(size, format, bgset)
invalid_size_error unless size.match?(/^[0-9]+x[0-9]+$/)
invalid_format_error unless SUPPORTED_FORMATS.include?(format)
invalid_background_number unless bgset.nil? || (1..2).cover?(bgset.to_i)
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 raise_error_on_bad_arguments
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def raise_error_on_bad_arguments(from, to, gender)
raise ArgumentError, 'Invalid from argument: from' unless to.is_a? ::Time
raise ArgumentError, 'Invalid from argument: from' unless from.is_a? ::Time
raise ArgumentError, 'Invalid argument: from > to' if from > to
raise ArgumentError, 'Invalid argument: gender' unless GENDERS.include?(gender.to_s)
- 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 document_verification_digits
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def document_verification_digits(verification_multipliers, document = nil)
return false if document.nil?
document_digits = document.to_s.scan(/[0-9]/).map(&:to_i)
validation_digits = []
- 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 digits_sum
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def digits_sum(digits)
sum = 0
digits.chars.each_with_index do |char, index|
if index.even?
multiple = char.to_i * 2
- 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 file_name
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def file_name(
*args,
dir: directory, name: Lorem.word.downcase, ext: extension, directory_separator: File::SEPARATOR
)
if args.any?
- 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 select_sex
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def select_sex(sex) # :nodoc:
@fixed_sex ||= nil
given_sex = @fixed_sex || sex
raise ArgumentError, "Unknown sex #{given_sex}" unless GENDERS.include?(given_sex)
- 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 generate_range
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def generate_range(tokens)
result = []
while tokens.any?
token = tokens.shift
if token == DASH && tokens.first && result.last
- 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 npi
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def npi(legacy: false)
max = legacy ? 299_999_999 : 999_999_999
base_npi = rand(100_000_000..max).to_s
summed_digits = base_npi
- 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 first_name
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def first_name(gender = :any)
case gender
when :any then rand(0..1).zero? ? first_name(:male) : first_name(:female)
when :male then fetch_sample(MALE_FIRST_NAMES)
when :female then fetch_sample(FEMALE_FIRST_NAMES)
- 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 name
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def name(gender = :any)
case gender
when :any then rand(0..1).zero? ? name(:male) : name(:female)
when :male then fetch_sample(MALE_FIRST_NAMES)
when :female then fetch_sample(FEMALE_FIRST_NAMES)
- 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"