publiclab/plots2

View on GitHub
app/models/user.rb

Summary

Maintainability
D
2 days
Test Coverage

Class User has 71 methods (exceeds 20 allowed). Consider refactoring.
Open

class User < ActiveRecord::Base
  extend Utils
  include Statistics
  extend RawStats
  self.table_name = 'rusers'
Severity: Major
Found in app/models/user.rb - About 1 day to fix

File user.rb has 442 lines of code (exceeds 250 allowed). Consider refactoring.
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
Severity: Minor
Found in app/models/user.rb - About 6 hrs to fix

Method content_followed_in_period has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def content_followed_in_period(start_time, end_time,
    order_by = 'node_revisions.timestamp DESC', node_type = 'note', include_revisions = false)
Severity: Minor
Found in app/models/user.rb - About 35 mins to fix

Align the parameters of a method definition if they span more than one line.
Open

    order_by = 'node_revisions.timestamp DESC', node_type = 'note', include_revisions = false)
Severity: Minor
Found in app/models/user.rb by rubocop

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

    recent_nodes = nodes.includes(:tag)
Severity: Minor
Found in app/models/user.rb by rubocop

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

       following: true)
Severity: Minor
Found in app/models/user.rb by rubocop

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

    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'
Severity: Minor
Found in app/models/user.rb by rubocop

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

There are no issues that match your filters.

Category
Status