fga-gpp-mds/2017.1-Escola-X

View on GitHub
app/helpers/sessions_helper.rb

Summary

Maintainability
A
0 mins
Test Coverage

Module has too many lines. [111/100]
Open

module SessionsHelper
  def current_user
    if ( !@current_user.nil? )
      @current_user = @current_user
    else
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

This cop checks if the length a module exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Assignment Branch Condition size for current_user is too high. [18.17/15]
Open

  def current_user
    if ( !@current_user.nil? )
      @current_user = @current_user
    else
      if ( !(@current_user = Employee.find_by_authorization_token(cookies[:authorization_token])).nil? )
Severity: Minor
Found in app/helpers/sessions_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

Method has too many lines. [13/10]
Open

  def current_user
    if ( !@current_user.nil? )
      @current_user = @current_user
    else
      if ( !(@current_user = Employee.find_by_authorization_token(cookies[:authorization_token])).nil? )
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Cyclomatic complexity for current_user is too high. [5/3]
Open

  def current_user
    if ( !@current_user.nil? )
      @current_user = @current_user
    else
      if ( !(@current_user = Employee.find_by_authorization_token(cookies[:authorization_token])).nil? )
Severity: Minor
Found in app/helpers/sessions_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.

SessionsHelper#current_user calls 'cookies[:authorization_token]' 3 times
Open

      if ( !(@current_user = Employee.find_by_authorization_token(cookies[:authorization_token])).nil? )
        return @current_user
      elsif ( !(@current_user = Parent.find_by_authorization_token(cookies[:authorization_token])).nil? )
          return @current_user
      elsif ( !(@current_user = Alumn.find_by_authorization_token(cookies[:authorization_token])).nil? )
Severity: Minor
Found in app/helpers/sessions_helper.rb by reek

Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

Reek implements a check for Duplicate Method Call.

Example

Here's a very much simplified and contrived example. The following method will report a warning:

def double_thing()
  @other.thing + @other.thing
end

One quick approach to silence Reek would be to refactor the code thus:

def double_thing()
  thing = @other.thing
  thing + thing
end

A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

class Other
  def double_thing()
    thing + thing
  end
end

The approach you take will depend on balancing other factors in your code.

SessionsHelper#logged_in? calls 'current_user.nil?' 2 times
Open

    if ( current_user.nil? )
      raise 'Not logged in'
    else
      !(current_user.nil?)
Severity: Minor
Found in app/helpers/sessions_helper.rb by reek

Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

Reek implements a check for Duplicate Method Call.

Example

Here's a very much simplified and contrived example. The following method will report a warning:

def double_thing()
  @other.thing + @other.thing
end

One quick approach to silence Reek would be to refactor the code thus:

def double_thing()
  thing = @other.thing
  thing + thing
end

A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

class Other
  def double_thing()
    thing + thing
  end
end

The approach you take will depend on balancing other factors in your code.

SessionsHelper#logged_in? performs a nil-check
Open

    if ( current_user.nil? )
      raise 'Not logged in'
    else
      !(current_user.nil?)
Severity: Minor
Found in app/helpers/sessions_helper.rb by reek

A NilCheck is a type check. Failures of NilCheck violate the "tell, don't ask" principle.

Additionally, type checks often mask bigger problems in your source code like not using OOP and / or polymorphism when you should.

Example

Given

class Klass
  def nil_checker(argument)
    if argument.nil?
      puts "argument isn't nil!"
    end
  end
end

Reek would emit the following warning:

test.rb -- 1 warning:
  [3]:Klass#nil_checker performs a nil-check. (NilCheck)

SessionsHelper#current_user performs a nil-check
Open

    if ( !@current_user.nil? )
      @current_user = @current_user
    else
      if ( !(@current_user = Employee.find_by_authorization_token(cookies[:authorization_token])).nil? )
        return @current_user
Severity: Minor
Found in app/helpers/sessions_helper.rb by reek

A NilCheck is a type check. Failures of NilCheck violate the "tell, don't ask" principle.

Additionally, type checks often mask bigger problems in your source code like not using OOP and / or polymorphism when you should.

Example

Given

class Klass
  def nil_checker(argument)
    if argument.nil?
      puts "argument isn't nil!"
    end
  end
end

Reek would emit the following warning:

test.rb -- 1 warning:
  [3]:Klass#nil_checker performs a nil-check. (NilCheck)

Extra blank line detected.
Open


  def verify_parent(id)
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

This cops checks for two or more consecutive blank lines.

Example:

# bad - It has two empty lines.
some_method
# one empty line
# two empty lines
some_method

# good
some_method
# one empty line
some_method

Line is too long. [105/80]
Open

      elsif ( !(@current_user = Parent.find_by_authorization_token(cookies[:authorization_token])).nil? )
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

Rename is_alumn? to alumn?.
Open

  def is_alumn?
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

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

Redundant else-clause.
Open

    else
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

Checks for empty else-clauses, possibly including comments and/or an explicit nil depending on the EnforcedStyle.

Example: EnforcedStyle: empty

# warn only on empty else

# bad
if condition
  statement
else
end

# good
if condition
  statement
else
  nil
end

# good
if condition
  statement
else
  statement
end

# good
if condition
  statement
end

Example: EnforcedStyle: nil

# warn on else with nil in it

# bad
if condition
  statement
else
  nil
end

# good
if condition
  statement
else
end

# good
if condition
  statement
else
  statement
end

# good
if condition
  statement
end

Example: EnforcedStyle: both (default)

# warn on empty else and else with nil in it

# bad
if condition
  statement
else
  nil
end

# bad
if condition
  statement
else
end

# good
if condition
  statement
else
  statement
end

# good
if condition
  statement
end

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

    if ( alumn.parent_id == current_user.id and current_user.is_a?(Parent))
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

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

Don't use parentheses around a method call.
Open

    if ( (logged_in?) and (current_user.is_a?(Principal)) )
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

This cop checks for redundant parentheses.

Example:

# bad
(x) if ((y.z).nil?)

# good
x if y.z.nil?

Redundant return detected.
Open

        return @current_user
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

This cop checks for redundant return expressions.

Example:

def test
  return something
end

def test
  one
  two
  three
  return something
end

It should be extended to handle methods whose body is if/else or a case expression with a default branch.

Redundant return detected.
Open

      return false
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

This cop checks for redundant return expressions.

Example:

def test
  return something
end

def test
  one
  two
  three
  return something
end

It should be extended to handle methods whose body is if/else or a case expression with a default branch.

Redundant return detected.
Open

      return true
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

This cop checks for redundant return expressions.

Example:

def test
  return something
end

def test
  one
  two
  three
  return something
end

It should be extended to handle methods whose body is if/else or a case expression with a default branch.

Redundant return detected.
Open

      return false
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

This cop checks for redundant return expressions.

Example:

def test
  return something
end

def test
  one
  two
  three
  return something
end

It should be extended to handle methods whose body is if/else or a case expression with a default branch.

Space inside parentheses detected.
Open

      elsif ( !(@current_user = Parent.find_by_authorization_token(cookies[:authorization_token])).nil? )
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

Checks for spaces inside ordinary round parentheses.

Example:

# bad
f( 3)
g = (a + 3 )

# good
f(3)
g = (a + 3)

Space inside parentheses detected.
Open

    if ( (logged_in?) and (current_user.is_a?(Secretary)))
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

Checks for spaces inside ordinary round parentheses.

Example:

# bad
f( 3)
g = (a + 3 )

# good
f(3)
g = (a + 3)

Space inside parentheses detected.
Open

    return ( is_principal? or is_secretary? or is_teacher? )
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

Checks for spaces inside ordinary round parentheses.

Example:

# bad
f( 3)
g = (a + 3 )

# good
f(3)
g = (a + 3)

Space inside parentheses detected.
Open

    return ( is_principal? or is_secretary? or is_teacher? )
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

Checks for spaces inside ordinary round parentheses.

Example:

# bad
f( 3)
g = (a + 3 )

# good
f(3)
g = (a + 3)

Extra blank line detected.
Open


  def is_son?(id)
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

This cops checks for two or more consecutive blank lines.

Example:

# bad - It has two empty lines.
some_method
# one empty line
# two empty lines
some_method

# good
some_method
# one empty line
some_method

Space inside parentheses detected.
Open

    if ( alumn.id == current_user.id and current_user.is_a?(Alumn))
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

Checks for spaces inside ordinary round parentheses.

Example:

# bad
f( 3)
g = (a + 3 )

# good
f(3)
g = (a + 3)

Space inside parentheses detected.
Open

    if ( (logged_in?) and (current_user.is_a?(Alumn)) )
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

Checks for spaces inside ordinary round parentheses.

Example:

# bad
f( 3)
g = (a + 3 )

# good
f(3)
g = (a + 3)

Use && instead of and.
Open

    if ( (logged_in?) and (current_user.is_a?(Alumn)) )
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

This cop checks for uses of and and or, and suggests using && and || instead. It can be configured to check only in conditions, or in all contexts.

Example: EnforcedStyle: always (default)

# bad
foo.save and return

# bad
if foo and bar
end

# good
foo.save && return

# good
if foo && bar
end

Example: EnforcedStyle: conditionals

# bad
if foo and bar
end

# good
foo.save && return

# good
foo.save and return

# good
if foo && bar
end

Don't use parentheses around a method call.
Open

    if ( (logged_in?) and (current_user.is_a?(Alumn)) )
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

This cop checks for redundant parentheses.

Example:

# bad
(x) if ((y.z).nil?)

# good
x if y.z.nil?

Rename is_parent_related_to_alumn? to parent_related_to_alumn?.
Open

  def is_parent_related_to_alumn?(alumn)
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

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

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

    if ( alumn.id == current_user.id and current_user.is_a?(Alumn))
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

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

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

      elsif ( !(@current_user = Alumn.find_by_authorization_token(cookies[:authorization_token])).nil? )
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

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

Don't use parentheses around a method call.
Open

    if ( (logged_in?) and (current_user.is_a?(Alumn)) )
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

This cop checks for redundant parentheses.

Example:

# bad
(x) if ((y.z).nil?)

# good
x if y.z.nil?

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

        if (alumn == Alumn.find_by_id(id))
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

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

Redundant return detected.
Open

      return false
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

This cop checks for redundant return expressions.

Example:

def test
  return something
end

def test
  one
  two
  three
  return something
end

It should be extended to handle methods whose body is if/else or a case expression with a default branch.

Don't use parentheses around an unary operation.
Open

      elsif ( !(@current_user = Parent.find_by_authorization_token(cookies[:authorization_token])).nil? )
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

This cop checks for redundant parentheses.

Example:

# bad
(x) if ((y.z).nil?)

# good
x if y.z.nil?

Redundant return detected.
Open

        return @current_user
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

This cop checks for redundant return expressions.

Example:

def test
  return something
end

def test
  one
  two
  three
  return something
end

It should be extended to handle methods whose body is if/else or a case expression with a default branch.

Redundant return detected.
Open

      return false
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

This cop checks for redundant return expressions.

Example:

def test
  return something
end

def test
  one
  two
  three
  return something
end

It should be extended to handle methods whose body is if/else or a case expression with a default branch.

Use 2 (not 4) spaces for indentation.
Open

          return @current_user
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

This cops checks for indentation that doesn't use the specified number of spaces.

See also the IndentationConsistency cop which is the companion to this one.

Example:

# bad
class A
 def test
  puts 'hello'
 end
end

# good
class A
  def test
    puts 'hello'
  end
end

Example: IgnoredPatterns: ['^\s*module']

# bad
module A
class B
  def test
  puts 'hello'
  end
end
end

# good
module A
class B
  def test
    puts 'hello'
  end
end
end

Space inside parentheses detected.
Open

    if ( (logged_in?) and (current_user.is_a?(Parent)))
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

Checks for spaces inside ordinary round parentheses.

Example:

# bad
f( 3)
g = (a + 3 )

# good
f(3)
g = (a + 3)

Use && instead of and.
Open

    if ( (logged_in?) and (current_user.is_a?(Teacher)))
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

This cop checks for uses of and and or, and suggests using && and || instead. It can be configured to check only in conditions, or in all contexts.

Example: EnforcedStyle: always (default)

# bad
foo.save and return

# bad
if foo and bar
end

# good
foo.save && return

# good
if foo && bar
end

Example: EnforcedStyle: conditionals

# bad
if foo and bar
end

# good
foo.save && return

# good
foo.save and return

# good
if foo && bar
end

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

      if ( !(@current_user = Employee.find_by_authorization_token(cookies[:authorization_token])).nil? )
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

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

Use empty lines between method definitions.
Open

  def is_son?(id)
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

This cop checks whether method definitions are separated by one empty line.

NumberOfEmptyLines can be and integer (e.g. 1 by default) or an array (e.g. [1, 2]) to specificy a minimum and a maximum of empty lines.

AllowAdjacentOneLineDefs can be used to configure is adjacent one line methods definitions are an offense

Example:

# bad
def a
end
def b
end

Example:

# good
def a
end

def b
end

Use empty lines between method definitions.
Open

  def verify_alumn(id)
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

This cop checks whether method definitions are separated by one empty line.

NumberOfEmptyLines can be and integer (e.g. 1 by default) or an array (e.g. [1, 2]) to specificy a minimum and a maximum of empty lines.

AllowAdjacentOneLineDefs can be used to configure is adjacent one line methods definitions are an offense

Example:

# bad
def a
end
def b
end

Example:

# good
def a
end

def b
end

Line is too long. [104/80]
Open

      if ( !(@current_user = Employee.find_by_authorization_token(cookies[:authorization_token])).nil? )
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

Rename is_principal? to principal?.
Open

  def is_principal?
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

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

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

    if ( (logged_in?) and (current_user.is_a?(Teacher)))
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

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

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

    if ( (logged_in?) and (current_user.is_a?(Principal)) )
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

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

Redundant return detected.
Open

    return found
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

This cop checks for redundant return expressions.

Example:

def test
  return something
end

def test
  one
  two
  three
  return something
end

It should be extended to handle methods whose body is if/else or a case expression with a default branch.

Rename is_employee? to employee?.
Open

  def is_employee?
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

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

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

    if ( (logged_in?) and (current_user.is_a?(Alumn)) )
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

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

Don't use parentheses around an unary operation.
Open

      if ( !(@current_user = Employee.find_by_authorization_token(cookies[:authorization_token])).nil? )
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

This cop checks for redundant parentheses.

Example:

# bad
(x) if ((y.z).nil?)

# good
x if y.z.nil?

Don't use parentheses around a method call.
Open

    if ( (logged_in?) and (current_user.is_a?(Principal)) )
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

This cop checks for redundant parentheses.

Example:

# bad
(x) if ((y.z).nil?)

# good
x if y.z.nil?

Don't use parentheses around a method call.
Open

    if ( (logged_in?) and (current_user.is_a?(Parent)))
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

This cop checks for redundant parentheses.

Example:

# bad
(x) if ((y.z).nil?)

# good
x if y.z.nil?

Redundant return detected.
Open

      return true
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

This cop checks for redundant return expressions.

Example:

def test
  return something
end

def test
  one
  two
  three
  return something
end

It should be extended to handle methods whose body is if/else or a case expression with a default branch.

Redundant return detected.
Open

      return true
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

This cop checks for redundant return expressions.

Example:

def test
  return something
end

def test
  one
  two
  three
  return something
end

It should be extended to handle methods whose body is if/else or a case expression with a default branch.

Use empty lines between method definitions.
Open

  def verify_parent(id)
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

This cop checks whether method definitions are separated by one empty line.

NumberOfEmptyLines can be and integer (e.g. 1 by default) or an array (e.g. [1, 2]) to specificy a minimum and a maximum of empty lines.

AllowAdjacentOneLineDefs can be used to configure is adjacent one line methods definitions are an offense

Example:

# bad
def a
end
def b
end

Example:

# good
def a
end

def b
end

Space inside parentheses detected.
Open

      if ( !(@current_user = Employee.find_by_authorization_token(cookies[:authorization_token])).nil? )
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

Checks for spaces inside ordinary round parentheses.

Example:

# bad
f( 3)
g = (a + 3 )

# good
f(3)
g = (a + 3)

Space inside parentheses detected.
Open

      if ( !(@current_user = Employee.find_by_authorization_token(cookies[:authorization_token])).nil? )
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

Checks for spaces inside ordinary round parentheses.

Example:

# bad
f( 3)
g = (a + 3 )

# good
f(3)
g = (a + 3)

Space inside parentheses detected.
Open

    if ( (logged_in?) and (current_user.is_a?(Alumn)) )
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

Checks for spaces inside ordinary round parentheses.

Example:

# bad
f( 3)
g = (a + 3 )

# good
f(3)
g = (a + 3)

Rename is_son? to son?.
Open

  def is_son?(id)
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

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

Redundant else-clause.
Open

    else
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

Checks for empty else-clauses, possibly including comments and/or an explicit nil depending on the EnforcedStyle.

Example: EnforcedStyle: empty

# warn only on empty else

# bad
if condition
  statement
else
end

# good
if condition
  statement
else
  nil
end

# good
if condition
  statement
else
  statement
end

# good
if condition
  statement
end

Example: EnforcedStyle: nil

# warn on else with nil in it

# bad
if condition
  statement
else
  nil
end

# good
if condition
  statement
else
end

# good
if condition
  statement
else
  statement
end

# good
if condition
  statement
end

Example: EnforcedStyle: both (default)

# warn on empty else and else with nil in it

# bad
if condition
  statement
else
  nil
end

# bad
if condition
  statement
else
end

# good
if condition
  statement
else
  statement
end

# good
if condition
  statement
end

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

    if ( (logged_in?) and (current_user.is_a?(Principal)) )
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

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

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

    if ( (logged_in?) and (current_user.is_a?(Alumn)) )
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

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

Don't use parentheses around a method call.
Open

    if ( current_user.nil? )
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

This cop checks for redundant parentheses.

Example:

# bad
(x) if ((y.z).nil?)

# good
x if y.z.nil?

Space inside parentheses detected.
Open

    if ( (logged_in?) and (current_user.is_a?(Teacher)))
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

Checks for spaces inside ordinary round parentheses.

Example:

# bad
f( 3)
g = (a + 3 )

# good
f(3)
g = (a + 3)

Rename is_teacher? to teacher?.
Open

  def is_teacher?
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

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

Space inside parentheses detected.
Open

    if ( (logged_in?) and (current_user.is_a?(Principal)) )
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

Checks for spaces inside ordinary round parentheses.

Example:

# bad
f( 3)
g = (a + 3 )

# good
f(3)
g = (a + 3)

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

    if ( current_user.nil? )
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

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

Line is too long. [104/80]
Open

      elsif ( !(@current_user = Alumn.find_by_authorization_token(cookies[:authorization_token])).nil? )
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

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

    if ( (logged_in?) and (current_user.is_a?(Parent)))
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

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

Redundant return detected.
Open

      return true
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

This cop checks for redundant return expressions.

Example:

def test
  return something
end

def test
  one
  two
  three
  return something
end

It should be extended to handle methods whose body is if/else or a case expression with a default branch.

Rename is_me? to me?.
Open

  def is_me?(alumn)
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

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

Use && instead of and.
Open

    if ( (logged_in?) and (current_user.is_a?(Parent)))
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

This cop checks for uses of and and or, and suggests using && and || instead. It can be configured to check only in conditions, or in all contexts.

Example: EnforcedStyle: always (default)

# bad
foo.save and return

# bad
if foo and bar
end

# good
foo.save && return

# good
if foo && bar
end

Example: EnforcedStyle: conditionals

# bad
if foo and bar
end

# good
foo.save && return

# good
foo.save and return

# good
if foo && bar
end

Redundant return detected.
Open

    return found
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

This cop checks for redundant return expressions.

Example:

def test
  return something
end

def test
  one
  two
  three
  return something
end

It should be extended to handle methods whose body is if/else or a case expression with a default branch.

Use && instead of and.
Open

    if ( alumn.parent_id == current_user.id and current_user.is_a?(Parent))
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

This cop checks for uses of and and or, and suggests using && and || instead. It can be configured to check only in conditions, or in all contexts.

Example: EnforcedStyle: always (default)

# bad
foo.save and return

# bad
if foo and bar
end

# good
foo.save && return

# good
if foo && bar
end

Example: EnforcedStyle: conditionals

# bad
if foo and bar
end

# good
foo.save && return

# good
foo.save and return

# good
if foo && bar
end

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

      if ( !(@current_user = Employee.find_by_authorization_token(cookies[:authorization_token])).nil? )
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

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 a guard clause instead of wrapping the code inside a conditional expression.
Open

    if ( alumn.id == current_user.id and current_user.is_a?(Alumn))
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

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

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

    if ( current_user.nil? )
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

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

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

    if ( (logged_in?) and (current_user.is_a?(Secretary)))
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

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

Don't use parentheses around a method call.
Open

    if ( (logged_in?) and (current_user.is_a?(Parent)))
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

This cop checks for redundant parentheses.

Example:

# bad
(x) if ((y.z).nil?)

# good
x if y.z.nil?

Redundant return detected.
Open

      return false
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

This cop checks for redundant return expressions.

Example:

def test
  return something
end

def test
  one
  two
  three
  return something
end

It should be extended to handle methods whose body is if/else or a case expression with a default branch.

Extra blank line detected.
Open


  def verify_alumn(id)
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

This cops checks for two or more consecutive blank lines.

Example:

# bad - It has two empty lines.
some_method
# one empty line
# two empty lines
some_method

# good
some_method
# one empty line
some_method

Space inside parentheses detected.
Open

    if ( !@current_user.nil? )
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

Checks for spaces inside ordinary round parentheses.

Example:

# bad
f( 3)
g = (a + 3 )

# good
f(3)
g = (a + 3)

Favor modifier if usage when having a single-line body. Another good alternative is the usage of control flow &&/||.
Open

        if (alumn == Alumn.find_by_id(id))
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

Checks for if and unless statements that would fit on one line if written as a modifier if/unless. The maximum line length is configured in the Metrics/LineLength cop.

Example:

# bad
if condition
  do_stuff(bar)
end

unless qux.empty?
  Foo.do_something
end

# good
do_stuff(bar) if condition
Foo.do_something unless qux.empty?

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

    if ( (logged_in?) and (current_user.is_a?(Teacher)))
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

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

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

    if ( alumn.parent_id == current_user.id and current_user.is_a?(Parent))
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

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

Don't use parentheses around an unary operation.
Open

    if ( !@current_user.nil? )
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

This cop checks for redundant parentheses.

Example:

# bad
(x) if ((y.z).nil?)

# good
x if y.z.nil?

Don't use parentheses around a method call.
Open

    if ( (logged_in?) and (current_user.is_a?(Teacher)))
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

This cop checks for redundant parentheses.

Example:

# bad
(x) if ((y.z).nil?)

# good
x if y.z.nil?

Don't use parentheses around a method call.
Open

    if ( (logged_in?) and (current_user.is_a?(Teacher)))
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

This cop checks for redundant parentheses.

Example:

# bad
(x) if ((y.z).nil?)

# good
x if y.z.nil?

Don't use parentheses around a method call.
Open

    if ( (logged_in?) and (current_user.is_a?(Secretary)))
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

This cop checks for redundant parentheses.

Example:

# bad
(x) if ((y.z).nil?)

# good
x if y.z.nil?

Redundant return detected.
Open

      return true
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

This cop checks for redundant return expressions.

Example:

def test
  return something
end

def test
  one
  two
  three
  return something
end

It should be extended to handle methods whose body is if/else or a case expression with a default branch.

Redundant return detected.
Open

      return false
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

This cop checks for redundant return expressions.

Example:

def test
  return something
end

def test
  one
  two
  three
  return something
end

It should be extended to handle methods whose body is if/else or a case expression with a default branch.

Extra empty line detected at module body end.
Open


end
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

This cops checks if empty lines around the bodies of modules match the configuration.

Example: EnforcedStyle: empty_lines

# good

module Foo

  def bar
    # ...
  end

end

Example: EnforcedStyle: emptylinesexcept_namespace

# good

module Foo
  module Bar

    # ...

  end
end

Example: EnforcedStyle: emptylinesspecial

# good
module Foo

  def bar; end

end

Example: EnforcedStyle: noemptylines (default)

# good

module Foo
  def bar
    # ...
  end
end

Space inside parentheses detected.
Open

    if ( current_user.nil? )
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

Checks for spaces inside ordinary round parentheses.

Example:

# bad
f( 3)
g = (a + 3 )

# good
f(3)
g = (a + 3)

Space inside parentheses detected.
Open

    if ( (logged_in?) and (current_user.is_a?(Principal)) )
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

Checks for spaces inside ordinary round parentheses.

Example:

# bad
f( 3)
g = (a + 3 )

# good
f(3)
g = (a + 3)

Use && instead of and.
Open

    if ( (logged_in?) and (current_user.is_a?(Principal)) )
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

This cop checks for uses of and and or, and suggests using && and || instead. It can be configured to check only in conditions, or in all contexts.

Example: EnforcedStyle: always (default)

# bad
foo.save and return

# bad
if foo and bar
end

# good
foo.save && return

# good
if foo && bar
end

Example: EnforcedStyle: conditionals

# bad
if foo and bar
end

# good
foo.save && return

# good
foo.save and return

# good
if foo && bar
end

Use || instead of or.
Open

    return ( is_principal? or is_secretary? or is_teacher? )
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

This cop checks for uses of and and or, and suggests using && and || instead. It can be configured to check only in conditions, or in all contexts.

Example: EnforcedStyle: always (default)

# bad
foo.save and return

# bad
if foo and bar
end

# good
foo.save && return

# good
if foo && bar
end

Example: EnforcedStyle: conditionals

# bad
if foo and bar
end

# good
foo.save && return

# good
foo.save and return

# good
if foo && bar
end

Redundant return detected.
Open

    return found
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

This cop checks for redundant return expressions.

Example:

def test
  return something
end

def test
  one
  two
  three
  return something
end

It should be extended to handle methods whose body is if/else or a case expression with a default branch.

Space inside parentheses detected.
Open

    if ( !@current_user.nil? )
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

Checks for spaces inside ordinary round parentheses.

Example:

# bad
f( 3)
g = (a + 3 )

# good
f(3)
g = (a + 3)

Space inside parentheses detected.
Open

      elsif ( !(@current_user = Parent.find_by_authorization_token(cookies[:authorization_token])).nil? )
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

Checks for spaces inside ordinary round parentheses.

Example:

# bad
f( 3)
g = (a + 3 )

# good
f(3)
g = (a + 3)

Rename is_parent? to parent?.
Open

  def is_parent?
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

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

Rename is_secretary? to secretary?.
Open

  def is_secretary?
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

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

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

      elsif ( !(@current_user = Parent.find_by_authorization_token(cookies[:authorization_token])).nil? )
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

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

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

    if ( (logged_in?) and (current_user.is_a?(Parent)))
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

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

Don't use parentheses around an unary operation.
Open

      elsif ( !(@current_user = Alumn.find_by_authorization_token(cookies[:authorization_token])).nil? )
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

This cop checks for redundant parentheses.

Example:

# bad
(x) if ((y.z).nil?)

# good
x if y.z.nil?

Extra empty line detected at method body beginning.
Open


    found = false
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

This cops checks if empty lines exist around the bodies of methods.

Example:

# good

def foo
  # ...
end

# bad

def bar

  # ...

end

Redundant return detected.
Open

      return true
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

This cop checks for redundant return expressions.

Example:

def test
  return something
end

def test
  one
  two
  three
  return something
end

It should be extended to handle methods whose body is if/else or a case expression with a default branch.

Extra empty line detected at method body beginning.
Open


    found = false
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

This cops checks if empty lines exist around the bodies of methods.

Example:

# good

def foo
  # ...
end

# bad

def bar

  # ...

end

Redundant return detected.
Open

    return found
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

This cop checks for redundant return expressions.

Example:

def test
  return something
end

def test
  one
  two
  three
  return something
end

It should be extended to handle methods whose body is if/else or a case expression with a default branch.

Space inside parentheses detected.
Open

      elsif ( !(@current_user = Alumn.find_by_authorization_token(cookies[:authorization_token])).nil? )
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

Checks for spaces inside ordinary round parentheses.

Example:

# bad
f( 3)
g = (a + 3 )

# good
f(3)
g = (a + 3)

Space inside parentheses detected.
Open

    if ( current_user.nil? )
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

Checks for spaces inside ordinary round parentheses.

Example:

# bad
f( 3)
g = (a + 3 )

# good
f(3)
g = (a + 3)

Space inside parentheses detected.
Open

    if ( alumn.parent_id == current_user.id and current_user.is_a?(Parent))
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

Checks for spaces inside ordinary round parentheses.

Example:

# bad
f( 3)
g = (a + 3 )

# good
f(3)
g = (a + 3)

Use || instead of or.
Open

    return ( is_principal? or is_secretary? or is_teacher? )
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

This cop checks for uses of and and or, and suggests using && and || instead. It can be configured to check only in conditions, or in all contexts.

Example: EnforcedStyle: always (default)

# bad
foo.save and return

# bad
if foo and bar
end

# good
foo.save && return

# good
if foo && bar
end

Example: EnforcedStyle: conditionals

# bad
if foo and bar
end

# good
foo.save && return

# good
foo.save and return

# good
if foo && bar
end

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

    if ( (logged_in?) and (current_user.is_a?(Secretary)))
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

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

Extra blank line detected.
Open



Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

This cops checks for two or more consecutive blank lines.

Example:

# bad - It has two empty lines.
some_method
# one empty line
# two empty lines
some_method

# good
some_method
# one empty line
some_method

Redundant return detected.
Open

      return false
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

This cop checks for redundant return expressions.

Example:

def test
  return something
end

def test
  one
  two
  three
  return something
end

It should be extended to handle methods whose body is if/else or a case expression with a default branch.

Use && instead of and.
Open

    if ( (logged_in?) and (current_user.is_a?(Secretary)))
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

This cop checks for uses of and and or, and suggests using && and || instead. It can be configured to check only in conditions, or in all contexts.

Example: EnforcedStyle: always (default)

# bad
foo.save and return

# bad
if foo and bar
end

# good
foo.save && return

# good
if foo && bar
end

Example: EnforcedStyle: conditionals

# bad
if foo and bar
end

# good
foo.save && return

# good
foo.save and return

# good
if foo && bar
end

Redundant return detected.
Open

    return ( is_principal? or is_secretary? or is_teacher? )
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

This cop checks for redundant return expressions.

Example:

def test
  return something
end

def test
  one
  two
  three
  return something
end

It should be extended to handle methods whose body is if/else or a case expression with a default branch.

Use && instead of and.
Open

    if ( alumn.id == current_user.id and current_user.is_a?(Alumn))
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

This cop checks for uses of and and or, and suggests using && and || instead. It can be configured to check only in conditions, or in all contexts.

Example: EnforcedStyle: always (default)

# bad
foo.save and return

# bad
if foo and bar
end

# good
foo.save && return

# good
if foo && bar
end

Example: EnforcedStyle: conditionals

# bad
if foo and bar
end

# good
foo.save && return

# good
foo.save and return

# good
if foo && bar
end

Convert if nested inside else to elsif.
Open

      if ( !(@current_user = Employee.find_by_authorization_token(cookies[:authorization_token])).nil? )
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

If the else branch of a conditional consists solely of an if node, it can be combined with the else to become an elsif. This helps to keep the nesting level from getting too deep.

Example:

# bad
if condition_a
  action_a
else
  if condition_b
    action_b
  else
    action_c
  end
end

# good
if condition_a
  action_a
elsif condition_b
  action_b
else
  action_c
end

Favor modifier if usage when having a single-line body. Another good alternative is the usage of control flow &&/||.
Open

      if (parent == Parent.find_by_id(id))
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

Checks for if and unless statements that would fit on one line if written as a modifier if/unless. The maximum line length is configured in the Metrics/LineLength cop.

Example:

# bad
if condition
  do_stuff(bar)
end

unless qux.empty?
  Foo.do_something
end

# good
do_stuff(bar) if condition
Foo.do_something unless qux.empty?

Don't use parentheses around a method call.
Open

    if ( (logged_in?) and (current_user.is_a?(Secretary)))
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

This cop checks for redundant parentheses.

Example:

# bad
(x) if ((y.z).nil?)

# good
x if y.z.nil?

Extra empty line detected at method body beginning.
Open


    found = false
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

This cops checks if empty lines exist around the bodies of methods.

Example:

# good

def foo
  # ...
end

# bad

def bar

  # ...

end

Space inside parentheses detected.
Open

      elsif ( !(@current_user = Alumn.find_by_authorization_token(cookies[:authorization_token])).nil? )
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

Checks for spaces inside ordinary round parentheses.

Example:

# bad
f( 3)
g = (a + 3 )

# good
f(3)
g = (a + 3)

Rename is_related? to related?.
Open

  def is_related?(id)
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

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

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

    if ( !@current_user.nil? )
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

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

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

      if (parent == Parent.find_by_id(id))
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

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

Don't use parentheses around a method call.
Open

      !(current_user.nil?)
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

This cop checks for redundant parentheses.

Example:

# bad
(x) if ((y.z).nil?)

# good
x if y.z.nil?

Redundant return detected.
Open

          return @current_user
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

This cop checks for redundant return expressions.

Example:

def test
  return something
end

def test
  one
  two
  three
  return something
end

It should be extended to handle methods whose body is if/else or a case expression with a default branch.

Redundant return detected.
Open

      return true
Severity: Minor
Found in app/helpers/sessions_helper.rb by rubocop

This cop checks for redundant return expressions.

Example:

def test
  return something
end

def test
  one
  two
  three
  return something
end

It should be extended to handle methods whose body is if/else or a case expression with a default branch.

There are no issues that match your filters.

Category
Status