lawrencechanyewlong/wherewolfpro

View on GitHub
app/controllers/welcome_controller.rb

Summary

Maintainability
A
0 mins
Test Coverage

Assignment Branch Condition size for clear_event is too high. [19/15]
Open

  def clear_event
    session.delete(:address_string)
    session.delete(:address_lat)
    session.delete(:address_lng)
    session.delete(:receiver)

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 index
    if params[:login]
      @login = true
    end
    if session[:id] 

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.

Space missing to the left of {.
Open

    @history.sort!{ |x,y| y[:created_at] <=> x[:created_at] }

Checks that block braces have or don't have a space before the opening brace depending on configuration.

Example:

# bad
foo.map{ |a|
  a.bar.to_s
}

# good
foo.map { |a|
  a.bar.to_s
}

Useless assignment to variable - i.
Open

    i = 0

This cop checks for every useless assignment to local variable in every scope. The basic idea for this cop was from the warning of ruby -cw:

assigned but unused variable - foo

Currently this cop has advanced logic that detects unreferenced reassignments and properly handles varied cases such as branch, loop, rescue, ensure, etc.

Example:

# bad

def some_method
  some_var = 1
  do_something
end

Example:

# good

def some_method
  some_var = 1
  do_something(some_var)
end

Missing top-level class documentation comment.
Open

class WelcomeController < ApplicationController

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

Line is too long. [81/80]
Open

      e[:duration_setting] = WelcomeHelper.toDurationString(e[:duration_setting])

Trailing whitespace detected.
Open

      

Trailing whitespace detected.
Open

  

Trailing whitespace detected.
Open

    

Line is too long. [82/80]
Open

  #     logger.debug "session[:formatted_address]: #{session[:formatted_address]}"

Space missing after comma.
Open

    @history.sort!{ |x,y| y[:created_at] <=> x[:created_at] }

Checks for comma (,) not followed by some kind of space.

Example:

# bad
[1,2]
{ foo:bar,}

# good
[1, 2]
{ foo:bar, }

Trailing whitespace detected.
Open

  

Line is too long. [95/80]
Open

  #     render text: "<script>window.location = '#{event_summary_path}';</script>", status: 200

Extra empty line detected at method body end.
Open


  end

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

Example:

# good

def foo
  # ...
end

# bad

def bar

  # ...

end

Trailing whitespace detected.
Open

  

Trailing whitespace detected.
Open

    if session[:id] 

Prefer single-quoted strings when you don't need string interpolation or special symbols.
Open

    redirect_to "/"

Checks if uses of quotes match the configured preference.

Example: EnforcedStyle: single_quotes (default)

# bad
"No special symbols"
"No string interpolation"
"Just text"

# good
'No special symbols'
'No string interpolation'
'Just text'
"Wait! What's #{this}!"

Example: EnforcedStyle: double_quotes

# bad
'Just some text'
'No special chars or interpolation'

# good
"Just some text"
"No special chars or interpolation"
"Every string in #{project} uses double_quotes"

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

    if params[:login]

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?

Favor unless over if for negative conditions.
Open

      if !user
        session[:id] = nil
        return
      end

Checks for uses of if with a negated condition. Only ifs without else are considered. There are three different styles:

- both
- prefix
- postfix

Example: EnforcedStyle: both (default)

# enforces `unless` for `prefix` and `postfix` conditionals

# bad

if !foo
  bar
end

# good

unless foo
  bar
end

# bad

bar if !foo

# good

bar unless foo

Example: EnforcedStyle: prefix

# enforces `unless` for just `prefix` conditionals

# bad

if !foo
  bar
end

# good

unless foo
  bar
end

# good

bar if !foo

Example: EnforcedStyle: postfix

# enforces `unless` for just `postfix` conditionals

# bad

bar if !foo

# good

bar unless foo

# good

if !foo
  bar
end

Prefer single-quoted strings when you don't need string interpolation or special symbols.
Open

    redirect_to "/"

Checks if uses of quotes match the configured preference.

Example: EnforcedStyle: single_quotes (default)

# bad
"No special symbols"
"No string interpolation"
"Just text"

# good
'No special symbols'
'No string interpolation'
'Just text'
"Wait! What's #{this}!"

Example: EnforcedStyle: double_quotes

# bad
'Just some text'
'No special chars or interpolation'

# good
"Just some text"
"No special chars or interpolation"
"Every string in #{project} uses double_quotes"

There are no issues that match your filters.

Category
Status