jjeremydiaz/OpenHouse

View on GitHub
features/support/paths.rb

Summary

Maintainability
A
0 mins
Test Coverage

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

  def path_to(page_name, user = nil)
    case page_name

    when /^the home\s?page$/
      '/'
Severity: Minor
Found in features/support/paths.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 path_to is too high. [8/6]
Open

  def path_to(page_name, user = nil)
    case page_name

    when /^the home\s?page$/
      '/'
Severity: Minor
Found in features/support/paths.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.

Assignment Branch Condition size for path_to is too high. [16.58/15]
Open

  def path_to(page_name, user = nil)
    case page_name

    when /^the home\s?page$/
      '/'
Severity: Minor
Found in features/support/paths.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

Redundant self detected.
Open

        self.send(path_components.push('path').join('_').to_sym)
Severity: Minor
Found in features/support/paths.rb by rubocop

This cop checks for redundant uses of self.

The usage of self is only needed when:

  • Sending a message to same object with zero arguments in presence of a method name clash with an argument or a local variable.

  • Calling an attribute writer to prevent an local variable assignment.

Note, with using explicit self you can only send messages with public or protected scope, you cannot send private messages this way.

Note we allow uses of self with operators because it would be awkward otherwise.

Example:

# bad
def foo(bar)
  self.baz
end

# good
def foo(bar)
  self.bar  # Resolves name clash with the argument.
end

def foo
  bar = 1
  self.bar  # Resolves name clash with the local variable.
end

def foo
  %w[x y z].select do |bar|
    self.bar == bar  # Resolves name clash with argument of the block.
  end
end

Avoid the use of Perl-style backrefs.
Open

      user_path(User.find_by(email: $1))
Severity: Minor
Found in features/support/paths.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

      edit_user_path(User.find_by(email: $1))
Severity: Minor
Found in features/support/paths.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

        path_components = $1.split(/\s+/)
Severity: Minor
Found in features/support/paths.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)

Unused method argument - user. If it's necessary, use _ or _user as an argument name to indicate that it won't be used.
Open

  def path_to(page_name, user = nil)
Severity: Minor
Found in features/support/paths.rb by rubocop

This cop checks for unused method arguments.

Example:

# bad

def some_method(used, unused, _unused_but_allowed)
  puts used
end

Example:

# good

def some_method(used, _unused, _unused_but_allowed)
  puts used
end

Use \ instead of + or << to concatenate those strings.
Open

        raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
Severity: Minor
Found in features/support/paths.rb by rubocop

This cop checks for string literal concatenation at the end of a line.

Example:

# bad
some_str = 'ala' +
           'bala'

some_str = 'ala' <<
           'bala'

# good
some_str = 'ala' \
           'bala'

There are no issues that match your filters.

Category
Status