call4paperz/call4paperz

View on GitHub
app/controllers/application_controller.rb

Summary

Maintainability
A
0 mins
Test Coverage

Use a guard clause (return unless current_user.need_profile_completion? && !profile_completing?) instead of wrapping the code inside a conditional expression.
Open

    if current_user.need_profile_completion? && !profile_completing?

Use a guard clause instead of wrapping the code inside a conditional expression

Example:

# bad
def test
  if something
    work
  end
end

# good
def test
  return unless something
  work
end

# also good
def test
  work if something
end

# bad
if something
  raise 'exception'
else
  ok
end

# good
raise 'exception' if something
ok

Use 2 (not 3) spaces for indenting an expression spanning multiple lines.
Open

       (params['action'] == 'update' || params['action'] == 'edit')

This cop checks the indentation of the right hand side operand in binary operations that span more than one line.

Example: EnforcedStyle: aligned (default)

# bad
if a +
    b
  something
end

# good
if a +
   b
  something
end

Example: EnforcedStyle: indented

# bad
if a +
   b
  something
end

# good
if a +
    b
  something
end

Line is too long. [88/80]
Open

      redirect_to(edit_profile_path(current_user), notice: I18n.t('profile.completion'))

Indent access modifiers like protected.
Open

protected

Bare access modifiers (those not applying to specific methods) should be indented as deep as method definitions, or as deep as the class/module keyword, depending on configuration.

Example: EnforcedStyle: indent (default)

# bad
class Plumbus
private
  def smooth; end
end

# good
class Plumbus
  private
  def smooth; end
end

Example: EnforcedStyle: outdent

# bad
class Plumbus
  private
  def smooth; end
end

# good
class Plumbus
private
  def smooth; end
end

Indent access modifiers like private.
Open

private

Bare access modifiers (those not applying to specific methods) should be indented as deep as method definitions, or as deep as the class/module keyword, depending on configuration.

Example: EnforcedStyle: indent (default)

# bad
class Plumbus
private
  def smooth; end
end

# good
class Plumbus
  private
  def smooth; end
end

Example: EnforcedStyle: outdent

# bad
class Plumbus
  private
  def smooth; end
end

# good
class Plumbus
private
  def smooth; end
end

Keep a blank line before and after private.
Open

private

Access modifiers should be surrounded by blank lines.

Example: EnforcedStyle: around (default)

# bad
class Foo
  def bar; end
  private
  def baz; end
end

# good
class Foo
  def bar; end

  private

  def baz; end
end

Example: EnforcedStyle: only_before

# bad
class Foo
  def bar; end
  private
  def baz; end
end

# good
class Foo
  def bar; end

  private
  def baz; end
end

Don't use parentheses around the condition of an if.
Open

    if (request.get? && request.format.html? && !request.xhr? && !devise_controller?)

This cop checks for the presence of superfluous parentheses around the condition of if/unless/while/until.

Example:

# bad
x += 1 while (x < 10)
foo unless (bar || baz)

if (x > 10)
elsif (x < 3)
end

# good
x += 1 while x < 10
foo unless bar || baz

if x > 10
elsif x < 3
end

Example: AllowInMultilineConditions: false (default)

# bad
if (x > 10 &&
   y > 10)
end

# good
 if x > 10 &&
    y > 10
 end

Example: AllowInMultilineConditions: true

# good
if (x > 10 &&
   y > 10)
end

Missing top-level class documentation comment.
Open

class ApplicationController < ActionController::Base

This cop checks for missing top-level documentation of classes and modules. Classes with no body are exempt from the check and so are namespace modules - modules that have nothing in their bodies except classes, other modules, or constant definitions.

The documentation requirement is annulled if the class or module has a "#:nodoc:" comment next to it. Likewise, "#:nodoc: all" does the same for all its children.

Example:

# bad
class Person
  # ...
end

# good
# Description/Explanation of Person class
class Person
  # ...
end

Keep a blank line before and after protected.
Open

protected

Access modifiers should be surrounded by blank lines.

Example: EnforcedStyle: around (default)

# bad
class Foo
  def bar; end
  private
  def baz; end
end

# good
class Foo
  def bar; end

  private

  def baz; end
end

Example: EnforcedStyle: only_before

# bad
class Foo
  def bar; end
  private
  def baz; end
end

# good
class Foo
  def bar; end

  private
  def baz; end
end

Line is too long. [85/80]
Open

    if (request.get? && request.format.html? && !request.xhr? && !devise_controller?)

Missing magic comment # frozen_string_literal: true.
Open

require 'application_responder'

This cop is designed to help upgrade to after Ruby 3.0. It will add the comment # frozen_string_literal: true to the top of files to enable frozen string literals. Frozen string literals may be default after Ruby 3.0. The comment will be added below a shebang and encoding comment. The frozen string literal comment is only valid in Ruby 2.3+.

Example: EnforcedStyle: always (default)

# The `always` style will always add the frozen string literal comment
# to a file, regardless of the Ruby version or if `freeze` or `<<` are
# called on a string literal.
# bad
module Bar
  # ...
end

# good
# frozen_string_literal: true

module Bar
  # ...
end

Example: EnforcedStyle: never

# The `never` will enforce that the frozen string literal comment does
# not exist in a file.
# bad
# frozen_string_literal: true

module Baz
  # ...
end

# good
module Baz
  # ...
end

Use a guard clause (unless (request.get? && request.format.html? && !request.xhr? && !devise_controller?); return; end) instead of wrapping the code inside a conditional expression.
Open

    if (request.get? && request.format.html? && !request.xhr? && !devise_controller?)

Use a guard clause instead of wrapping the code inside a conditional expression

Example:

# bad
def test
  if something
    work
  end
end

# good
def test
  return unless something
  work
end

# also good
def test
  work if something
end

# bad
if something
  raise 'exception'
else
  ok
end

# good
raise 'exception' if something
ok

There are no issues that match your filters.

Category
Status