mconf/mconf-web

View on GitHub
app/helpers/dates_helper.rb

Summary

Maintainability
A
2 hrs
Test Coverage

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
Severity: Minor
Found in app/helpers/dates_helper.rb - About 55 mins to fix

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
Severity: Minor
Found in app/helpers/dates_helper.rb - About 25 mins to fix

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)

Severity: Minor
Found in app/helpers/dates_helper.rb - About 25 mins to fix

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
Severity: Minor
Found in app/helpers/dates_helper.rb - About 25 mins to fix

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

There are no issues that match your filters.

Category
Status