app/models/user.rb
Class User
has 71 methods (exceeds 20 allowed). Consider refactoring. Open
Open
class User < ActiveRecord::Base
extend Utils
include Statistics
extend RawStats
self.table_name = 'rusers'
- Create a ticketCreate a ticket
File user.rb
has 442 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
class UniqueUsernameValidator < ActiveModel::Validator
def validate(record)
if User.find_by(username: record.username) && record.openid_identifier.nil?
record.errors[:base] << 'That username is already taken. If this is your username, you can simply log in to this site.'
end
- Create a ticketCreate a ticket
Method content_followed_in_period
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def content_followed_in_period(start_time, end_time,
order_by = 'node_revisions.timestamp DESC', node_type = 'note', include_revisions = false)
- Create a ticketCreate a ticket
Align the parameters of a method definition if they span more than one line. Open
Open
order_by = 'node_revisions.timestamp DESC', node_type = 'note', include_revisions = false)
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Here we check if the parameters on a multi-line method call or definition are aligned.
Example: EnforcedStyle: withfirstparameter (default)
# good
foo :bar,
:baz
# bad
foo :bar,
:baz
Example: EnforcedStyle: withfixedindentation
# good
foo :bar,
:baz
# bad
foo :bar,
:baz
Useless assignment to variable - recent_nodes
. Open
Open
recent_nodes = nodes.includes(:tag)
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
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
Align the elements of a hash literal if they span more than one line. Open
Open
following: true)
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Check that the keys, separators, and values of a multi-line hash literal are aligned according to configuration. The configuration options are:
- key (left align keys)
- separator (align hash rockets and colons, right align keys)
- table (left align keys, hash rockets, and values)
The treatment of hashes passed as the last argument to a method call can also be configured. The options are:
- always_inspect
- always_ignore
- ignore_implicit (without curly braces)
- ignore_explicit (with curly braces)
Example:
# EnforcedHashRocketStyle: key (default)
# EnforcedColonStyle: key (default)
# good
{
foo: bar,
ba: baz
}
{
:foo => bar,
:ba => baz
}
# bad
{
foo: bar,
ba: baz
}
{
:foo => bar,
:ba => baz
}
Example:
# EnforcedHashRocketStyle: separator
# EnforcedColonStyle: separator
#good
{
foo: bar,
ba: baz
}
{
:foo => bar,
:ba => baz
}
#bad
{
foo: bar,
ba: baz
}
{
:foo => bar,
:ba => baz
}
{
:foo => bar,
:ba => baz
}
Example:
# EnforcedHashRocketStyle: table
# EnforcedColonStyle: table
#good
{
foo: bar,
ba: baz
}
{
:foo => bar,
:ba => baz
}
#bad
{
foo: bar,
ba: baz
}
{
:foo => bar,
:ba => baz
}
Align the parameters of a method call if they span more than one line. Open
Open
styles: { thumb: '200x200#', medium: '500x500#', large: '800x800#' },
url: '/public/system/profile/photos/:id/:style/:basename.:extension',
path: ':rails_root/public/system/public/system/profile/photos/:id/:style/:filename'
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Here we check if the parameters on a multi-line method call or definition are aligned.
Example: EnforcedStyle: withfirstparameter (default)
# good
foo :bar,
:baz
# bad
foo :bar,
:baz
Example: EnforcedStyle: withfixedindentation
# good
foo :bar,
:baz
# bad
foo :bar,
:baz