Showing 25 of 25 total issues
Method to_s
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def to_s
"every " + duration.parts.
reduce(::Hash.new(0)) { |h,(l,r)| h[l] += r; h }.
sort_by {|unit, _ | [:years, :months, :days, :minutes, :seconds].index(unit)}.
map {|unit, val| "#{val} #{val == 1 ? unit.to_s.chop : unit.to_s}" if val.nonzero?}.compact.
- 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 condition_intervals
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def condition_intervals(datetimes, &block)
return [] if datetimes.blank? || !block_given?
datetimes = datetimes.clone
current_datetime = first_datetime = datetimes.shift
last_datetime = 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_range
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def self.validate_range(first, last)
raise ArgumentError, 'Date range missing start date' if first.nil?
raise ArgumentError, 'Date range missing end date' if last.nil?
raise ArgumentError, 'Start date is not a date' unless first.is_a? Date
raise ArgumentError, 'End date is not a date' unless last.is_a? Date
- 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 to_s
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def to_s
str = start_date && end_date ? (start_date..end_date).to_date_range.to_s : (start_date || end_date).to_s
str += " on #{weekdays}" unless weekdays.all_days?
str
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 best_pattern
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def best_pattern(frequency_patterns)
best_fit = nil
frequency_patterns.each do |pattern_hash|
if best_fit.nil? ||
(best_fit[:intervals].count < pattern_hash[:intervals].count) ||
- 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"