app/models/search_result_presenter.rb

Summary

Maintainability
A
0 mins
Test Coverage

Literal :thumbnail_file appeared as a condition.
Open

    model.respond_to? :thumbnail_file ? model.thumbnail_file : ''

This cop checks for literals used as the conditions or as operands in and/or expressions serving as the conditions of if/while/until.

Example:

# bad

if 20
  do_something
end

Example:

# bad

if some_var && true
  do_something
end

Example:

# good

if some_var && some_condition
  do_something
end

Literal :locally_hosted appeared as a condition.
Open

    model.respond_to? :locally_hosted ? model.locally_hosted : ''

This cop checks for literals used as the conditions or as operands in and/or expressions serving as the conditions of if/while/until.

Example:

# bad

if 20
  do_something
end

Example:

# bad

if some_var && true
  do_something
end

Example:

# good

if some_var && some_condition
  do_something
end

Literal :dc_dates appeared as a condition.
Open

    model.respond_to? :dc_dates ? model.dc_dates : ''

This cop checks for literals used as the conditions or as operands in and/or expressions serving as the conditions of if/while/until.

Example:

# bad

if 20
  do_something
end

Example:

# bad

if some_var && true
  do_something
end

Example:

# good

if some_var && some_condition
  do_something
end

Literal :thumbnail appeared as a condition.
Open

    model.respond_to? :thumbnail ? model.thumbnail : ''

This cop checks for literals used as the conditions or as operands in and/or expressions serving as the conditions of if/while/until.

Example:

# bad

if 20
  do_something
end

Example:

# bad

if some_var && true
  do_something
end

Example:

# good

if some_var && some_condition
  do_something
end

Use models.count.positive? instead of models.count > 0.
Open

      models.count > 0 ? "#{models.count} #{content_type.to_s.humanize}" : nil

This cop checks for usage of comparison operators (==, >, <) to test numbers as zero, positive, or negative. These can be replaced by their respective predicate methods. The cop can also be configured to do the reverse.

The cop disregards #nonzero? as it its value is truthy or falsey, but not true and false, and thus not always interchangeable with != 0.

The cop ignores comparisons to global variables, since they are often populated with objects which can be compared with integers, but are not themselves Interger polymorphic.

Example: EnforcedStyle: predicate (default)

# bad

foo == 0
0 > foo
bar.baz > 0

# good

foo.zero?
foo.negative?
bar.baz.positive?

Example: EnforcedStyle: comparison

# bad

foo.zero?
foo.negative?
bar.baz.positive?

# good

foo == 0
0 > foo
bar.baz > 0

Literal :id appeared as a condition.
Open

    model.respond_to? :id ? model.id : ''

This cop checks for literals used as the conditions or as operands in and/or expressions serving as the conditions of if/while/until.

Example:

# bad

if 20
  do_something
end

Example:

# bad

if some_var && true
  do_something
end

Example:

# good

if some_var && some_condition
  do_something
end

Literal :title appeared as a condition.
Open

    model.respond_to? :title ? model.title : ''

This cop checks for literals used as the conditions or as operands in and/or expressions serving as the conditions of if/while/until.

Example:

# bad

if 20
  do_something
end

Example:

# bad

if some_var && true
  do_something
end

Example:

# good

if some_var && some_condition
  do_something
end

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

    if model.class == PgSearch::Document
      # all/for searches
      @model = model.searchable
    elsif model.class == ContentItemRelation
      # related_to searches

Literal :topic_types appeared as a condition.
Open

    model.respond_to? :topic_types ? model.topic_types : []

This cop checks for literals used as the conditions or as operands in and/or expressions serving as the conditions of if/while/until.

Example:

# bad

if 20
  do_something
end

Example:

# bad

if some_var && true
  do_something
end

Example:

# good

if some_var && some_condition
  do_something
end

Rename has_related_items? to related_items?.
Open

  def has_related_items?

This cop makes sure that predicates are named properly.

Example:

# bad
def is_even?(value)
end

# good
def even?(value)
end

# bad
def has_value?
end

# good
def value?
end

Literal :class appeared as a condition.
Open

    model.respond_to? :class ? model.class : ''

This cop checks for literals used as the conditions or as operands in and/or expressions serving as the conditions of if/while/until.

Example:

# bad

if 20
  do_something
end

Example:

# bad

if some_var && true
  do_something
end

Example:

# good

if some_var && some_condition
  do_something
end

There are no issues that match your filters.

Category
Status