Method format_date
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def format_date(date, format=:short, include_time=true)
if date.present?
if date.is_a?(Integer) && date.to_s.length == 13
value = Time.at(date/1000)
else
- 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 format_time
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def format_time(date)
if date.present?
if date.is_a?(Integer) && date.to_s.length == 13
value = Time.at(date/1000)
else
- 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 formatted_time_ago
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def formatted_time_ago(date, options = {}, time_ago_options = {})
base_classes = "thread-updated-at updated-at"
options[:class] = options.key?(:class) ? "#{base_classes} #{options[:class]}" : base_classes
options[:title] = I18n.l(date, format: :long)
- 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 this_year?
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def this_year?(date)
if date.present?
if date.is_a?(Integer) && date.to_s.length == 13
Time.at(date/1000).year == Time.current.year
else
- 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"