diaspora/diaspora

View on GitHub
app/models/user.rb

Summary

Maintainability
D
2 days
Test Coverage

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

class User < ApplicationRecord
  include AuthenticationToken
  include Connecting
  include Querying
  include SocialActions
Severity: Major
Found in app/models/user.rb - About 1 day to fix

    File user.rb has 449 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    class User < ApplicationRecord
      include AuthenticationToken
      include Connecting
      include Querying
      include SocialActions
    Severity: Minor
    Found in app/models/user.rb - About 6 hrs to fix

      Assignment Branch Condition size for send_welcome_message is too high. [28.44/20]
      Open

        def send_welcome_message
          return unless AppConfig.settings.welcome_message.enabled? && AppConfig.admins.account?
          sender_username = AppConfig.admins.account.get
          sender = User.find_by(username: sender_username)
          return if sender.nil?
      Severity: Minor
      Found in app/models/user.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

      Assignment Branch Condition size for setup is too high. [21.28/20]
      Open

        def setup(opts)
          self.username = opts[:username]
          self.email = opts[:email]
          self.language = opts[:language]
          self.language ||= I18n.locale.to_s
      Severity: Minor
      Found in app/models/user.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 update_user_preferences has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def update_user_preferences(pref_hash)
          if self.disable_mail
            UserPreference::VALID_EMAIL_TYPES.each{|x| self.user_preferences.find_or_create_by(email_type: x)}
            self.disable_mail = false
            self.save
      Severity: Minor
      Found in app/models/user.rb - About 35 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method guard_unconfirmed_email has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def guard_unconfirmed_email
          self.unconfirmed_email = nil if unconfirmed_email.blank? || unconfirmed_email == email
      
          return unless will_save_change_to_unconfirmed_email?
      
      
      Severity: Minor
      Found in app/models/user.rb - About 25 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Use each_key instead of keys.each.
      Open

          pref_hash.keys.each do |key|
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop checks for uses of each_key and each_value Hash methods.

      Note: If you have an array of two-element arrays, you can put parentheses around the block arguments to indicate that you're not working with a hash, and suppress RuboCop offenses.

      Example:

      # bad
      hash.keys.each { |k| p k }
      hash.values.each { |v| p v }
      hash.each { |k, _v| p k }
      hash.each { |_k, v| p v }
      
      # good
      hash.each_key { |k| p k }
      hash.each_value { |v| p v }
      

      Use if job.blank? instead of unless job.present?.
      Open

          return unless job.present?
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cops checks for code that can be changed to blank?. Settings: NilOrEmpty: Convert checks for nil or empty? to blank? NotPresent: Convert usages of not present? to blank? UnlessPresent: Convert usages of unless present? to blank?

      Example:

      # NilOrEmpty: true
        # bad
        foo.nil? || foo.empty?
        foo == nil || foo.empty?
      
        # good
        foo.blank?
      
      # NotPresent: true
        # bad
        !foo.present?
      
        # good
        foo.blank?
      
      # UnlessPresent: true
        # bad
        something unless foo.present?
        unless foo.present?
          something
        end
      
        # good
        something if foo.blank?
        if foo.blank?
          something
        end
      

      Specify a :dependent option.
      Open

        has_many :share_visibilities
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop looks for has_many or has_one associations that don't specify a :dependent option. It doesn't register an offense if :through option was specified.

      Example:

      # bad
      class User < ActiveRecord::Base
        has_many :comments
        has_one :avatar
      end
      
      # good
      class User < ActiveRecord::Base
        has_many :comments, dependent: :restrict_with_exception
        has_one :avatar, dependent: :destroy
        has_many :patients, through: :appointments
      end
      

      Specify a :dependent option.
      Open

        has_many :tag_followings
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop looks for has_many or has_one associations that don't specify a :dependent option. It doesn't register an offense if :through option was specified.

      Example:

      # bad
      class User < ActiveRecord::Base
        has_many :comments
        has_one :avatar
      end
      
      # good
      class User < ActiveRecord::Base
        has_many :comments, dependent: :restrict_with_exception
        has_one :avatar, dependent: :destroy
        has_many :patients, through: :appointments
      end
      

      Prefer 6.months.
      Open

        scope :halfyear_actives, ->(time = Time.now) { logged_in_since(time - 6.month) }
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop checks for correct grammar when using ActiveSupport's core extensions to the numeric classes.

      Example:

      # bad
      3.day.ago
      1.months.ago
      
      # good
      3.days.ago
      1.month.ago
      

      Favor Rails.env.test? over Rails.env == 'test'.
      Open

          key_size = (Rails.env == "test" ? 512 : 4096)
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop checks that Rails.env is compared using .production?-like methods instead of equality against a string or symbol.

      Example:

      # bad
      Rails.env == 'production'
      
      # bad, always returns false
      Rails.env == :test
      
      # good
      Rails.env.production?
      

      Avoid using update_attribute because it skips validations.
      Open

            aspect.update_attribute(:post_default, enable)
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop checks for the use of methods which skip validations which are listed in http://guides.rubyonrails.org/activerecordvalidations.html#skipping-validations

      Example:

      # bad
      Article.first.decrement!(:view_count)
      DiscussionBoard.decrement_counter(:post_count, 5)
      Article.first.increment!(:view_count)
      DiscussionBoard.increment_counter(:post_count, 5)
      person.toggle :active
      product.touch
      Billing.update_all("category = 'authorized', author = 'David'")
      user.update_attribute(website: 'example.com')
      user.update_columns(last_request_at: Time.current)
      Post.update_counters 5, comment_count: -1, action_count: 1
      
      # good
      user.update_attributes(website: 'example.com')
      FileUtils.touch('file')
      

      Specify a :dependent option.
      Open

        has_many :invited_users, class_name: "User", inverse_of: :invited_by, foreign_key: :invited_by_id
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop looks for has_many or has_one associations that don't specify a :dependent option. It doesn't register an offense if :through option was specified.

      Example:

      # bad
      class User < ActiveRecord::Base
        has_many :comments
        has_one :avatar
      end
      
      # good
      class User < ActiveRecord::Base
        has_many :comments, dependent: :restrict_with_exception
        has_one :avatar, dependent: :destroy
        has_many :patients, through: :appointments
      end
      

      Specify a :dependent option.
      Open

        has_many :services
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop looks for has_many or has_one associations that don't specify a :dependent option. It doesn't register an offense if :through option was specified.

      Example:

      # bad
      class User < ActiveRecord::Base
        has_many :comments
        has_one :avatar
      end
      
      # good
      class User < ActiveRecord::Base
        has_many :comments, dependent: :restrict_with_exception
        has_one :avatar, dependent: :destroy
        has_many :patients, through: :appointments
      end
      

      Specify an :inverse_of option.
      Open

        belongs_to :auto_follow_back_aspect, class_name: "Aspect", optional: true
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop looks for has(one|many) and belongsto associations where ActiveRecord can't automatically determine the inverse association because of a scope or the options used. This can result in unnecessary queries in some circumstances. :inverse_of must be manually specified for associations to work in both ways, or set to false to opt-out.

      Example:

      # good
      class Blog < ApplicationRecord
        has_many :posts
      end
      
      class Post < ApplicationRecord
        belongs_to :blog
      end
      

      Example:

      # bad
      class Blog < ApplicationRecord
        has_many :posts, -> { order(published_at: :desc) }
      end
      
      class Post < ApplicationRecord
        belongs_to :blog
      end
      
      # good
      class Blog < ApplicationRecord
        has_many(:posts,
          -> { order(published_at: :desc) },
          inverse_of: :blog
        )
      end
      
      class Post < ApplicationRecord
        belongs_to :blog
      end
      
      # good
      class Blog < ApplicationRecord
        with_options inverse_of: :blog do
          has_many :posts, -> { order(published_at: :desc) }
        end
      end
      
      class Post < ApplicationRecord
        belongs_to :blog
      end
      

      Example:

      # bad
      class Picture < ApplicationRecord
        belongs_to :imageable, polymorphic: true
      end
      
      class Employee < ApplicationRecord
        has_many :pictures, as: :imageable
      end
      
      class Product < ApplicationRecord
        has_many :pictures, as: :imageable
      end
      
      # good
      class Picture < ApplicationRecord
        belongs_to :imageable, polymorphic: true
      end
      
      class Employee < ApplicationRecord
        has_many :pictures, as: :imageable, inverse_of: :imageable
      end
      
      class Product < ApplicationRecord
        has_many :pictures, as: :imageable, inverse_of: :imageable
      end
      

      Example:

      # bad
      # However, RuboCop can not detect this pattern...
      class Physician < ApplicationRecord
        has_many :appointments
        has_many :patients, through: :appointments
      end
      
      class Appointment < ApplicationRecord
        belongs_to :physician
        belongs_to :patient
      end
      
      class Patient < ApplicationRecord
        has_many :appointments
        has_many :physicians, through: :appointments
      end
      
      # good
      class Physician < ApplicationRecord
        has_many :appointments
        has_many :patients, through: :appointments
      end
      
      class Appointment < ApplicationRecord
        belongs_to :physician, inverse_of: :appointments
        belongs_to :patient, inverse_of: :appointments
      end
      
      class Patient < ApplicationRecord
        has_many :appointments
        has_many :physicians, through: :appointments
      end
      

      @see http://guides.rubyonrails.org/association_basics.html#bi-directional-associations @see http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html#module-ActiveRecord::Associations::ClassMethods-label-Setting+Inverses

      Specify an :inverse_of option.
      Open

        has_many :notifications, :foreign_key => :recipient_id
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop looks for has(one|many) and belongsto associations where ActiveRecord can't automatically determine the inverse association because of a scope or the options used. This can result in unnecessary queries in some circumstances. :inverse_of must be manually specified for associations to work in both ways, or set to false to opt-out.

      Example:

      # good
      class Blog < ApplicationRecord
        has_many :posts
      end
      
      class Post < ApplicationRecord
        belongs_to :blog
      end
      

      Example:

      # bad
      class Blog < ApplicationRecord
        has_many :posts, -> { order(published_at: :desc) }
      end
      
      class Post < ApplicationRecord
        belongs_to :blog
      end
      
      # good
      class Blog < ApplicationRecord
        has_many(:posts,
          -> { order(published_at: :desc) },
          inverse_of: :blog
        )
      end
      
      class Post < ApplicationRecord
        belongs_to :blog
      end
      
      # good
      class Blog < ApplicationRecord
        with_options inverse_of: :blog do
          has_many :posts, -> { order(published_at: :desc) }
        end
      end
      
      class Post < ApplicationRecord
        belongs_to :blog
      end
      

      Example:

      # bad
      class Picture < ApplicationRecord
        belongs_to :imageable, polymorphic: true
      end
      
      class Employee < ApplicationRecord
        has_many :pictures, as: :imageable
      end
      
      class Product < ApplicationRecord
        has_many :pictures, as: :imageable
      end
      
      # good
      class Picture < ApplicationRecord
        belongs_to :imageable, polymorphic: true
      end
      
      class Employee < ApplicationRecord
        has_many :pictures, as: :imageable, inverse_of: :imageable
      end
      
      class Product < ApplicationRecord
        has_many :pictures, as: :imageable, inverse_of: :imageable
      end
      

      Example:

      # bad
      # However, RuboCop can not detect this pattern...
      class Physician < ApplicationRecord
        has_many :appointments
        has_many :patients, through: :appointments
      end
      
      class Appointment < ApplicationRecord
        belongs_to :physician
        belongs_to :patient
      end
      
      class Patient < ApplicationRecord
        has_many :appointments
        has_many :physicians, through: :appointments
      end
      
      # good
      class Physician < ApplicationRecord
        has_many :appointments
        has_many :patients, through: :appointments
      end
      
      class Appointment < ApplicationRecord
        belongs_to :physician, inverse_of: :appointments
        belongs_to :patient, inverse_of: :appointments
      end
      
      class Patient < ApplicationRecord
        has_many :appointments
        has_many :physicians, through: :appointments
      end
      

      @see http://guides.rubyonrails.org/association_basics.html#bi-directional-associations @see http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html#module-ActiveRecord::Associations::ClassMethods-label-Setting+Inverses

      Specify a :dependent option.
      Open

        has_one :person, inverse_of: :owner, foreign_key: :owner_id
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop looks for has_many or has_one associations that don't specify a :dependent option. It doesn't register an offense if :through option was specified.

      Example:

      # bad
      class User < ActiveRecord::Base
        has_many :comments
        has_one :avatar
      end
      
      # good
      class User < ActiveRecord::Base
        has_many :comments, dependent: :restrict_with_exception
        has_one :avatar, dependent: :destroy
        has_many :patients, through: :appointments
      end
      

      Specify a :dependent option.
      Open

        has_many :reports
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop looks for has_many or has_one associations that don't specify a :dependent option. It doesn't register an offense if :through option was specified.

      Example:

      # bad
      class User < ActiveRecord::Base
        has_many :comments
        has_one :avatar
      end
      
      # good
      class User < ActiveRecord::Base
        has_many :comments, dependent: :restrict_with_exception
        has_one :avatar, dependent: :destroy
        has_many :patients, through: :appointments
      end
      

      Use find_by instead of where.first.
      Open

          where(conditions).first
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop is used to identify usages of where.first and change them to use find_by instead.

      Example:

      # bad
      User.where(name: 'Bruce').first
      User.where(name: 'Bruce').take
      
      # good
      User.find_by(name: 'Bruce')
      

      Specify a :dependent option.
      Open

        has_many :notifications, :foreign_key => :recipient_id
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop looks for has_many or has_one associations that don't specify a :dependent option. It doesn't register an offense if :through option was specified.

      Example:

      # bad
      class User < ActiveRecord::Base
        has_many :comments
        has_one :avatar
      end
      
      # good
      class User < ActiveRecord::Base
        has_many :comments, dependent: :restrict_with_exception
        has_one :avatar, dependent: :destroy
        has_many :patients, through: :appointments
      end
      

      Specify a :dependent option.
      Open

        has_many :authorizations, class_name: "Api::OpenidConnect::Authorization"
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop looks for has_many or has_one associations that don't specify a :dependent option. It doesn't register an offense if :through option was specified.

      Example:

      # bad
      class User < ActiveRecord::Base
        has_many :comments
        has_one :avatar
      end
      
      # good
      class User < ActiveRecord::Base
        has_many :comments, dependent: :restrict_with_exception
        has_one :avatar, dependent: :destroy
        has_many :patients, through: :appointments
      end
      

      Specify an :inverse_of option.
      Open

        has_many :aspects, -> { order('order_id ASC') }
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop looks for has(one|many) and belongsto associations where ActiveRecord can't automatically determine the inverse association because of a scope or the options used. This can result in unnecessary queries in some circumstances. :inverse_of must be manually specified for associations to work in both ways, or set to false to opt-out.

      Example:

      # good
      class Blog < ApplicationRecord
        has_many :posts
      end
      
      class Post < ApplicationRecord
        belongs_to :blog
      end
      

      Example:

      # bad
      class Blog < ApplicationRecord
        has_many :posts, -> { order(published_at: :desc) }
      end
      
      class Post < ApplicationRecord
        belongs_to :blog
      end
      
      # good
      class Blog < ApplicationRecord
        has_many(:posts,
          -> { order(published_at: :desc) },
          inverse_of: :blog
        )
      end
      
      class Post < ApplicationRecord
        belongs_to :blog
      end
      
      # good
      class Blog < ApplicationRecord
        with_options inverse_of: :blog do
          has_many :posts, -> { order(published_at: :desc) }
        end
      end
      
      class Post < ApplicationRecord
        belongs_to :blog
      end
      

      Example:

      # bad
      class Picture < ApplicationRecord
        belongs_to :imageable, polymorphic: true
      end
      
      class Employee < ApplicationRecord
        has_many :pictures, as: :imageable
      end
      
      class Product < ApplicationRecord
        has_many :pictures, as: :imageable
      end
      
      # good
      class Picture < ApplicationRecord
        belongs_to :imageable, polymorphic: true
      end
      
      class Employee < ApplicationRecord
        has_many :pictures, as: :imageable, inverse_of: :imageable
      end
      
      class Product < ApplicationRecord
        has_many :pictures, as: :imageable, inverse_of: :imageable
      end
      

      Example:

      # bad
      # However, RuboCop can not detect this pattern...
      class Physician < ApplicationRecord
        has_many :appointments
        has_many :patients, through: :appointments
      end
      
      class Appointment < ApplicationRecord
        belongs_to :physician
        belongs_to :patient
      end
      
      class Patient < ApplicationRecord
        has_many :appointments
        has_many :physicians, through: :appointments
      end
      
      # good
      class Physician < ApplicationRecord
        has_many :appointments
        has_many :patients, through: :appointments
      end
      
      class Appointment < ApplicationRecord
        belongs_to :physician, inverse_of: :appointments
        belongs_to :patient, inverse_of: :appointments
      end
      
      class Patient < ApplicationRecord
        has_many :appointments
        has_many :physicians, through: :appointments
      end
      

      @see http://guides.rubyonrails.org/association_basics.html#bi-directional-associations @see http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html#module-ActiveRecord::Associations::ClassMethods-label-Setting+Inverses

      Avoid using update_attribute because it skips validations.
      Open

          self.update_attribute(:getting_started, false) if self.getting_started?
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop checks for the use of methods which skip validations which are listed in http://guides.rubyonrails.org/activerecordvalidations.html#skipping-validations

      Example:

      # bad
      Article.first.decrement!(:view_count)
      DiscussionBoard.decrement_counter(:post_count, 5)
      Article.first.increment!(:view_count)
      DiscussionBoard.increment_counter(:post_count, 5)
      person.toggle :active
      product.touch
      Billing.update_all("category = 'authorized', author = 'David'")
      user.update_attribute(website: 'example.com')
      user.update_columns(last_request_at: Time.current)
      Post.update_counters 5, comment_count: -1, action_count: 1
      
      # good
      user.update_attributes(website: 'example.com')
      FileUtils.touch('file')
      

      Specify a :dependent option.
      Open

        has_many :blocks
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop looks for has_many or has_one associations that don't specify a :dependent option. It doesn't register an offense if :through option was specified.

      Example:

      # bad
      class User < ActiveRecord::Base
        has_many :comments
        has_one :avatar
      end
      
      # good
      class User < ActiveRecord::Base
        has_many :comments, dependent: :restrict_with_exception
        has_one :avatar, dependent: :destroy
        has_many :patients, through: :appointments
      end
      

      Specify a :dependent option.
      Open

        has_many :pairwise_pseudonymous_identifiers, class_name: "Api::OpenidConnect::PairwisePseudonymousIdentifier"
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop looks for has_many or has_one associations that don't specify a :dependent option. It doesn't register an offense if :through option was specified.

      Example:

      # bad
      class User < ActiveRecord::Base
        has_many :comments
        has_one :avatar
      end
      
      # good
      class User < ActiveRecord::Base
        has_many :comments, dependent: :restrict_with_exception
        has_one :avatar, dependent: :destroy
        has_many :patients, through: :appointments
      end
      

      Specify an :inverse_of option.
      Open

        has_many :pairwise_pseudonymous_identifiers, class_name: "Api::OpenidConnect::PairwisePseudonymousIdentifier"
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop looks for has(one|many) and belongsto associations where ActiveRecord can't automatically determine the inverse association because of a scope or the options used. This can result in unnecessary queries in some circumstances. :inverse_of must be manually specified for associations to work in both ways, or set to false to opt-out.

      Example:

      # good
      class Blog < ApplicationRecord
        has_many :posts
      end
      
      class Post < ApplicationRecord
        belongs_to :blog
      end
      

      Example:

      # bad
      class Blog < ApplicationRecord
        has_many :posts, -> { order(published_at: :desc) }
      end
      
      class Post < ApplicationRecord
        belongs_to :blog
      end
      
      # good
      class Blog < ApplicationRecord
        has_many(:posts,
          -> { order(published_at: :desc) },
          inverse_of: :blog
        )
      end
      
      class Post < ApplicationRecord
        belongs_to :blog
      end
      
      # good
      class Blog < ApplicationRecord
        with_options inverse_of: :blog do
          has_many :posts, -> { order(published_at: :desc) }
        end
      end
      
      class Post < ApplicationRecord
        belongs_to :blog
      end
      

      Example:

      # bad
      class Picture < ApplicationRecord
        belongs_to :imageable, polymorphic: true
      end
      
      class Employee < ApplicationRecord
        has_many :pictures, as: :imageable
      end
      
      class Product < ApplicationRecord
        has_many :pictures, as: :imageable
      end
      
      # good
      class Picture < ApplicationRecord
        belongs_to :imageable, polymorphic: true
      end
      
      class Employee < ApplicationRecord
        has_many :pictures, as: :imageable, inverse_of: :imageable
      end
      
      class Product < ApplicationRecord
        has_many :pictures, as: :imageable, inverse_of: :imageable
      end
      

      Example:

      # bad
      # However, RuboCop can not detect this pattern...
      class Physician < ApplicationRecord
        has_many :appointments
        has_many :patients, through: :appointments
      end
      
      class Appointment < ApplicationRecord
        belongs_to :physician
        belongs_to :patient
      end
      
      class Patient < ApplicationRecord
        has_many :appointments
        has_many :physicians, through: :appointments
      end
      
      # good
      class Physician < ApplicationRecord
        has_many :appointments
        has_many :patients, through: :appointments
      end
      
      class Appointment < ApplicationRecord
        belongs_to :physician, inverse_of: :appointments
        belongs_to :patient, inverse_of: :appointments
      end
      
      class Patient < ApplicationRecord
        has_many :appointments
        has_many :physicians, through: :appointments
      end
      

      @see http://guides.rubyonrails.org/association_basics.html#bi-directional-associations @see http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html#module-ActiveRecord::Associations::ClassMethods-label-Setting+Inverses

      Specify an :inverse_of option.
      Open

        has_many :authorizations, class_name: "Api::OpenidConnect::Authorization"
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop looks for has(one|many) and belongsto associations where ActiveRecord can't automatically determine the inverse association because of a scope or the options used. This can result in unnecessary queries in some circumstances. :inverse_of must be manually specified for associations to work in both ways, or set to false to opt-out.

      Example:

      # good
      class Blog < ApplicationRecord
        has_many :posts
      end
      
      class Post < ApplicationRecord
        belongs_to :blog
      end
      

      Example:

      # bad
      class Blog < ApplicationRecord
        has_many :posts, -> { order(published_at: :desc) }
      end
      
      class Post < ApplicationRecord
        belongs_to :blog
      end
      
      # good
      class Blog < ApplicationRecord
        has_many(:posts,
          -> { order(published_at: :desc) },
          inverse_of: :blog
        )
      end
      
      class Post < ApplicationRecord
        belongs_to :blog
      end
      
      # good
      class Blog < ApplicationRecord
        with_options inverse_of: :blog do
          has_many :posts, -> { order(published_at: :desc) }
        end
      end
      
      class Post < ApplicationRecord
        belongs_to :blog
      end
      

      Example:

      # bad
      class Picture < ApplicationRecord
        belongs_to :imageable, polymorphic: true
      end
      
      class Employee < ApplicationRecord
        has_many :pictures, as: :imageable
      end
      
      class Product < ApplicationRecord
        has_many :pictures, as: :imageable
      end
      
      # good
      class Picture < ApplicationRecord
        belongs_to :imageable, polymorphic: true
      end
      
      class Employee < ApplicationRecord
        has_many :pictures, as: :imageable, inverse_of: :imageable
      end
      
      class Product < ApplicationRecord
        has_many :pictures, as: :imageable, inverse_of: :imageable
      end
      

      Example:

      # bad
      # However, RuboCop can not detect this pattern...
      class Physician < ApplicationRecord
        has_many :appointments
        has_many :patients, through: :appointments
      end
      
      class Appointment < ApplicationRecord
        belongs_to :physician
        belongs_to :patient
      end
      
      class Patient < ApplicationRecord
        has_many :appointments
        has_many :physicians, through: :appointments
      end
      
      # good
      class Physician < ApplicationRecord
        has_many :appointments
        has_many :patients, through: :appointments
      end
      
      class Appointment < ApplicationRecord
        belongs_to :physician, inverse_of: :appointments
        belongs_to :patient, inverse_of: :appointments
      end
      
      class Patient < ApplicationRecord
        has_many :appointments
        has_many :physicians, through: :appointments
      end
      

      @see http://guides.rubyonrails.org/association_basics.html#bi-directional-associations @see http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html#module-ActiveRecord::Associations::ClassMethods-label-Setting+Inverses

      Specify a :dependent option.
      Open

        has_many :contacts
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop looks for has_many or has_one associations that don't specify a :dependent option. It doesn't register an offense if :through option was specified.

      Example:

      # bad
      class User < ActiveRecord::Base
        has_many :comments
        has_one :avatar
      end
      
      # good
      class User < ActiveRecord::Base
        has_many :comments, dependent: :restrict_with_exception
        has_one :avatar, dependent: :destroy
        has_many :patients, through: :appointments
      end
      

      Specify a :dependent option.
      Open

        has_many :user_preferences
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop looks for has_many or has_one associations that don't specify a :dependent option. It doesn't register an offense if :through option was specified.

      Example:

      # bad
      class User < ActiveRecord::Base
        has_many :comments
        has_one :avatar
      end
      
      # good
      class User < ActiveRecord::Base
        has_many :comments, dependent: :restrict_with_exception
        has_one :avatar, dependent: :destroy
        has_many :patients, through: :appointments
      end
      

      Specify an :inverse_of option.
      Open

        belongs_to :invited_by, class_name: "User", optional: true
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop looks for has(one|many) and belongsto associations where ActiveRecord can't automatically determine the inverse association because of a scope or the options used. This can result in unnecessary queries in some circumstances. :inverse_of must be manually specified for associations to work in both ways, or set to false to opt-out.

      Example:

      # good
      class Blog < ApplicationRecord
        has_many :posts
      end
      
      class Post < ApplicationRecord
        belongs_to :blog
      end
      

      Example:

      # bad
      class Blog < ApplicationRecord
        has_many :posts, -> { order(published_at: :desc) }
      end
      
      class Post < ApplicationRecord
        belongs_to :blog
      end
      
      # good
      class Blog < ApplicationRecord
        has_many(:posts,
          -> { order(published_at: :desc) },
          inverse_of: :blog
        )
      end
      
      class Post < ApplicationRecord
        belongs_to :blog
      end
      
      # good
      class Blog < ApplicationRecord
        with_options inverse_of: :blog do
          has_many :posts, -> { order(published_at: :desc) }
        end
      end
      
      class Post < ApplicationRecord
        belongs_to :blog
      end
      

      Example:

      # bad
      class Picture < ApplicationRecord
        belongs_to :imageable, polymorphic: true
      end
      
      class Employee < ApplicationRecord
        has_many :pictures, as: :imageable
      end
      
      class Product < ApplicationRecord
        has_many :pictures, as: :imageable
      end
      
      # good
      class Picture < ApplicationRecord
        belongs_to :imageable, polymorphic: true
      end
      
      class Employee < ApplicationRecord
        has_many :pictures, as: :imageable, inverse_of: :imageable
      end
      
      class Product < ApplicationRecord
        has_many :pictures, as: :imageable, inverse_of: :imageable
      end
      

      Example:

      # bad
      # However, RuboCop can not detect this pattern...
      class Physician < ApplicationRecord
        has_many :appointments
        has_many :patients, through: :appointments
      end
      
      class Appointment < ApplicationRecord
        belongs_to :physician
        belongs_to :patient
      end
      
      class Patient < ApplicationRecord
        has_many :appointments
        has_many :physicians, through: :appointments
      end
      
      # good
      class Physician < ApplicationRecord
        has_many :appointments
        has_many :patients, through: :appointments
      end
      
      class Appointment < ApplicationRecord
        belongs_to :physician, inverse_of: :appointments
        belongs_to :patient, inverse_of: :appointments
      end
      
      class Patient < ApplicationRecord
        has_many :appointments
        has_many :physicians, through: :appointments
      end
      

      @see http://guides.rubyonrails.org/association_basics.html#bi-directional-associations @see http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html#module-ActiveRecord::Associations::ClassMethods-label-Setting+Inverses

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

        rescue => error
          logger.error "Unexpected error while exporting user '#{username}': #{error.class}: #{error.message}\n" \
                       "#{error.backtrace.first(15).join("\n")}"
          update exporting: false
        end
      Severity: Minor
      Found in app/models/user.rb and 1 other location - About 25 mins to fix
      app/models/user.rb on lines 340..344

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 29.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

        rescue => error
          logger.error "Unexpected error while exporting photos for '#{username}': #{error.class}: #{error.message}\n" \
                       "#{error.backtrace.first(15).join("\n")}"
          update exporting_photos: false
        end
      Severity: Minor
      Found in app/models/user.rb and 1 other location - About 25 mins to fix
      app/models/user.rb on lines 320..324

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 29.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Space after keyword if is missing.
      Open

          if(self.disable_mail == false && !self.user_preferences.exists?(:email_type => pref))
      Severity: Minor
      Found in app/models/user.rb by rubocop

      Checks the spacing around the keywords.

      Example:

      # bad
      something 'test'do|x|
      end
      
      while(something)
      end
      
      something = 123if test
      
      # good
      something 'test' do |x|
      end
      
      while (something)
      end
      
      something = 123 if test
      

      Use empty lines between method definitions.
      Open

        def unconfirmed_email_quasiuniqueness
      Severity: Minor
      Found in app/models/user.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
      

      Unnecessary spacing detected.
      Open

        validates_format_of :unconfirmed_email, :with  => Devise.email_regexp, :allow_blank => true
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop checks for extra/unnecessary whitespace.

      Example:

      # good if AllowForAlignment is true
      name      = "RuboCop"
      # Some comment and an empty line
      
      website  += "/bbatsov/rubocop" unless cond
      puts        "rubocop"          if     debug
      
      # bad for any configuration
      set_app("RuboCop")
      website  = "https://github.com/bbatsov/rubocop"
      

      Surrounding space detected in default value assignment.
      Open

        def self.build(opts = {})
      Severity: Minor
      Found in app/models/user.rb by rubocop

      Checks that the equals signs in parameter default assignments have or don't have surrounding space depending on configuration.

      Example:

      # bad
      def some_method(arg1=:default, arg2=nil, arg3=[])
        # do something...
      end
      
      # good
      def some_method(arg1 = :default, arg2 = nil, arg3 = [])
        # do something...
      end
      

      Extra blank line detected.
      Open

      
        # Ensure that the unconfirmed email isn't already someone's email
      Severity: Minor
      Found in app/models/user.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
      

      Surrounding space detected in default value assignment.
      Open

        scope :halfyear_actives, ->(time = Time.now) { logged_in_since(time - 6.month) }
      Severity: Minor
      Found in app/models/user.rb by rubocop

      Checks that the equals signs in parameter default assignments have or don't have surrounding space depending on configuration.

      Example:

      # bad
      def some_method(arg1=:default, arg2=nil, arg3=[])
        # do something...
      end
      
      # good
      def some_method(arg1 = :default, arg2 = nil, arg3 = [])
        # do something...
      end
      

      Operator => should be surrounded by a single space.
      Open

        validates_format_of :unconfirmed_email, :with  => Devise.email_regexp, :allow_blank => true
      Severity: Minor
      Found in app/models/user.rb by rubocop

      Checks that operators have space around them, except for ** which should not have surrounding space.

      Example:

      # bad
      total = 3*4
      "apple"+"juice"
      my_number = 38/4
      a ** b
      
      # good
      total = 3 * 4
      "apple" + "juice"
      my_number = 38 / 4
      a**b
      

      Space inside parentheses detected.
      Open

          update_profile( self.profile.from_omniauth_hash( user_info ) )
      Severity: Minor
      Found in app/models/user.rb by rubocop

      Checks for spaces inside ordinary round parentheses.

      Example:

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

      Use == if you meant to do a comparison or move the assignment up out of the condition.
      Open

          if photo = params.delete(:photo)
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop checks for assignments in the conditions of if/while/until.

      Example:

      # bad
      
      if some_var = true
        do_something
      end
      

      Example:

      # good
      
      if some_var == true
        do_something
      end
      

      Use the new Ruby 1.9 hash syntax.
      Open

        validates_length_of :username, :maximum => 32
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop checks hash literal syntax.

      It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

      A separate offense is registered for each problematic pair.

      The supported styles are:

      • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
      • hash_rockets - forces use of hash rockets for all hashes
      • nomixedkeys - simply checks for hashes with mixed syntaxes
      • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

      Example: EnforcedStyle: ruby19 (default)

      # bad
      {:a => 2}
      {b: 1, :c => 2}
      
      # good
      {a: 2, b: 1}
      {:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
      {d: 1, 'e' => 2} # technically not forbidden
      

      Example: EnforcedStyle: hash_rockets

      # bad
      {a: 1, b: 2}
      {c: 1, 'd' => 5}
      
      # good
      {:a => 1, :b => 2}
      

      Example: EnforcedStyle: nomixedkeys

      # bad
      {:a => 1, b: 2}
      {c: 1, 'd' => 2}
      
      # good
      {:a => 1, :b => 2}
      {c: 1, d: 2}
      

      Example: EnforcedStyle: ruby19nomixed_keys

      # bad
      {:a => 1, :b => 2}
      {c: 2, 'd' => 3} # should just use hash rockets
      
      # good
      {a: 1, b: 2}
      {:c => 3, 'd' => 4}
      

      Surrounding space detected in default value assignment.
      Open

        scope :daily_actives, ->(time = Time.now) { logged_in_since(time - 1.day) }
      Severity: Minor
      Found in app/models/user.rb by rubocop

      Checks that the equals signs in parameter default assignments have or don't have surrounding space depending on configuration.

      Example:

      # bad
      def some_method(arg1=:default, arg2=nil, arg3=[])
        # do something...
      end
      
      # good
      def some_method(arg1 = :default, arg2 = nil, arg3 = [])
        # do something...
      end
      

      Surrounding space detected in default value assignment.
      Open

        def has_hidden_shareables_of_type?(t = Post)
      Severity: Minor
      Found in app/models/user.rb by rubocop

      Checks that the equals signs in parameter default assignments have or don't have surrounding space depending on configuration.

      Example:

      # bad
      def some_method(arg1=:default, arg2=nil, arg3=[])
        # do something...
      end
      
      # good
      def some_method(arg1 = :default, arg2 = nil, arg3 = [])
        # do something...
      end
      

      Space missing to the left of {.
      Open

            UserPreference::VALID_EMAIL_TYPES.each{|x| self.user_preferences.find_or_create_by(email_type: x)}
      Severity: Minor
      Found in app/models/user.rb by rubocop

      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
      }
      

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

          if self.username_changed? && Person.exists?(:diaspora_handle => diaspora_id)
      Severity: Minor
      Found in app/models/user.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 the new Ruby 1.9 hash syntax.
      Open

        validates :username, :presence => true, :uniqueness => true
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop checks hash literal syntax.

      It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

      A separate offense is registered for each problematic pair.

      The supported styles are:

      • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
      • hash_rockets - forces use of hash rockets for all hashes
      • nomixedkeys - simply checks for hashes with mixed syntaxes
      • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

      Example: EnforcedStyle: ruby19 (default)

      # bad
      {:a => 2}
      {b: 1, :c => 2}
      
      # good
      {a: 2, b: 1}
      {:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
      {d: 1, 'e' => 2} # technically not forbidden
      

      Example: EnforcedStyle: hash_rockets

      # bad
      {a: 1, b: 2}
      {c: 1, 'd' => 5}
      
      # good
      {:a => 1, :b => 2}
      

      Example: EnforcedStyle: nomixedkeys

      # bad
      {:a => 1, b: 2}
      {c: 1, 'd' => 2}
      
      # good
      {:a => 1, :b => 2}
      {c: 1, d: 2}
      

      Example: EnforcedStyle: ruby19nomixed_keys

      # bad
      {:a => 1, :b => 2}
      {c: 2, 'd' => 3} # should just use hash rockets
      
      # good
      {a: 1, b: 2}
      {:c => 3, 'd' => 4}
      

      Use the new Ruby 1.9 hash syntax.
      Open

        has_many :notifications, :foreign_key => :recipient_id
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop checks hash literal syntax.

      It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

      A separate offense is registered for each problematic pair.

      The supported styles are:

      • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
      • hash_rockets - forces use of hash rockets for all hashes
      • nomixedkeys - simply checks for hashes with mixed syntaxes
      • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

      Example: EnforcedStyle: ruby19 (default)

      # bad
      {:a => 2}
      {b: 1, :c => 2}
      
      # good
      {a: 2, b: 1}
      {:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
      {d: 1, 'e' => 2} # technically not forbidden
      

      Example: EnforcedStyle: hash_rockets

      # bad
      {a: 1, b: 2}
      {c: 1, 'd' => 5}
      
      # good
      {:a => 1, :b => 2}
      

      Example: EnforcedStyle: nomixedkeys

      # bad
      {:a => 1, b: 2}
      {c: 1, 'd' => 2}
      
      # good
      {:a => 1, :b => 2}
      {c: 1, d: 2}
      

      Example: EnforcedStyle: ruby19nomixed_keys

      # bad
      {:a => 1, :b => 2}
      {c: 2, 'd' => 3} # should just use hash rockets
      
      # good
      {a: 1, b: 2}
      {:c => 3, 'd' => 4}
      

      Missing space after #.
      Open

        ###Helpers############
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop checks whether comments have a leading space after the # denoting the start of the comment. The leading space is not required for some RDoc special syntax, like #++, #--, #:nodoc, =begin- and =end comments, "shebang" directives, or rackup options.

      Example:

      # bad
      #Some comment
      
      # good
      # Some comment
      

      Space inside parentheses detected.
      Open

          update_profile( self.profile.from_omniauth_hash( user_info ) )
      Severity: Minor
      Found in app/models/user.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_shareable_hidden? to shareable_hidden?.
      Open

        def is_shareable_hidden?(shareable)
      Severity: Minor
      Found in app/models/user.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 User.exists?(["id != ? AND email = ?", id, unconfirmed_email])
      Severity: Minor
      Found in app/models/user.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 the new Ruby 1.9 hash syntax.
      Open

        before_validation :set_current_language, :on => :create
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop checks hash literal syntax.

      It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

      A separate offense is registered for each problematic pair.

      The supported styles are:

      • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
      • hash_rockets - forces use of hash rockets for all hashes
      • nomixedkeys - simply checks for hashes with mixed syntaxes
      • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

      Example: EnforcedStyle: ruby19 (default)

      # bad
      {:a => 2}
      {b: 1, :c => 2}
      
      # good
      {a: 2, b: 1}
      {:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
      {d: 1, 'e' => 2} # technically not forbidden
      

      Example: EnforcedStyle: hash_rockets

      # bad
      {a: 1, b: 2}
      {c: 1, 'd' => 5}
      
      # good
      {:a => 1, :b => 2}
      

      Example: EnforcedStyle: nomixedkeys

      # bad
      {:a => 1, b: 2}
      {c: 1, 'd' => 2}
      
      # good
      {:a => 1, :b => 2}
      {c: 1, d: 2}
      

      Example: EnforcedStyle: ruby19nomixed_keys

      # bad
      {:a => 1, :b => 2}
      {c: 2, 'd' => 3} # should just use hash rockets
      
      # good
      {a: 1, b: 2}
      {:c => 3, 'd' => 4}
      

      Use the new Ruby 1.9 hash syntax.
      Open

        validates :username, :presence => true, :uniqueness => true
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop checks hash literal syntax.

      It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

      A separate offense is registered for each problematic pair.

      The supported styles are:

      • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
      • hash_rockets - forces use of hash rockets for all hashes
      • nomixedkeys - simply checks for hashes with mixed syntaxes
      • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

      Example: EnforcedStyle: ruby19 (default)

      # bad
      {:a => 2}
      {b: 1, :c => 2}
      
      # good
      {a: 2, b: 1}
      {:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
      {d: 1, 'e' => 2} # technically not forbidden
      

      Example: EnforcedStyle: hash_rockets

      # bad
      {a: 1, b: 2}
      {c: 1, 'd' => 5}
      
      # good
      {:a => 1, :b => 2}
      

      Example: EnforcedStyle: nomixedkeys

      # bad
      {:a => 1, b: 2}
      {c: 1, 'd' => 2}
      
      # good
      {:a => 1, :b => 2}
      {c: 1, d: 2}
      

      Example: EnforcedStyle: ruby19nomixed_keys

      # bad
      {:a => 1, :b => 2}
      {c: 2, 'd' => 3} # should just use hash rockets
      
      # good
      {a: 1, b: 2}
      {:c => 3, 'd' => 4}
      

      Use the new Ruby 1.9 hash syntax.
      Open

        has_many :followed_tags, -> { order('tags.name') }, :through => :tag_followings, :source => :tag
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop checks hash literal syntax.

      It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

      A separate offense is registered for each problematic pair.

      The supported styles are:

      • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
      • hash_rockets - forces use of hash rockets for all hashes
      • nomixedkeys - simply checks for hashes with mixed syntaxes
      • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

      Example: EnforcedStyle: ruby19 (default)

      # bad
      {:a => 2}
      {b: 1, :c => 2}
      
      # good
      {a: 2, b: 1}
      {:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
      {d: 1, 'e' => 2} # technically not forbidden
      

      Example: EnforcedStyle: hash_rockets

      # bad
      {a: 1, b: 2}
      {c: 1, 'd' => 5}
      
      # good
      {:a => 1, :b => 2}
      

      Example: EnforcedStyle: nomixedkeys

      # bad
      {:a => 1, b: 2}
      {c: 1, 'd' => 2}
      
      # good
      {:a => 1, :b => 2}
      {c: 1, d: 2}
      

      Example: EnforcedStyle: ruby19nomixed_keys

      # bad
      {:a => 1, :b => 2}
      {c: 2, 'd' => 3} # should just use hash rockets
      
      # good
      {a: 1, b: 2}
      {:c => 3, 'd' => 4}
      

      Surrounding space missing for operator +.
      Open

          params.slice!(*(Profile.column_names+['tag_string', 'date']))
      Severity: Minor
      Found in app/models/user.rb by rubocop

      Checks that operators have space around them, except for ** which should not have surrounding space.

      Example:

      # bad
      total = 3*4
      "apple"+"juice"
      my_number = 38/4
      a ** b
      
      # good
      total = 3 * 4
      "apple" + "juice"
      my_number = 38 / 4
      a**b
      

      Space missing inside }.
      Open

            UserPreference::VALID_EMAIL_TYPES.each{|x| self.user_preferences.find_or_create_by(email_type: x)}
      Severity: Minor
      Found in app/models/user.rb by rubocop

      Checks that block braces have or don't have surrounding space inside them on configuration. For blocks taking parameters, it checks that the left brace has or doesn't have trailing space depending on configuration.

      Example: EnforcedStyle: space (default)

      # The `space` style enforces that block braces have
      # surrounding space.
      
      # bad
      some_array.each {puts e}
      
      # good
      some_array.each { puts e }
      

      Example: EnforcedStyle: no_space

      # The `no_space` style enforces that block braces don't
      # have surrounding space.
      
      # bad
      some_array.each { puts e }
      
      # good
      some_array.each {puts e}
      

      Example: EnforcedStyleForEmptyBraces: no_space (default)

      # The `no_space` EnforcedStyleForEmptyBraces style enforces that
      # block braces don't have a space in between when empty.
      
      # bad
      some_array.each {   }
      some_array.each {  }
      some_array.each { }
      
      # good
      some_array.each {}
      

      Example: EnforcedStyleForEmptyBraces: space

      # The `space` EnforcedStyleForEmptyBraces style enforces that
      # block braces have at least a spece in between when empty.
      
      # bad
      some_array.each {}
      
      # good
      some_array.each { }
      some_array.each {  }
      some_array.each {   }
      

      Example: SpaceBeforeBlockParameters: true (default)

      # The SpaceBeforeBlockParameters style set to `true` enforces that
      # there is a space between `{` and `|`. Overrides `EnforcedStyle`
      # if there is a conflict.
      
      # bad
      [1, 2, 3].each {|n| n * 2 }
      
      # good
      [1, 2, 3].each { |n| n * 2 }
      

      Example: SpaceBeforeBlockParameters: true

      # The SpaceBeforeBlockParameters style set to `false` enforces that
      # there is no space between `{` and `|`. Overrides `EnforcedStyle`
      # if there is a conflict.
      
      # bad
      [1, 2, 3].each { |n| n * 2 }
      
      # good
      [1, 2, 3].each {|n| n * 2 }
      

      Do not prefix writer method names with set_.
      Open

        def set_person(person)
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop makes sure that accessor methods are named properly.

      Example:

      # bad
      def set_attribute(value)
      end
      
      # good
      def attribute=(value)
      end
      
      # bad
      def get_attribute
      end
      
      # good
      def attribute
      end
      

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

            if self.like_for(target)
      Severity: Minor
      Found in app/models/user.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 the new Ruby 1.9 hash syntax.
      Open

          User.joins(:contacts).where(:contacts => {:person_id => person.id})
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop checks hash literal syntax.

      It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

      A separate offense is registered for each problematic pair.

      The supported styles are:

      • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
      • hash_rockets - forces use of hash rockets for all hashes
      • nomixedkeys - simply checks for hashes with mixed syntaxes
      • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

      Example: EnforcedStyle: ruby19 (default)

      # bad
      {:a => 2}
      {b: 1, :c => 2}
      
      # good
      {a: 2, b: 1}
      {:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
      {d: 1, 'e' => 2} # technically not forbidden
      

      Example: EnforcedStyle: hash_rockets

      # bad
      {a: 1, b: 2}
      {c: 1, 'd' => 5}
      
      # good
      {:a => 1, :b => 2}
      

      Example: EnforcedStyle: nomixedkeys

      # bad
      {:a => 1, b: 2}
      {c: 1, 'd' => 2}
      
      # good
      {:a => 1, :b => 2}
      {c: 1, d: 2}
      

      Example: EnforcedStyle: ruby19nomixed_keys

      # bad
      {:a => 1, :b => 2}
      {c: 2, 'd' => 3} # should just use hash rockets
      
      # good
      {a: 1, b: 2}
      {:c => 3, 'd' => 4}
      

      Space inside parentheses detected.
      Open

          update_profile( self.profile.from_omniauth_hash( user_info ) )
      Severity: Minor
      Found in app/models/user.rb by rubocop

      Checks for spaces inside ordinary round parentheses.

      Example:

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

      Surrounding space detected in default value assignment.
      Open

        scope :yearly_actives, ->(time = Time.now) { logged_in_since(time - 1.year) }
      Severity: Minor
      Found in app/models/user.rb by rubocop

      Checks that the equals signs in parameter default assignments have or don't have surrounding space depending on configuration.

      Example:

      # bad
      def some_method(arg1=:default, arg2=nil, arg3=[])
        # do something...
      end
      
      # good
      def some_method(arg1 = :default, arg2 = nil, arg3 = [])
        # do something...
      end
      

      Use the new Ruby 1.9 hash syntax.
      Open

        has_many :contact_people, :through => :contacts, :source => :person
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop checks hash literal syntax.

      It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

      A separate offense is registered for each problematic pair.

      The supported styles are:

      • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
      • hash_rockets - forces use of hash rockets for all hashes
      • nomixedkeys - simply checks for hashes with mixed syntaxes
      • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

      Example: EnforcedStyle: ruby19 (default)

      # bad
      {:a => 2}
      {b: 1, :c => 2}
      
      # good
      {a: 2, b: 1}
      {:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
      {d: 1, 'e' => 2} # technically not forbidden
      

      Example: EnforcedStyle: hash_rockets

      # bad
      {a: 1, b: 2}
      {c: 1, 'd' => 5}
      
      # good
      {:a => 1, :b => 2}
      

      Example: EnforcedStyle: nomixedkeys

      # bad
      {:a => 1, b: 2}
      {c: 1, 'd' => 2}
      
      # good
      {:a => 1, :b => 2}
      {c: 1, d: 2}
      

      Example: EnforcedStyle: ruby19nomixed_keys

      # bad
      {:a => 1, :b => 2}
      {c: 2, 'd' => 3} # should just use hash rockets
      
      # good
      {a: 1, b: 2}
      {:c => 3, 'd' => 4}
      

      Space inside parentheses detected.
      Open

        def update_profile_with_omniauth( user_info )
      Severity: Minor
      Found in app/models/user.rb by rubocop

      Checks for spaces inside ordinary round parentheses.

      Example:

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

      Use alias instead of alias_method in a class body.
      Open

        alias_method :send_reset_password_instructions!, :send_reset_password_instructions
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop enforces the use of either #alias or #alias_method depending on configuration. It also flags uses of alias :symbol rather than alias bareword.

      Example: EnforcedStyle: prefer_alias (default)

      # bad
      alias_method :bar, :foo
      alias :bar :foo
      
      # good
      alias bar foo
      

      Example: EnforcedStyle: preferaliasmethod

      # bad
      alias :bar :foo
      alias bar foo
      
      # good
      alias_method :bar, :foo
      

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

          if self.hidden_shareables.has_key?(key)
      Severity: Minor
      Found in app/models/user.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 username.present?
      Severity: Minor
      Found in app/models/user.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 the new Ruby 1.9 hash syntax.
      Open

        validates_format_of :username, :with => /\A[A-Za-z0-9_]+\z/
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop checks hash literal syntax.

      It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

      A separate offense is registered for each problematic pair.

      The supported styles are:

      • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
      • hash_rockets - forces use of hash rockets for all hashes
      • nomixedkeys - simply checks for hashes with mixed syntaxes
      • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

      Example: EnforcedStyle: ruby19 (default)

      # bad
      {:a => 2}
      {b: 1, :c => 2}
      
      # good
      {a: 2, b: 1}
      {:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
      {d: 1, 'e' => 2} # technically not forbidden
      

      Example: EnforcedStyle: hash_rockets

      # bad
      {a: 1, b: 2}
      {c: 1, 'd' => 5}
      
      # good
      {:a => 1, :b => 2}
      

      Example: EnforcedStyle: nomixedkeys

      # bad
      {:a => 1, b: 2}
      {c: 1, 'd' => 2}
      
      # good
      {:a => 1, :b => 2}
      {c: 1, d: 2}
      

      Example: EnforcedStyle: ruby19nomixed_keys

      # bad
      {:a => 1, :b => 2}
      {c: 2, 'd' => 3} # should just use hash rockets
      
      # good
      {a: 1, b: 2}
      {:c => 3, 'd' => 4}
      

      Use the new Ruby 1.9 hash syntax.
      Open

        has_many :contact_people, :through => :contacts, :source => :person
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop checks hash literal syntax.

      It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

      A separate offense is registered for each problematic pair.

      The supported styles are:

      • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
      • hash_rockets - forces use of hash rockets for all hashes
      • nomixedkeys - simply checks for hashes with mixed syntaxes
      • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

      Example: EnforcedStyle: ruby19 (default)

      # bad
      {:a => 2}
      {b: 1, :c => 2}
      
      # good
      {a: 2, b: 1}
      {:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
      {d: 1, 'e' => 2} # technically not forbidden
      

      Example: EnforcedStyle: hash_rockets

      # bad
      {a: 1, b: 2}
      {c: 1, 'd' => 5}
      
      # good
      {:a => 1, :b => 2}
      

      Example: EnforcedStyle: nomixedkeys

      # bad
      {:a => 1, b: 2}
      {c: 1, 'd' => 2}
      
      # good
      {:a => 1, :b => 2}
      {c: 1, d: 2}
      

      Example: EnforcedStyle: ruby19nomixed_keys

      # bad
      {:a => 1, :b => 2}
      {c: 2, 'd' => 3} # should just use hash rockets
      
      # good
      {a: 1, b: 2}
      {:c => 3, 'd' => 4}
      

      Use the new Ruby 1.9 hash syntax.
      Open

        has_many :ignored_people, :through => :blocks, :source => :person
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop checks hash literal syntax.

      It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

      A separate offense is registered for each problematic pair.

      The supported styles are:

      • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
      • hash_rockets - forces use of hash rockets for all hashes
      • nomixedkeys - simply checks for hashes with mixed syntaxes
      • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

      Example: EnforcedStyle: ruby19 (default)

      # bad
      {:a => 2}
      {b: 1, :c => 2}
      
      # good
      {a: 2, b: 1}
      {:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
      {d: 1, 'e' => 2} # technically not forbidden
      

      Example: EnforcedStyle: hash_rockets

      # bad
      {a: 1, b: 2}
      {c: 1, 'd' => 5}
      
      # good
      {:a => 1, :b => 2}
      

      Example: EnforcedStyle: nomixedkeys

      # bad
      {:a => 1, b: 2}
      {c: 1, 'd' => 2}
      
      # good
      {:a => 1, :b => 2}
      {c: 1, d: 2}
      

      Example: EnforcedStyle: ruby19nomixed_keys

      # bad
      {:a => 1, :b => 2}
      {c: 2, 'd' => 3} # should just use hash rockets
      
      # good
      {a: 1, b: 2}
      {:c => 3, 'd' => 4}
      

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

          if target.present? && target.respond_to?(:user_id)
      Severity: Minor
      Found in app/models/user.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?
      

      Use the new Ruby 1.9 hash syntax.
      Open

        apply_simple_captcha :message => I18n.t('simple_captcha.message.failed'), :add_to_base => true
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop checks hash literal syntax.

      It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

      A separate offense is registered for each problematic pair.

      The supported styles are:

      • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
      • hash_rockets - forces use of hash rockets for all hashes
      • nomixedkeys - simply checks for hashes with mixed syntaxes
      • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

      Example: EnforcedStyle: ruby19 (default)

      # bad
      {:a => 2}
      {b: 1, :c => 2}
      
      # good
      {a: 2, b: 1}
      {:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
      {d: 1, 'e' => 2} # technically not forbidden
      

      Example: EnforcedStyle: hash_rockets

      # bad
      {a: 1, b: 2}
      {c: 1, 'd' => 5}
      
      # good
      {:a => 1, :b => 2}
      

      Example: EnforcedStyle: nomixedkeys

      # bad
      {:a => 1, b: 2}
      {c: 1, 'd' => 2}
      
      # good
      {:a => 1, :b => 2}
      {c: 1, d: 2}
      

      Example: EnforcedStyle: ruby19nomixed_keys

      # bad
      {:a => 1, :b => 2}
      {c: 2, 'd' => 3} # should just use hash rockets
      
      # good
      {a: 1, b: 2}
      {:c => 3, 'd' => 4}
      

      Redundant return detected.
      Open

              return false
      Severity: Minor
      Found in app/models/user.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 the new Ruby 1.9 hash syntax.
      Open

          if(self.disable_mail == false && !self.user_preferences.exists?(:email_type => pref))
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop checks hash literal syntax.

      It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

      A separate offense is registered for each problematic pair.

      The supported styles are:

      • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
      • hash_rockets - forces use of hash rockets for all hashes
      • nomixedkeys - simply checks for hashes with mixed syntaxes
      • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

      Example: EnforcedStyle: ruby19 (default)

      # bad
      {:a => 2}
      {b: 1, :c => 2}
      
      # good
      {a: 2, b: 1}
      {:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
      {d: 1, 'e' => 2} # technically not forbidden
      

      Example: EnforcedStyle: hash_rockets

      # bad
      {a: 1, b: 2}
      {c: 1, 'd' => 5}
      
      # good
      {:a => 1, :b => 2}
      

      Example: EnforcedStyle: nomixedkeys

      # bad
      {:a => 1, b: 2}
      {c: 1, 'd' => 2}
      
      # good
      {:a => 1, :b => 2}
      {c: 1, d: 2}
      

      Example: EnforcedStyle: ruby19nomixed_keys

      # bad
      {:a => 1, :b => 2}
      {c: 2, 'd' => 3} # should just use hash rockets
      
      # good
      {a: 1, b: 2}
      {:c => 3, 'd' => 4}
      

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

              if block
      Severity: Minor
      Found in app/models/user.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?
      

      Redundant self detected.
      Open

          self.hidden_shareables
      Severity: Minor
      Found in app/models/user.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
      

      Redundant self detected.
      Open

            self.save
      Severity: Minor
      Found in app/models/user.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
      

      Space inside parentheses detected.
      Open

          update_profile( self.profile.from_omniauth_hash( user_info ) )
      Severity: Minor
      Found in app/models/user.rb by rubocop

      Checks for spaces inside ordinary round parentheses.

      Example:

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

      Rename has_hidden_shareables_of_type? to hidden_shareables_of_type?.
      Open

        def has_hidden_shareables_of_type?(t = Post)
      Severity: Minor
      Found in app/models/user.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 the new Ruby 1.9 hash syntax.
      Open

        validates_inclusion_of :language, :in => AVAILABLE_LANGUAGE_CODES
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop checks hash literal syntax.

      It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

      A separate offense is registered for each problematic pair.

      The supported styles are:

      • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
      • hash_rockets - forces use of hash rockets for all hashes
      • nomixedkeys - simply checks for hashes with mixed syntaxes
      • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

      Example: EnforcedStyle: ruby19 (default)

      # bad
      {:a => 2}
      {b: 1, :c => 2}
      
      # good
      {a: 2, b: 1}
      {:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
      {d: 1, 'e' => 2} # technically not forbidden
      

      Example: EnforcedStyle: hash_rockets

      # bad
      {a: 1, b: 2}
      {c: 1, 'd' => 5}
      
      # good
      {:a => 1, :b => 2}
      

      Example: EnforcedStyle: nomixedkeys

      # bad
      {:a => 1, b: 2}
      {c: 1, 'd' => 2}
      
      # good
      {:a => 1, :b => 2}
      {c: 1, d: 2}
      

      Example: EnforcedStyle: ruby19nomixed_keys

      # bad
      {:a => 1, :b => 2}
      {c: 2, 'd' => 3} # should just use hash rockets
      
      # good
      {a: 1, b: 2}
      {:c => 3, 'd' => 4}
      

      Use the new Ruby 1.9 hash syntax.
      Open

        validates_format_of :unconfirmed_email, :with  => Devise.email_regexp, :allow_blank => true
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop checks hash literal syntax.

      It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

      A separate offense is registered for each problematic pair.

      The supported styles are:

      • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
      • hash_rockets - forces use of hash rockets for all hashes
      • nomixedkeys - simply checks for hashes with mixed syntaxes
      • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

      Example: EnforcedStyle: ruby19 (default)

      # bad
      {:a => 2}
      {b: 1, :c => 2}
      
      # good
      {a: 2, b: 1}
      {:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
      {d: 1, 'e' => 2} # technically not forbidden
      

      Example: EnforcedStyle: hash_rockets

      # bad
      {a: 1, b: 2}
      {c: 1, 'd' => 5}
      
      # good
      {:a => 1, :b => 2}
      

      Example: EnforcedStyle: nomixedkeys

      # bad
      {:a => 1, b: 2}
      {c: 1, 'd' => 2}
      
      # good
      {:a => 1, :b => 2}
      {c: 1, d: 2}
      

      Example: EnforcedStyle: ruby19nomixed_keys

      # bad
      {:a => 1, :b => 2}
      {c: 2, 'd' => 3} # should just use hash rockets
      
      # good
      {a: 1, b: 2}
      {:c => 3, 'd' => 4}
      

      Use the new Ruby 1.9 hash syntax.
      Open

        has_many :aspect_memberships, :through => :aspects
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop checks hash literal syntax.

      It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

      A separate offense is registered for each problematic pair.

      The supported styles are:

      • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
      • hash_rockets - forces use of hash rockets for all hashes
      • nomixedkeys - simply checks for hashes with mixed syntaxes
      • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

      Example: EnforcedStyle: ruby19 (default)

      # bad
      {:a => 2}
      {b: 1, :c => 2}
      
      # good
      {a: 2, b: 1}
      {:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
      {d: 1, 'e' => 2} # technically not forbidden
      

      Example: EnforcedStyle: hash_rockets

      # bad
      {a: 1, b: 2}
      {c: 1, 'd' => 5}
      
      # good
      {:a => 1, :b => 2}
      

      Example: EnforcedStyle: nomixedkeys

      # bad
      {:a => 1, b: 2}
      {c: 1, 'd' => 2}
      
      # good
      {:a => 1, :b => 2}
      {c: 1, d: 2}
      

      Example: EnforcedStyle: ruby19nomixed_keys

      # bad
      {:a => 1, :b => 2}
      {c: 2, 'd' => 3} # should just use hash rockets
      
      # good
      {a: 1, b: 2}
      {:c => 3, 'd' => 4}
      

      Use the new Ruby 1.9 hash syntax.
      Open

        has_many :ignored_people, :through => :blocks, :source => :person
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop checks hash literal syntax.

      It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

      A separate offense is registered for each problematic pair.

      The supported styles are:

      • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
      • hash_rockets - forces use of hash rockets for all hashes
      • nomixedkeys - simply checks for hashes with mixed syntaxes
      • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

      Example: EnforcedStyle: ruby19 (default)

      # bad
      {:a => 2}
      {b: 1, :c => 2}
      
      # good
      {a: 2, b: 1}
      {:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
      {d: 1, 'e' => 2} # technically not forbidden
      

      Example: EnforcedStyle: hash_rockets

      # bad
      {a: 1, b: 2}
      {c: 1, 'd' => 5}
      
      # good
      {:a => 1, :b => 2}
      

      Example: EnforcedStyle: nomixedkeys

      # bad
      {:a => 1, b: 2}
      {c: 1, 'd' => 2}
      
      # good
      {:a => 1, :b => 2}
      {c: 1, d: 2}
      

      Example: EnforcedStyle: ruby19nomixed_keys

      # bad
      {:a => 1, :b => 2}
      {c: 2, 'd' => 3} # should just use hash rockets
      
      # good
      {a: 1, b: 2}
      {:c => 3, 'd' => 4}
      

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

          if self.hidden_shareables.has_key?(key)
      Severity: Minor
      Found in app/models/user.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?
      

      Space inside parentheses detected.
      Open

        def update_profile_with_omniauth( user_info )
      Severity: Minor
      Found in app/models/user.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 self.owns? post
      Severity: Minor
      Found in app/models/user.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 self.person && self.person.serialized_public_key.blank?
      Severity: Minor
      Found in app/models/user.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 the new Ruby 1.9 hash syntax.
      Open

               :lockable, :lastseenable, :lock_strategy => :none, :unlock_strategy => :none
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop checks hash literal syntax.

      It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

      A separate offense is registered for each problematic pair.

      The supported styles are:

      • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
      • hash_rockets - forces use of hash rockets for all hashes
      • nomixedkeys - simply checks for hashes with mixed syntaxes
      • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

      Example: EnforcedStyle: ruby19 (default)

      # bad
      {:a => 2}
      {b: 1, :c => 2}
      
      # good
      {a: 2, b: 1}
      {:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
      {d: 1, 'e' => 2} # technically not forbidden
      

      Example: EnforcedStyle: hash_rockets

      # bad
      {a: 1, b: 2}
      {c: 1, 'd' => 5}
      
      # good
      {:a => 1, :b => 2}
      

      Example: EnforcedStyle: nomixedkeys

      # bad
      {:a => 1, b: 2}
      {c: 1, 'd' => 2}
      
      # good
      {:a => 1, :b => 2}
      {c: 1, d: 2}
      

      Example: EnforcedStyle: ruby19nomixed_keys

      # bad
      {:a => 1, :b => 2}
      {c: 2, 'd' => 3} # should just use hash rockets
      
      # good
      {a: 1, b: 2}
      {:c => 3, 'd' => 4}
      

      Use the new Ruby 1.9 hash syntax.
      Open

        validates_format_of :unconfirmed_email, :with  => Devise.email_regexp, :allow_blank => true
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop checks hash literal syntax.

      It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

      A separate offense is registered for each problematic pair.

      The supported styles are:

      • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
      • hash_rockets - forces use of hash rockets for all hashes
      • nomixedkeys - simply checks for hashes with mixed syntaxes
      • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

      Example: EnforcedStyle: ruby19 (default)

      # bad
      {:a => 2}
      {b: 1, :c => 2}
      
      # good
      {a: 2, b: 1}
      {:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
      {d: 1, 'e' => 2} # technically not forbidden
      

      Example: EnforcedStyle: hash_rockets

      # bad
      {a: 1, b: 2}
      {c: 1, 'd' => 5}
      
      # good
      {:a => 1, :b => 2}
      

      Example: EnforcedStyle: nomixedkeys

      # bad
      {:a => 1, b: 2}
      {c: 1, 'd' => 2}
      
      # good
      {:a => 1, :b => 2}
      {c: 1, d: 2}
      

      Example: EnforcedStyle: ruby19nomixed_keys

      # bad
      {:a => 1, :b => 2}
      {c: 2, 'd' => 3} # should just use hash rockets
      
      # good
      {a: 1, b: 2}
      {:c => 3, 'd' => 4}
      

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

          if(self.disable_mail == false && !self.user_preferences.exists?(:email_type => pref))
      Severity: Minor
      Found in app/models/user.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?
      

      Redundant self detected.
      Open

          Workers::ResetPassword.perform_async(self.id)
      Severity: Minor
      Found in app/models/user.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
      

      Redundant self detected.
      Open

          self.update_attribute(:getting_started, false) if self.getting_started?
      Severity: Minor
      Found in app/models/user.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
      

      Redundant self detected.
      Open

          self.language = I18n.locale.to_s if self.language.blank?
      Severity: Minor
      Found in app/models/user.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
      

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

          if(self.disable_mail == false && !self.user_preferences.exists?(:email_type => pref))
      Severity: Minor
      Found in app/models/user.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 the new Ruby 1.9 hash syntax.
      Open

        has_many :followed_tags, -> { order('tags.name') }, :through => :tag_followings, :source => :tag
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop checks hash literal syntax.

      It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

      A separate offense is registered for each problematic pair.

      The supported styles are:

      • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
      • hash_rockets - forces use of hash rockets for all hashes
      • nomixedkeys - simply checks for hashes with mixed syntaxes
      • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

      Example: EnforcedStyle: ruby19 (default)

      # bad
      {:a => 2}
      {b: 1, :c => 2}
      
      # good
      {a: 2, b: 1}
      {:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
      {d: 1, 'e' => 2} # technically not forbidden
      

      Example: EnforcedStyle: hash_rockets

      # bad
      {a: 1, b: 2}
      {c: 1, 'd' => 5}
      
      # good
      {:a => 1, :b => 2}
      

      Example: EnforcedStyle: nomixedkeys

      # bad
      {:a => 1, b: 2}
      {c: 1, 'd' => 2}
      
      # good
      {:a => 1, :b => 2}
      {c: 1, d: 2}
      

      Example: EnforcedStyle: ruby19nomixed_keys

      # bad
      {:a => 1, :b => 2}
      {c: 2, 'd' => 3} # should just use hash rockets
      
      # good
      {a: 1, b: 2}
      {:c => 3, 'd' => 4}
      

      Use the new Ruby 1.9 hash syntax.
      Open

          User.joins(:contacts).where(:contacts => {:person_id => person.id})
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop checks hash literal syntax.

      It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

      A separate offense is registered for each problematic pair.

      The supported styles are:

      • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
      • hash_rockets - forces use of hash rockets for all hashes
      • nomixedkeys - simply checks for hashes with mixed syntaxes
      • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

      Example: EnforcedStyle: ruby19 (default)

      # bad
      {:a => 2}
      {b: 1, :c => 2}
      
      # good
      {a: 2, b: 1}
      {:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
      {d: 1, 'e' => 2} # technically not forbidden
      

      Example: EnforcedStyle: hash_rockets

      # bad
      {a: 1, b: 2}
      {c: 1, 'd' => 5}
      
      # good
      {:a => 1, :b => 2}
      

      Example: EnforcedStyle: nomixedkeys

      # bad
      {:a => 1, b: 2}
      {c: 1, 'd' => 2}
      
      # good
      {:a => 1, :b => 2}
      {c: 1, d: 2}
      

      Example: EnforcedStyle: ruby19nomixed_keys

      # bad
      {:a => 1, :b => 2}
      {c: 2, 'd' => 3} # should just use hash rockets
      
      # good
      {a: 1, b: 2}
      {:c => 3, 'd' => 4}
      

      Redundant self detected.
      Open

          if self.hidden_shareables.has_key?(shareable_type)
      Severity: Minor
      Found in app/models/user.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
      

      Use the new Ruby 1.9 hash syntax.
      Open

            photo.update_attributes(:pending => false) if photo.pending
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop checks hash literal syntax.

      It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

      A separate offense is registered for each problematic pair.

      The supported styles are:

      • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
      • hash_rockets - forces use of hash rockets for all hashes
      • nomixedkeys - simply checks for hashes with mixed syntaxes
      • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

      Example: EnforcedStyle: ruby19 (default)

      # bad
      {:a => 2}
      {b: 1, :c => 2}
      
      # good
      {a: 2, b: 1}
      {:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
      {d: 1, 'e' => 2} # technically not forbidden
      

      Example: EnforcedStyle: hash_rockets

      # bad
      {a: 1, b: 2}
      {c: 1, 'd' => 5}
      
      # good
      {:a => 1, :b => 2}
      

      Example: EnforcedStyle: nomixedkeys

      # bad
      {:a => 1, b: 2}
      {c: 1, 'd' => 2}
      
      # good
      {:a => 1, :b => 2}
      {c: 1, d: 2}
      

      Example: EnforcedStyle: ruby19nomixed_keys

      # bad
      {:a => 1, :b => 2}
      {c: 2, 'd' => 3} # should just use hash rockets
      
      # good
      {a: 1, b: 2}
      {:c => 3, 'd' => 4}
      

      Use the new Ruby 1.9 hash syntax.
      Open

          notifications.where(:unread => true)
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop checks hash literal syntax.

      It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

      A separate offense is registered for each problematic pair.

      The supported styles are:

      • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
      • hash_rockets - forces use of hash rockets for all hashes
      • nomixedkeys - simply checks for hashes with mixed syntaxes
      • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

      Example: EnforcedStyle: ruby19 (default)

      # bad
      {:a => 2}
      {b: 1, :c => 2}
      
      # good
      {a: 2, b: 1}
      {:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
      {d: 1, 'e' => 2} # technically not forbidden
      

      Example: EnforcedStyle: hash_rockets

      # bad
      {a: 1, b: 2}
      {c: 1, 'd' => 5}
      
      # good
      {:a => 1, :b => 2}
      

      Example: EnforcedStyle: nomixedkeys

      # bad
      {:a => 1, b: 2}
      {c: 1, 'd' => 2}
      
      # good
      {:a => 1, :b => 2}
      {c: 1, d: 2}
      

      Example: EnforcedStyle: ruby19nomixed_keys

      # bad
      {:a => 1, :b => 2}
      {c: 2, 'd' => 3} # should just use hash rockets
      
      # good
      {a: 1, b: 2}
      {:c => 3, 'd' => 4}
      

      Redundant self detected.
      Open

          self.hidden_shareables[share_type].present?
      Severity: Minor
      Found in app/models/user.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
      

      Use the new Ruby 1.9 hash syntax.
      Open

            Like.exists?(:author_id => self.person.id, :target_type => target.class.base_class.to_s, :target_id => target.id)
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop checks hash literal syntax.

      It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

      A separate offense is registered for each problematic pair.

      The supported styles are:

      • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
      • hash_rockets - forces use of hash rockets for all hashes
      • nomixedkeys - simply checks for hashes with mixed syntaxes
      • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

      Example: EnforcedStyle: ruby19 (default)

      # bad
      {:a => 2}
      {b: 1, :c => 2}
      
      # good
      {a: 2, b: 1}
      {:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
      {d: 1, 'e' => 2} # technically not forbidden
      

      Example: EnforcedStyle: hash_rockets

      # bad
      {a: 1, b: 2}
      {c: 1, 'd' => 5}
      
      # good
      {:a => 1, :b => 2}
      

      Example: EnforcedStyle: nomixedkeys

      # bad
      {:a => 1, b: 2}
      {c: 1, 'd' => 2}
      
      # good
      {:a => 1, :b => 2}
      {c: 1, d: 2}
      

      Example: EnforcedStyle: ruby19nomixed_keys

      # bad
      {:a => 1, :b => 2}
      {c: 2, 'd' => 3} # should just use hash rockets
      
      # good
      {a: 1, b: 2}
      {:c => 3, 'd' => 4}
      

      Use the new Ruby 1.9 hash syntax.
      Open

          aq = self.aspects.create(:name => I18n.t('aspects.seed.acquaintances'))
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop checks hash literal syntax.

      It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

      A separate offense is registered for each problematic pair.

      The supported styles are:

      • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
      • hash_rockets - forces use of hash rockets for all hashes
      • nomixedkeys - simply checks for hashes with mixed syntaxes
      • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

      Example: EnforcedStyle: ruby19 (default)

      # bad
      {:a => 2}
      {b: 1, :c => 2}
      
      # good
      {a: 2, b: 1}
      {:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
      {d: 1, 'e' => 2} # technically not forbidden
      

      Example: EnforcedStyle: hash_rockets

      # bad
      {a: 1, b: 2}
      {c: 1, 'd' => 5}
      
      # good
      {:a => 1, :b => 2}
      

      Example: EnforcedStyle: nomixedkeys

      # bad
      {:a => 1, b: 2}
      {c: 1, 'd' => 2}
      
      # good
      {:a => 1, :b => 2}
      {c: 1, d: 2}
      

      Example: EnforcedStyle: ruby19nomixed_keys

      # bad
      {:a => 1, :b => 2}
      {c: 2, 'd' => 3} # should just use hash rockets
      
      # good
      {a: 1, b: 2}
      {:c => 3, 'd' => 4}
      

      Avoid comparing a variable with multiple items in a conditional, use Array#include? instead.
      Open

          if aspect_ids == "all" || aspect_ids == :all
            self.aspects
          else
            aspects.where(:id => aspect_ids).to_a
          end
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop checks against comparing a variable with multiple items, where Array#include? could be used instead to avoid code repetition.

      Example:

      # bad
      a = 'a'
      foo if a == 'a' || a == 'b' || a == 'c'
      
      # good
      a = 'a'
      foo if ['a', 'b', 'c'].include?(a)
      

      Redundant self detected.
      Open

          self.save unless opts[:batch]
      Severity: Minor
      Found in app/models/user.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
      

      Use the new Ruby 1.9 hash syntax.
      Open

          if self.username_changed? && Person.exists?(:diaspora_handle => diaspora_id)
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop checks hash literal syntax.

      It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

      A separate offense is registered for each problematic pair.

      The supported styles are:

      • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
      • hash_rockets - forces use of hash rockets for all hashes
      • nomixedkeys - simply checks for hashes with mixed syntaxes
      • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

      Example: EnforcedStyle: ruby19 (default)

      # bad
      {:a => 2}
      {b: 1, :c => 2}
      
      # good
      {a: 2, b: 1}
      {:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
      {d: 1, 'e' => 2} # technically not forbidden
      

      Example: EnforcedStyle: hash_rockets

      # bad
      {a: 1, b: 2}
      {c: 1, 'd' => 5}
      
      # good
      {:a => 1, :b => 2}
      

      Example: EnforcedStyle: nomixedkeys

      # bad
      {:a => 1, b: 2}
      {c: 1, 'd' => 2}
      
      # good
      {:a => 1, :b => 2}
      {c: 1, d: 2}
      

      Example: EnforcedStyle: ruby19nomixed_keys

      # bad
      {:a => 1, :b => 2}
      {c: 2, 'd' => 3} # should just use hash rockets
      
      # good
      {a: 1, b: 2}
      {:c => 3, 'd' => 4}
      

      Redundant self detected.
      Open

            self.save
      Severity: Minor
      Found in app/models/user.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
      

      Redundant self detected.
      Open

          ConversationVisibility.where(person_id: self.person_id).sum(:unread)
      Severity: Minor
      Found in app/models/user.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
      

      Redundant self detected.
      Open

            self.hidden_shareables[key].delete(share_id)
      Severity: Minor
      Found in app/models/user.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
      

      Redundant self detected.
      Open

            self.dispatch_post(post)
      Severity: Minor
      Found in app/models/user.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
      

      Use the new Ruby 1.9 hash syntax.
      Open

            aspects.where(:id => aspect_ids).to_a
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop checks hash literal syntax.

      It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

      A separate offense is registered for each problematic pair.

      The supported styles are:

      • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
      • hash_rockets - forces use of hash rockets for all hashes
      • nomixedkeys - simply checks for hashes with mixed syntaxes
      • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

      Example: EnforcedStyle: ruby19 (default)

      # bad
      {:a => 2}
      {b: 1, :c => 2}
      
      # good
      {a: 2, b: 1}
      {:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
      {d: 1, 'e' => 2} # technically not forbidden
      

      Example: EnforcedStyle: hash_rockets

      # bad
      {a: 1, b: 2}
      {c: 1, 'd' => 5}
      
      # good
      {:a => 1, :b => 2}
      

      Example: EnforcedStyle: nomixedkeys

      # bad
      {:a => 1, b: 2}
      {c: 1, 'd' => 2}
      
      # good
      {:a => 1, :b => 2}
      {c: 1, d: 2}
      

      Example: EnforcedStyle: ruby19nomixed_keys

      # bad
      {:a => 1, :b => 2}
      {c: 2, 'd' => 3} # should just use hash rockets
      
      # good
      {a: 1, b: 2}
      {:c => 3, 'd' => 4}
      

      Use the new Ruby 1.9 hash syntax.
      Open

          self.aspects.create(:name => I18n.t('aspects.seed.family'))
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop checks hash literal syntax.

      It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

      A separate offense is registered for each problematic pair.

      The supported styles are:

      • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
      • hash_rockets - forces use of hash rockets for all hashes
      • nomixedkeys - simply checks for hashes with mixed syntaxes
      • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

      Example: EnforcedStyle: ruby19 (default)

      # bad
      {:a => 2}
      {b: 1, :c => 2}
      
      # good
      {a: 2, b: 1}
      {:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
      {d: 1, 'e' => 2} # technically not forbidden
      

      Example: EnforcedStyle: hash_rockets

      # bad
      {a: 1, b: 2}
      {c: 1, 'd' => 5}
      
      # good
      {:a => 1, :b => 2}
      

      Example: EnforcedStyle: nomixedkeys

      # bad
      {:a => 1, b: 2}
      {c: 1, 'd' => 2}
      
      # good
      {:a => 1, :b => 2}
      {c: 1, d: 2}
      

      Example: EnforcedStyle: ruby19nomixed_keys

      # bad
      {:a => 1, :b => 2}
      {c: 2, 'd' => 3} # should just use hash rockets
      
      # good
      {a: 1, b: 2}
      {:c => 3, 'd' => 4}
      

      Redundant return detected.
      Open

              return true
      Severity: Minor
      Found in app/models/user.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 self detected.
      Open

          if self.hidden_shareables.has_key?(key)
      Severity: Minor
      Found in app/models/user.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
      

      Redundant self detected.
      Open

            self.remove_hidden_shareable(key, share_id)
      Severity: Minor
      Found in app/models/user.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
      

      Redundant self detected.
      Open

            self.save
      Severity: Minor
      Found in app/models/user.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
      

      Use the new Ruby 1.9 hash syntax.
      Open

          self.aspects.create(:name => I18n.t('aspects.seed.work'))
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop checks hash literal syntax.

      It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

      A separate offense is registered for each problematic pair.

      The supported styles are:

      • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
      • hash_rockets - forces use of hash rockets for all hashes
      • nomixedkeys - simply checks for hashes with mixed syntaxes
      • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

      Example: EnforcedStyle: ruby19 (default)

      # bad
      {:a => 2}
      {b: 1, :c => 2}
      
      # good
      {a: 2, b: 1}
      {:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
      {d: 1, 'e' => 2} # technically not forbidden
      

      Example: EnforcedStyle: hash_rockets

      # bad
      {a: 1, b: 2}
      {c: 1, 'd' => 5}
      
      # good
      {:a => 1, :b => 2}
      

      Example: EnforcedStyle: nomixedkeys

      # bad
      {:a => 1, b: 2}
      {c: 1, 'd' => 2}
      
      # good
      {:a => 1, :b => 2}
      {c: 1, d: 2}
      

      Example: EnforcedStyle: ruby19nomixed_keys

      # bad
      {:a => 1, :b => 2}
      {c: 2, 'd' => 3} # should just use hash rockets
      
      # good
      {a: 1, b: 2}
      {:c => 3, 'd' => 4}
      

      Use the new Ruby 1.9 hash syntax.
      Open

          self.save(:validate => false)
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop checks hash literal syntax.

      It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

      A separate offense is registered for each problematic pair.

      The supported styles are:

      • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
      • hash_rockets - forces use of hash rockets for all hashes
      • nomixedkeys - simply checks for hashes with mixed syntaxes
      • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

      Example: EnforcedStyle: ruby19 (default)

      # bad
      {:a => 2}
      {b: 1, :c => 2}
      
      # good
      {a: 2, b: 1}
      {:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
      {d: 1, 'e' => 2} # technically not forbidden
      

      Example: EnforcedStyle: hash_rockets

      # bad
      {a: 1, b: 2}
      {c: 1, 'd' => 5}
      
      # good
      {:a => 1, :b => 2}
      

      Example: EnforcedStyle: nomixedkeys

      # bad
      {:a => 1, b: 2}
      {c: 1, 'd' => 2}
      
      # good
      {:a => 1, :b => 2}
      {c: 1, d: 2}
      

      Example: EnforcedStyle: ruby19nomixed_keys

      # bad
      {:a => 1, :b => 2}
      {c: 2, 'd' => 3} # should just use hash rockets
      
      # good
      {a: 1, b: 2}
      {:c => 3, 'd' => 4}
      

      Redundant self detected.
      Open

            self.add_hidden_shareable(key, share_id)
      Severity: Minor
      Found in app/models/user.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
      

      Use the new Ruby 1.9 hash syntax.
      Open

            Like.exists?(:author_id => self.person.id, :target_type => target.class.base_class.to_s, :target_id => target.id)
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop checks hash literal syntax.

      It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

      A separate offense is registered for each problematic pair.

      The supported styles are:

      • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
      • hash_rockets - forces use of hash rockets for all hashes
      • nomixedkeys - simply checks for hashes with mixed syntaxes
      • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

      Example: EnforcedStyle: ruby19 (default)

      # bad
      {:a => 2}
      {b: 1, :c => 2}
      
      # good
      {a: 2, b: 1}
      {:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
      {d: 1, 'e' => 2} # technically not forbidden
      

      Example: EnforcedStyle: hash_rockets

      # bad
      {a: 1, b: 2}
      {c: 1, 'd' => 5}
      
      # good
      {:a => 1, :b => 2}
      

      Example: EnforcedStyle: nomixedkeys

      # bad
      {:a => 1, b: 2}
      {c: 1, 'd' => 2}
      
      # good
      {:a => 1, :b => 2}
      {c: 1, d: 2}
      

      Example: EnforcedStyle: ruby19nomixed_keys

      # bad
      {:a => 1, :b => 2}
      {c: 2, 'd' => 3} # should just use hash rockets
      
      # good
      {a: 1, b: 2}
      {:c => 3, 'd' => 4}
      

      %w-literals should be delimited by [ and ].
      Open

          attributes.keys - %w(id username encrypted_password created_at updated_at locked_at
                               serialized_private_key getting_started
                               disable_mail show_community_spotlight_in_stream
                               strip_exif email remove_after export exporting exported_at
                               exported_photos_file exporting_photos exported_photos_at)
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop enforces the consistent usage of %-literal delimiters.

      Specify the 'default' key to set all preferred delimiters at once. You can continue to specify individual preferred delimiters to override the default.

      Example:

      # Style/PercentLiteralDelimiters:
      #   PreferredDelimiters:
      #     default: '[]'
      #     '%i':    '()'
      
      # good
      %w[alpha beta] + %i(gamma delta)
      
      # bad
      %W(alpha #{beta})
      
      # bad
      %I(alpha beta)
      

      Redundant self detected.
      Open

          if self.hidden_shareables.has_key?(key)
      Severity: Minor
      Found in app/models/user.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
      

      Redundant self detected.
      Open

          if self.hidden_shareables.has_key?(key) && self.hidden_shareables[key].include?(share_id)
      Severity: Minor
      Found in app/models/user.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
      

      Redundant self detected.
      Open

            self.hidden_shareables[key] << share_id
      Severity: Minor
      Found in app/models/user.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
      

      Redundant self detected.
      Open

            self.hidden_shareables[key] = [share_id]
      Severity: Minor
      Found in app/models/user.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
      

      Redundant self detected.
      Open

          if self.disable_mail
      Severity: Minor
      Found in app/models/user.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
      

      Use the new Ruby 1.9 hash syntax.
      Open

          self.aspects.create(:name => I18n.t('aspects.seed.friends'))
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop checks hash literal syntax.

      It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

      A separate offense is registered for each problematic pair.

      The supported styles are:

      • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
      • hash_rockets - forces use of hash rockets for all hashes
      • nomixedkeys - simply checks for hashes with mixed syntaxes
      • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

      Example: EnforcedStyle: ruby19 (default)

      # bad
      {:a => 2}
      {b: 1, :c => 2}
      
      # good
      {a: 2, b: 1}
      {:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
      {d: 1, 'e' => 2} # technically not forbidden
      

      Example: EnforcedStyle: hash_rockets

      # bad
      {a: 1, b: 2}
      {c: 1, 'd' => 5}
      
      # good
      {:a => 1, :b => 2}
      

      Example: EnforcedStyle: nomixedkeys

      # bad
      {:a => 1, b: 2}
      {c: 1, 'd' => 2}
      
      # good
      {:a => 1, :b => 2}
      {c: 1, d: 2}
      

      Example: EnforcedStyle: ruby19nomixed_keys

      # bad
      {:a => 1, :b => 2}
      {c: 2, 'd' => 3} # should just use hash rockets
      
      # good
      {a: 1, b: 2}
      {:c => 3, 'd' => 4}
      

      Redundant self detected.
      Open

            self.hidden_shareables[shareable_type].include?(shareable.id.to_s)
      Severity: Minor
      Found in app/models/user.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
      

      Redundant self detected.
      Open

            UserPreference::VALID_EMAIL_TYPES.each{|x| self.user_preferences.find_or_create_by(email_type: x)}
      Severity: Minor
      Found in app/models/user.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
      

      Redundant self detected.
      Open

          self.update_attribute(:getting_started, false) if self.getting_started?
      Severity: Minor
      Found in app/models/user.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
      

      Redundant self detected.
      Open

          if(self.disable_mail == false && !self.user_preferences.exists?(:email_type => pref))
      Severity: Minor
      Found in app/models/user.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
      

      Redundant self detected.
      Open

          self.aspects.create(:name => I18n.t('aspects.seed.friends'))
      Severity: Minor
      Found in app/models/user.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
      

      Redundant self detected.
      Open

          if self.person && self.person.serialized_public_key.blank?
      Severity: Minor
      Found in app/models/user.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
      

      Redundant self detected.
      Open

          if self.person && self.person.serialized_public_key.blank?
      Severity: Minor
      Found in app/models/user.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
      

      Redundant self detected.
      Open

          unless self.remove_after.nil?
      Severity: Minor
      Found in app/models/user.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
      

      Redundant self detected.
      Open

            self.save
      Severity: Minor
      Found in app/models/user.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
      

      Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
      Open

          pref = job.to_s.gsub('Workers::Mail::', '').underscore
      Severity: Minor
      Found in app/models/user.rb by rubocop

      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"
      

      Redundant self detected.
      Open

          if(self.disable_mail == false && !self.user_preferences.exists?(:email_type => pref))
      Severity: Minor
      Found in app/models/user.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
      

      Redundant self detected.
      Open

          self.set_person(Person.new((opts[:person] || {}).except(:id)))
      Severity: Minor
      Found in app/models/user.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
      

      Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
      Open

        apply_simple_captcha :message => I18n.t('simple_captcha.message.failed'), :add_to_base => true
      Severity: Minor
      Found in app/models/user.rb by rubocop

      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"
      

      Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
      Open

            if pref_hash[key] == 'true'
      Severity: Minor
      Found in app/models/user.rb by rubocop

      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"
      

      Do not use Time.now without zone. Use one of Time.zone.now, Time.current, Time.now.in_time_zone, Time.now.utc, Time.now.getlocal, Time.now.iso8601, Time.now.jisx0301, Time.now.rfc3339, Time.now.to_i, Time.now.to_f instead.
      Open

        scope :yearly_actives, ->(time = Time.now) { logged_in_since(time - 1.year) }
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop checks for the use of Time methods without zone.

      Built on top of Ruby on Rails style guide (https://github.com/bbatsov/rails-style-guide#time) and the article http://danilenko.org/2012/7/6/rails_timezones/ .

      Two styles are supported for this cop. When EnforcedStyle is 'strict' then only use of Time.zone is allowed.

      When EnforcedStyle is 'flexible' then it's also allowed to use Time.intimezone.

      Example:

      # always offense
      Time.now
      Time.parse('2015-03-02 19:05:37')
      
      # no offense
      Time.zone.now
      Time.zone.parse('2015-03-02 19:05:37')
      
      # no offense only if style is 'flexible'
      Time.current
      DateTime.strptime(str, "%Y-%m-%d %H:%M %Z").in_time_zone
      Time.at(timestamp).in_time_zone
      

      Surrounding space detected in default value assignment.
      Open

        scope :monthly_actives, ->(time = Time.now) { logged_in_since(time - 1.month) }
      Severity: Minor
      Found in app/models/user.rb by rubocop

      Checks that the equals signs in parameter default assignments have or don't have surrounding space depending on configuration.

      Example:

      # bad
      def some_method(arg1=:default, arg2=nil, arg3=[])
        # do something...
      end
      
      # good
      def some_method(arg1 = :default, arg2 = nil, arg3 = [])
        # do something...
      end
      

      Redundant self detected.
      Open

            self.person.serialized_public_key = OpenSSL::PKey::RSA.new(self.serialized_private_key).public_key.to_s
      Severity: Minor
      Found in app/models/user.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
      

      Redundant self detected.
      Open

          self.person.closed_account
      Severity: Minor
      Found in app/models/user.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
      

      Redundant self detected.
      Open

            self.save
      Severity: Minor
      Found in app/models/user.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
      

      Use safe navigation (&.) instead of checking if an object exists before calling the method.
      Open

              if block
                block.destroy
              end
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop transforms usages of a method call safeguarded by a non nil check for the variable whose method is being called to safe navigation (&.).

      Configuration option: ConvertCodeThatCanStartToReturnNil The default for this is false. When configured to true, this will check for code in the format !foo.nil? && foo.bar. As it is written, the return of this code is limited to false and whatever the return of the method is. If this is converted to safe navigation, foo&.bar can start returning nil as well as what the method returns.

      Example:

      # bad
      foo.bar if foo
      foo.bar(param1, param2) if foo
      foo.bar { |e| e.something } if foo
      foo.bar(param) { |e| e.something } if foo
      
      foo.bar if !foo.nil?
      foo.bar unless !foo
      foo.bar unless foo.nil?
      
      foo && foo.bar
      foo && foo.bar(param1, param2)
      foo && foo.bar { |e| e.something }
      foo && foo.bar(param) { |e| e.something }
      
      # good
      foo&.bar
      foo&.bar(param1, param2)
      foo&.bar { |e| e.something }
      foo&.bar(param) { |e| e.something }
      
      foo.nil? || foo.bar
      !foo || foo.bar
      
      # Methods that `nil` will `respond_to?` should not be converted to
      # use safe navigation
      foo.to_i if foo
      

      Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
      Open

          params.slice!(*(Profile.column_names+['tag_string', 'date']))
      Severity: Minor
      Found in app/models/user.rb by rubocop

      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"
      

      Use %i or %I for an array of symbols.
      Open

          [:getting_started,
           :show_community_spotlight_in_stream,
           :post_default_public].each do |field|
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop can check for array literals made up of symbols that are not using the %i() syntax.

      Alternatively, it checks for symbol arrays using the %i() syntax on projects which do not want to use that syntax.

      Configuration option: MinSize If set, arrays with fewer elements than this value will not trigger the cop. For example, a MinSize of3` will not enforce a style on an array of 2 or fewer elements.

      Example: EnforcedStyle: percent (default)

      # good
      %i[foo bar baz]
      
      # bad
      [:foo, :bar, :baz]
      

      Example: EnforcedStyle: brackets

      # good
      [:foo, :bar, :baz]
      
      # bad
      %i[foo bar baz]
      

      Redundant self detected.
      Open

            if self.like_for(target)
      Severity: Minor
      Found in app/models/user.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
      

      Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
      Open

        has_many :aspects, -> { order('order_id ASC') }
      Severity: Minor
      Found in app/models/user.rb by rubocop

      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"
      

      Redundant self detected.
      Open

          self.aspects.create(:name => I18n.t('aspects.seed.work'))
      Severity: Minor
      Found in app/models/user.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
      

      Redundant self detected.
      Open

          Role.is_admin?(self.person)
      Severity: Minor
      Found in app/models/user.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
      

      Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
      Open

        has_many :followed_tags, -> { order('tags.name') }, :through => :tag_followings, :source => :tag
      Severity: Minor
      Found in app/models/user.rb by rubocop

      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"
      

      Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
      Open

          aq = self.aspects.create(:name => I18n.t('aspects.seed.acquaintances'))
      Severity: Minor
      Found in app/models/user.rb by rubocop

      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"
      

      Redundant self detected.
      Open

          self.valid?
      Severity: Minor
      Found in app/models/user.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
      

      Use safe navigation (&.) instead of checking if an object exists before calling the method.
      Open

          if self.person && self.person.serialized_public_key.blank?
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop transforms usages of a method call safeguarded by a non nil check for the variable whose method is being called to safe navigation (&.).

      Configuration option: ConvertCodeThatCanStartToReturnNil The default for this is false. When configured to true, this will check for code in the format !foo.nil? && foo.bar. As it is written, the return of this code is limited to false and whatever the return of the method is. If this is converted to safe navigation, foo&.bar can start returning nil as well as what the method returns.

      Example:

      # bad
      foo.bar if foo
      foo.bar(param1, param2) if foo
      foo.bar { |e| e.something } if foo
      foo.bar(param) { |e| e.something } if foo
      
      foo.bar if !foo.nil?
      foo.bar unless !foo
      foo.bar unless foo.nil?
      
      foo && foo.bar
      foo && foo.bar(param1, param2)
      foo && foo.bar { |e| e.something }
      foo && foo.bar(param) { |e| e.something }
      
      # good
      foo&.bar
      foo&.bar(param1, param2)
      foo&.bar { |e| e.something }
      foo&.bar(param) { |e| e.something }
      
      foo.nil? || foo.bar
      !foo || foo.bar
      
      # Methods that `nil` will `respond_to?` should not be converted to
      # use safe navigation
      foo.to_i if foo
      

      Redundant self detected.
      Open

          self.generate_keys
      Severity: Minor
      Found in app/models/user.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
      

      Redundant self detected.
      Open

            return self.id == target.user_id
      Severity: Minor
      Found in app/models/user.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
      

      Redundant self detected.
      Open

            self.aspects
      Severity: Minor
      Found in app/models/user.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
      

      Redundant self detected.
      Open

          update_profile( self.profile.from_omniauth_hash( user_info ) )
      Severity: Minor
      Found in app/models/user.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
      

      Redundant self detected.
      Open

            self.person.serialized_public_key = OpenSSL::PKey::RSA.new(self.serialized_private_key).public_key.to_s
      Severity: Minor
      Found in app/models/user.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
      

      Redundant self detected.
      Open

          if self.username_changed? && Person.exists?(:diaspora_handle => diaspora_id)
      Severity: Minor
      Found in app/models/user.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
      

      Redundant self detected.
      Open

            Like.exists?(:author_id => self.person.id, :target_type => target.class.base_class.to_s, :target_id => target.id)
      Severity: Minor
      Found in app/models/user.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 rescuing without specifying an error class.
      Open

        rescue => error
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop checks for rescuing StandardError. There are two supported styles implicit and explicit. This cop will not register an offense if any error other than StandardError is specified.

      Example: EnforcedStyle: implicit

      # `implicit` will enforce using `rescue` instead of
      # `rescue StandardError`.
      
      # bad
      begin
        foo
      rescue StandardError
        bar
      end
      
      # good
      begin
        foo
      rescue
        bar
      end
      
      # good
      begin
        foo
      rescue OtherError
        bar
      end
      
      # good
      begin
        foo
      rescue StandardError, SecurityError
        bar
      end
      

      Example: EnforcedStyle: explicit (default)

      # `explicit` will enforce using `rescue StandardError`
      # instead of `rescue`.
      
      # bad
      begin
        foo
      rescue
        bar
      end
      
      # good
      begin
        foo
      rescue StandardError
        bar
      end
      
      # good
      begin
        foo
      rescue OtherError
        bar
      end
      
      # good
      begin
        foo
      rescue StandardError, SecurityError
        bar
      end
      

      Prefer the new style validations validates :column, format: value over validates_format_of.
      Open

        validates_format_of :username, :with => /\A[A-Za-z0-9_]+\z/
      Severity: Minor
      Found in app/models/user.rb by rubocop

      Redundant self detected.
      Open

          person.diaspora_handle = "#{self.username}#{User.diaspora_id_host}"
      Severity: Minor
      Found in app/models/user.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
      

      Redundant self detected.
      Open

          diaspora_id = "#{self.username}#{User.diaspora_id_host}"
      Severity: Minor
      Found in app/models/user.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
      

      Redundant self detected.
      Open

          self.person.lock_access!
      Severity: Minor
      Found in app/models/user.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
      

      Redundant self detected.
      Open

          self.save(:validate => false)
      Severity: Minor
      Found in app/models/user.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 rescuing without specifying an error class.
      Open

        rescue => error
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop checks for rescuing StandardError. There are two supported styles implicit and explicit. This cop will not register an offense if any error other than StandardError is specified.

      Example: EnforcedStyle: implicit

      # `implicit` will enforce using `rescue` instead of
      # `rescue StandardError`.
      
      # bad
      begin
        foo
      rescue StandardError
        bar
      end
      
      # good
      begin
        foo
      rescue
        bar
      end
      
      # good
      begin
        foo
      rescue OtherError
        bar
      end
      
      # good
      begin
        foo
      rescue StandardError, SecurityError
        bar
      end
      

      Example: EnforcedStyle: explicit (default)

      # `explicit` will enforce using `rescue StandardError`
      # instead of `rescue`.
      
      # bad
      begin
        foo
      rescue
        bar
      end
      
      # good
      begin
        foo
      rescue StandardError
        bar
      end
      
      # good
      begin
        foo
      rescue OtherError
        bar
      end
      
      # good
      begin
        foo
      rescue StandardError, SecurityError
        bar
      end
      

      Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
      Open

        scope :logged_in_since, ->(time) { where('last_seen > ?', time) }
      Severity: Minor
      Found in app/models/user.rb by rubocop

      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"
      

      Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
      Open

          pref = job.to_s.gsub('Workers::Mail::', '').underscore
      Severity: Minor
      Found in app/models/user.rb by rubocop

      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"
      

      Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
      Open

          self.aspects.create(:name => I18n.t('aspects.seed.family'))
      Severity: Minor
      Found in app/models/user.rb by rubocop

      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"
      

      Redundant self detected.
      Open

          aq = self.aspects.create(:name => I18n.t('aspects.seed.acquaintances'))
      Severity: Minor
      Found in app/models/user.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
      

      Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
      Open

            errors[:base] << 'That username has already been taken'
      Severity: Minor
      Found in app/models/user.rb by rubocop

      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"
      

      Prefer the new style validations validates :column, inclusion: value over validates_inclusion_of.
      Open

        validates_inclusion_of :language, :in => AVAILABLE_LANGUAGE_CODES
      Severity: Minor
      Found in app/models/user.rb by rubocop

      Redundant self detected.
      Open

          if self.profile.update_attributes(params)
      Severity: Minor
      Found in app/models/user.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
      

      Redundant self detected.
      Open

          self.aspects.create(:name => I18n.t('aspects.seed.family'))
      Severity: Minor
      Found in app/models/user.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
      

      Redundant self detected.
      Open

            self.share_with(default_account, aq) if default_account
      Severity: Minor
      Found in app/models/user.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
      

      Redundant self detected.
      Open

          self.lock_access!
      Severity: Minor
      Found in app/models/user.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
      

      Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
      Open

          self.aspects.create(:name => I18n.t('aspects.seed.work'))
      Severity: Minor
      Found in app/models/user.rb by rubocop

      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"
      

      Use !empty? instead of size > 0.
      Open

          return if errors.size > 0
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop checks for numeric comparisons that can be replaced by a predicate method, such as receiver.length == 0, receiver.length > 0, receiver.length != 0, receiver.length < 1 and receiver.size == 0 that can be replaced by receiver.empty? and !receiver.empty.

      Example:

      # bad
      [1, 2, 3].length == 0
      0 == "foobar".length
      array.length < 1
      {a: 1, b: 2}.length != 0
      string.length > 0
      hash.size > 0
      
      # good
      [1, 2, 3].empty?
      "foobar".empty?
      array.empty?
      !{a: 1, b: 2}.empty?
      !string.empty?
      !hash.empty?
      

      Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
      Open

          params.slice!(*(Profile.column_names+['tag_string', 'date']))
      Severity: Minor
      Found in app/models/user.rb by rubocop

      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"
      

      Do not use Time.now without zone. Use one of Time.zone.now, Time.current, Time.now.in_time_zone, Time.now.utc, Time.now.getlocal, Time.now.iso8601, Time.now.jisx0301, Time.now.rfc3339, Time.now.to_i, Time.now.to_f instead.
      Open

        scope :monthly_actives, ->(time = Time.now) { logged_in_since(time - 1.month) }
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop checks for the use of Time methods without zone.

      Built on top of Ruby on Rails style guide (https://github.com/bbatsov/rails-style-guide#time) and the article http://danilenko.org/2012/7/6/rails_timezones/ .

      Two styles are supported for this cop. When EnforcedStyle is 'strict' then only use of Time.zone is allowed.

      When EnforcedStyle is 'flexible' then it's also allowed to use Time.intimezone.

      Example:

      # always offense
      Time.now
      Time.parse('2015-03-02 19:05:37')
      
      # no offense
      Time.zone.now
      Time.zone.parse('2015-03-02 19:05:37')
      
      # no offense only if style is 'flexible'
      Time.current
      DateTime.strptime(str, "%Y-%m-%d %H:%M %Z").in_time_zone
      Time.at(timestamp).in_time_zone
      

      Do not use Time.now without zone. Use one of Time.zone.now, Time.current, Time.now.in_time_zone, Time.now.utc, Time.now.getlocal, Time.now.iso8601, Time.now.jisx0301, Time.now.rfc3339, Time.now.to_i, Time.now.to_f instead.
      Open

        scope :daily_actives, ->(time = Time.now) { logged_in_since(time - 1.day) }
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop checks for the use of Time methods without zone.

      Built on top of Ruby on Rails style guide (https://github.com/bbatsov/rails-style-guide#time) and the article http://danilenko.org/2012/7/6/rails_timezones/ .

      Two styles are supported for this cop. When EnforcedStyle is 'strict' then only use of Time.zone is allowed.

      When EnforcedStyle is 'flexible' then it's also allowed to use Time.intimezone.

      Example:

      # always offense
      Time.now
      Time.parse('2015-03-02 19:05:37')
      
      # no offense
      Time.zone.now
      Time.zone.parse('2015-03-02 19:05:37')
      
      # no offense only if style is 'flexible'
      Time.current
      DateTime.strptime(str, "%Y-%m-%d %H:%M %Z").in_time_zone
      Time.at(timestamp).in_time_zone
      

      Prefer the new style validations validates :column, length: value over validates_length_of.
      Open

        validates_length_of :username, :maximum => 32
      Severity: Minor
      Found in app/models/user.rb by rubocop

      Prefer the new style validations validates :column, format: value over validates_format_of.
      Open

        validates_format_of :unconfirmed_email, :with  => Devise.email_regexp, :allow_blank => true
      Severity: Minor
      Found in app/models/user.rb by rubocop

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

          unless self.remove_after.nil?
      Severity: Minor
      Found in app/models/user.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 the new Ruby 1.9 hash syntax.
      Open

        apply_simple_captcha :message => I18n.t('simple_captcha.message.failed'), :add_to_base => true
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop checks hash literal syntax.

      It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

      A separate offense is registered for each problematic pair.

      The supported styles are:

      • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
      • hash_rockets - forces use of hash rockets for all hashes
      • nomixedkeys - simply checks for hashes with mixed syntaxes
      • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

      Example: EnforcedStyle: ruby19 (default)

      # bad
      {:a => 2}
      {b: 1, :c => 2}
      
      # good
      {a: 2, b: 1}
      {:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
      {d: 1, 'e' => 2} # technically not forbidden
      

      Example: EnforcedStyle: hash_rockets

      # bad
      {a: 1, b: 2}
      {c: 1, 'd' => 5}
      
      # good
      {:a => 1, :b => 2}
      

      Example: EnforcedStyle: nomixedkeys

      # bad
      {:a => 1, b: 2}
      {c: 1, 'd' => 2}
      
      # good
      {:a => 1, :b => 2}
      {c: 1, d: 2}
      

      Example: EnforcedStyle: ruby19nomixed_keys

      # bad
      {:a => 1, :b => 2}
      {c: 2, 'd' => 3} # should just use hash rockets
      
      # good
      {a: 1, b: 2}
      {:c => 3, 'd' => 4}
      

      Use the new Ruby 1.9 hash syntax.
      Open

        validates_exclusion_of :username, :in => AppConfig.settings.username_blacklist
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop checks hash literal syntax.

      It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

      A separate offense is registered for each problematic pair.

      The supported styles are:

      • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
      • hash_rockets - forces use of hash rockets for all hashes
      • nomixedkeys - simply checks for hashes with mixed syntaxes
      • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

      Example: EnforcedStyle: ruby19 (default)

      # bad
      {:a => 2}
      {b: 1, :c => 2}
      
      # good
      {a: 2, b: 1}
      {:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
      {d: 1, 'e' => 2} # technically not forbidden
      

      Example: EnforcedStyle: hash_rockets

      # bad
      {a: 1, b: 2}
      {c: 1, 'd' => 5}
      
      # good
      {:a => 1, :b => 2}
      

      Example: EnforcedStyle: nomixedkeys

      # bad
      {:a => 1, b: 2}
      {c: 1, 'd' => 2}
      
      # good
      {:a => 1, :b => 2}
      {c: 1, d: 2}
      

      Example: EnforcedStyle: ruby19nomixed_keys

      # bad
      {:a => 1, :b => 2}
      {c: 2, 'd' => 3} # should just use hash rockets
      
      # good
      {a: 1, b: 2}
      {:c => 3, 'd' => 4}
      

      Redundant self detected.
      Open

          InvitationCode.find_or_create_by(user_id: self.id)
      Severity: Minor
      Found in app/models/user.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
      

      Redundant self detected.
      Open

          if self.hidden_shareables.has_key?(key) && self.hidden_shareables[key].include?(share_id)
      Severity: Minor
      Found in app/models/user.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
      

      Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
      Open

          self.aspects.create(:name => I18n.t('aspects.seed.friends'))
      Severity: Minor
      Found in app/models/user.rb by rubocop

      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"
      

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

          if AppConfig.settings.maintenance.remove_old_users.enable?
      Severity: Minor
      Found in app/models/user.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 the new Ruby 1.9 hash syntax.
      Open

               :lockable, :lastseenable, :lock_strategy => :none, :unlock_strategy => :none
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop checks hash literal syntax.

      It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

      A separate offense is registered for each problematic pair.

      The supported styles are:

      • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
      • hash_rockets - forces use of hash rockets for all hashes
      • nomixedkeys - simply checks for hashes with mixed syntaxes
      • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

      Example: EnforcedStyle: ruby19 (default)

      # bad
      {:a => 2}
      {b: 1, :c => 2}
      
      # good
      {a: 2, b: 1}
      {:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
      {d: 1, 'e' => 2} # technically not forbidden
      

      Example: EnforcedStyle: hash_rockets

      # bad
      {a: 1, b: 2}
      {c: 1, 'd' => 5}
      
      # good
      {:a => 1, :b => 2}
      

      Example: EnforcedStyle: nomixedkeys

      # bad
      {:a => 1, b: 2}
      {c: 1, 'd' => 2}
      
      # good
      {:a => 1, :b => 2}
      {c: 1, d: 2}
      

      Example: EnforcedStyle: ruby19nomixed_keys

      # bad
      {:a => 1, :b => 2}
      {c: 2, 'd' => 3} # should just use hash rockets
      
      # good
      {a: 1, b: 2}
      {:c => 3, 'd' => 4}
      

      Use the new Ruby 1.9 hash syntax.
      Open

            Like.exists?(:author_id => self.person.id, :target_type => target.class.base_class.to_s, :target_id => target.id)
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop checks hash literal syntax.

      It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

      A separate offense is registered for each problematic pair.

      The supported styles are:

      • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
      • hash_rockets - forces use of hash rockets for all hashes
      • nomixedkeys - simply checks for hashes with mixed syntaxes
      • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

      Example: EnforcedStyle: ruby19 (default)

      # bad
      {:a => 2}
      {b: 1, :c => 2}
      
      # good
      {a: 2, b: 1}
      {:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
      {d: 1, 'e' => 2} # technically not forbidden
      

      Example: EnforcedStyle: hash_rockets

      # bad
      {a: 1, b: 2}
      {c: 1, 'd' => 5}
      
      # good
      {:a => 1, :b => 2}
      

      Example: EnforcedStyle: nomixedkeys

      # bad
      {:a => 1, b: 2}
      {c: 1, 'd' => 2}
      
      # good
      {:a => 1, :b => 2}
      {c: 1, d: 2}
      

      Example: EnforcedStyle: ruby19nomixed_keys

      # bad
      {:a => 1, :b => 2}
      {c: 2, 'd' => 3} # should just use hash rockets
      
      # good
      {a: 1, b: 2}
      {:c => 3, 'd' => 4}
      

      Redundant self detected.
      Open

              self.user_preferences.find_or_create_by(email_type: key)
      Severity: Minor
      Found in app/models/user.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
      

      Redundant self detected.
      Open

          if self.owns? post
      Severity: Minor
      Found in app/models/user.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
      

      Use %w or %W for an array of words.
      Open

          params.slice!(*(Profile.column_names+['tag_string', 'date']))
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop can check for array literals made up of word-like strings, that are not using the %w() syntax.

      Alternatively, it can check for uses of the %w() syntax, in projects which do not want to include that syntax.

      Configuration option: MinSize If set, arrays with fewer elements than this value will not trigger the cop. For example, a MinSize of 3 will not enforce a style on an array of 2 or fewer elements.

      Example: EnforcedStyle: percent (default)

      # good
      %w[foo bar baz]
      
      # bad
      ['foo', 'bar', 'baz']
      

      Example: EnforcedStyle: brackets

      # good
      ['foo', 'bar', 'baz']
      
      # bad
      %w[foo bar baz]
      

      Prefer the new style validations validates :column, exclusion: value over validates_exclusion_of.
      Open

        validates_exclusion_of :username, :in => AppConfig.settings.username_blacklist
      Severity: Minor
      Found in app/models/user.rb by rubocop

      Do not use Time.now without zone. Use one of Time.zone.now, Time.current, Time.now.in_time_zone, Time.now.utc, Time.now.getlocal, Time.now.iso8601, Time.now.jisx0301, Time.now.rfc3339, Time.now.to_i, Time.now.to_f instead.
      Open

        scope :halfyear_actives, ->(time = Time.now) { logged_in_since(time - 6.month) }
      Severity: Minor
      Found in app/models/user.rb by rubocop

      This cop checks for the use of Time methods without zone.

      Built on top of Ruby on Rails style guide (https://github.com/bbatsov/rails-style-guide#time) and the article http://danilenko.org/2012/7/6/rails_timezones/ .

      Two styles are supported for this cop. When EnforcedStyle is 'strict' then only use of Time.zone is allowed.

      When EnforcedStyle is 'flexible' then it's also allowed to use Time.intimezone.

      Example:

      # always offense
      Time.now
      Time.parse('2015-03-02 19:05:37')
      
      # no offense
      Time.zone.now
      Time.zone.parse('2015-03-02 19:05:37')
      
      # no offense only if style is 'flexible'
      Time.current
      DateTime.strptime(str, "%Y-%m-%d %H:%M %Z").in_time_zone
      Time.at(timestamp).in_time_zone
      

      There are no issues that match your filters.

      Category
      Status