app/helpers/slideshows_helper.rb

Summary

Maintainability
A
2 hrs
Test Coverage

Assignment Branch Condition size for show_slideshow_controls? is too high. [24.74/15]
Open

  def show_slideshow_controls?(current_url = request.url)
    # Walter McGinnis, 2008-08-12
    # putting in check whether there is only one result
    # navigable? checks if there is more than 0
    # i think we want more than 1
Severity: Minor
Found in app/helpers/slideshows_helper.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Assignment Branch Condition size for link_to_previous_in_slideshow is too high. [19.65/15]
Open

  def link_to_previous_in_slideshow(text = t('slideshows_helper.previous'), current_url = request.url)
    current_url = url_without_extras(current_url)
    return nil if slideshow.first_result?(current_url)

    if previous_result = slideshow.before(current_url)
Severity: Minor
Found in app/helpers/slideshows_helper.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Assignment Branch Condition size for link_to_next_in_slideshow is too high. [19.65/15]
Open

  def link_to_next_in_slideshow(text = t('slideshows_helper.next'), current_url = request.url)
    current_url = url_without_extras(current_url)
    return nil if slideshow.last_result?(current_url)

    if next_result = slideshow.after(current_url)
Severity: Minor
Found in app/helpers/slideshows_helper.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

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

  def show_slideshow_controls?(current_url = request.url)
    # Walter McGinnis, 2008-08-12
    # putting in check whether there is only one result
    # navigable? checks if there is more than 0
    # i think we want more than 1
Severity: Minor
Found in app/helpers/slideshows_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.

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  def link_to_previous_in_slideshow(text = t('slideshows_helper.previous'), current_url = request.url)
    current_url = url_without_extras(current_url)
    return nil if slideshow.first_result?(current_url)

    if previous_result = slideshow.before(current_url)
Severity: Major
Found in app/helpers/slideshows_helper.rb and 1 other location - About 1 hr to fix
app/helpers/slideshows_helper.rb on lines 5..17

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 54.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  def link_to_next_in_slideshow(text = t('slideshows_helper.next'), current_url = request.url)
    current_url = url_without_extras(current_url)
    return nil if slideshow.last_result?(current_url)

    if next_result = slideshow.after(current_url)
Severity: Major
Found in app/helpers/slideshows_helper.rb and 1 other location - About 1 hr to fix
app/helpers/slideshows_helper.rb on lines 21..32

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 54.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Avoid the use of Perl-style backrefs.
Open

    if url =~ /view_size=([a-z_]+)$/ && %w{small_sq medium small large}.member?($1)
Severity: Minor
Found in app/helpers/slideshows_helper.rb by rubocop

This cop looks for uses of Perl-style regexp match backreferences like $1, $2, etc.

Example:

# bad
puts $1

# good
puts Regexp.last_match(1)

Avoid the use of Perl-style backrefs.
Open

      slideshow.image_view_size = $1
Severity: Minor
Found in app/helpers/slideshows_helper.rb by rubocop

This cop looks for uses of Perl-style regexp match backreferences like $1, $2, etc.

Example:

# bad
puts $1

# good
puts Regexp.last_match(1)

Use == if you meant to do a comparison or wrap the expression in parentheses to indicate you meant to assign in a condition.
Open

    if next_result = slideshow.after(current_url)
Severity: Minor
Found in app/helpers/slideshows_helper.rb by rubocop

This cop checks for assignments in the conditions of if/while/until.

Example:

# bad

if some_var = true
  do_something
end

Example:

# good

if some_var == true
  do_something
end

%w-literals should be delimited by [ and ].
Open

    if url =~ /view_size=([a-z_]+)$/ && %w{small_sq medium small large}.member?($1)
Severity: Minor
Found in app/helpers/slideshows_helper.rb by rubocop

This cop enforces the consistent usage of %-literal delimiters.

Specify the 'default' key to set all preferred delimiters at once. You can continue to specify individual preferred delimiters to override the default.

Example:

# Style/PercentLiteralDelimiters:
#   PreferredDelimiters:
#     default: '[]'
#     '%i':    '()'

# good
%w[alpha beta] + %i(gamma delta)

# bad
%W(alpha #{beta})

# bad
%I(alpha beta)

Use the return of the conditional for variable assignment and comparison.
Open

    if url =~ /view_size=([a-z_]+)$/ && %w{small_sq medium small large}.member?($1)
      slideshow.image_view_size = $1
    else
      slideshow.image_view_size = nil
    end
Severity: Minor
Found in app/helpers/slideshows_helper.rb by rubocop

%w-literals should be delimited by [ and ].
Open

      %w(audio documents images topics video web_links).member?(params[:controller]) &&
Severity: Minor
Found in app/helpers/slideshows_helper.rb by rubocop

This cop enforces the consistent usage of %-literal delimiters.

Specify the 'default' key to set all preferred delimiters at once. You can continue to specify individual preferred delimiters to override the default.

Example:

# Style/PercentLiteralDelimiters:
#   PreferredDelimiters:
#     default: '[]'
#     '%i':    '()'

# good
%w[alpha beta] + %i(gamma delta)

# bad
%W(alpha #{beta})

# bad
%I(alpha beta)

Use == if you meant to do a comparison or wrap the expression in parentheses to indicate you meant to assign in a condition.
Open

    if previous_result = slideshow.before(current_url)
Severity: Minor
Found in app/helpers/slideshows_helper.rb by rubocop

This cop checks for assignments in the conditions of if/while/until.

Example:

# bad

if some_var = true
  do_something
end

Example:

# good

if some_var == true
  do_something
end

There are no issues that match your filters.

Category
Status