armandofox/audience1st

View on GitHub
app/helpers/showdates_helper.rb

Summary

Maintainability
A
45 mins
Test Coverage
B
89%

Cyclomatic complexity for time_in_words_relative_to is too high. [7/6]
Open

  def time_in_words_relative_to(ed,sd)
    seconds_between = (ed - sd).abs
    if seconds_between < 1.hour
      "#{(seconds_between / 60).to_i} minutes %s performance starts" % ( ed > sd ? 'after' : 'before' )
    elsif (sd.month == ed.month) && (sd.day == ed.day) && (sd.year == ed.year)
Severity: Minor
Found in app/helpers/showdates_helper.rb by rubocop

This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

Cyclomatic complexity for showdate_type_choices is too high. [7/6]
Open

  def showdate_type_choices(show,new_showdate: nil)
    showdates = show.showdates
    options = []
    options.push(['In-theater',Showdate::IN_THEATER]) if new_showdate||showdates.any?(&:in_theater?)
    options.push(['Stream',Showdate::LIVE_STREAM]) if new_showdate||showdates.any?(&:live_stream?)
Severity: Minor
Found in app/helpers/showdates_helper.rb by rubocop

This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

Method time_in_words_relative_to has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def time_in_words_relative_to(ed,sd)
    seconds_between = (ed - sd).abs
    if seconds_between < 1.hour
      "#{(seconds_between / 60).to_i} minutes %s performance starts" % ( ed > sd ? 'after' : 'before' )
    elsif (sd.month == ed.month) && (sd.day == ed.day) && (sd.year == ed.year)
Severity: Minor
Found in app/helpers/showdates_helper.rb - About 45 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

Unused block argument - f. You can omit the argument if you don't care about it.
Open

      form_tag show_showdate_path(showdate.show, showdate), :method => :delete, :class => 'form form-inline' do |f|
Severity: Minor
Found in app/helpers/showdates_helper.rb by rubocop

This cop checks for unused block arguments.

Example:

# bad

do_something do |used, unused|
  puts used
end

do_something do |bar|
  puts :foo
end

define_method(:foo) do |bar|
  puts :baz
end

Example:

#good

do_something do |used, _unused|
  puts used
end

do_something do
  puts :foo
end

define_method(:foo) do |_bar|
  puts :baz
end

There are no issues that match your filters.

Category
Status