ece517-p3/expertiza

View on GitHub
app/models/user.rb

Summary

Maintainability
C
1 day
Test Coverage

Mass assignment is not restricted using attr_accessible
Open

class User < ActiveRecord::Base
Severity: Critical
Found in app/models/user.rb by brakeman

This warning comes up if a model does not limit what attributes can be set through mass assignment.

In particular, this check looks for attr_accessible inside model definitions. If it is not found, this warning will be issued.

Brakeman also warns on use of attr_protected - especially since it was found to be vulnerable to bypass. Warnings for mass assignment on models using attr_protected will be reported, but at a lower confidence level.

Note that disabling mass assignment globally will suppress these warnings.

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

class User < ActiveRecord::Base
  acts_as_authentic do |config|
    config.validates_uniqueness_of_email_field_options = {if: -> { false }} # Don't validate email uniqueness
    config.crypto_provider = Authlogic::CryptoProviders::Sha1
    Authlogic::CryptoProviders::Sha1.join_token = ''
Severity: Minor
Found in app/models/user.rb - About 3 hrs to fix

    Assignment Branch Condition size for export is too high. [30.48/15]
    Open

      def self.export(csv, _parent_id, options)
        users = User.all
        users.each do |user|
          tcsv = []
          tcsv.push(user.name, user.fullname, user.email) if options["personal_details"] == "true"
    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 get_user_list is too high. [18.47/15]
    Open

      def get_user_list
        user_list = []
        # If the user is a super admin, fetch all users
        user_list = SuperAdministrator.get_user_list if self.role.super_admin?
    
    
    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 import is too high. [18.49/15]
    Open

      def self.import(row_hash, _row_header, session, id = nil)
        raise ArgumentError, "Only #{row_hash.length} column(s) is(are) found. It must contain at least username, full name, email." if row_hash.length < 3
        user = User.find_by_name(row_hash[:name])
        if user.nil?
          attributes = ImportFileHelper.define_attributes(row_hash)
    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

    Cyclomatic complexity for get_user_list is too high. [7/6]
    Open

      def get_user_list
        user_list = []
        # If the user is a super admin, fetch all users
        user_list = SuperAdministrator.get_user_list if self.role.super_admin?
    
    
    Severity: Minor
    Found in app/models/user.rb by rubocop

    This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

    An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

    Assignment Branch Condition size for export_fields is too high. [15.84/15]
    Open

      def self.export_fields(options)
        fields = []
        fields.push("name", "full name", "email") if options["personal_details"] == "true"
        fields.push("role") if options["role"] == "true"
        fields.push("parent") if options["parent"] == "true"
    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 get_user_list has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

      def get_user_list
        user_list = []
        # If the user is a super admin, fetch all users
        user_list = SuperAdministrator.get_user_list if self.role.super_admin?
    
    
    Severity: Minor
    Found in app/models/user.rb - About 1 hr 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 export has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.export(csv, _parent_id, options)
        users = User.all
        users.each do |user|
          tcsv = []
          tcsv.push(user.name, user.fullname, user.email) if options["personal_details"] == "true"
    Severity: Minor
    Found in app/models/user.rb - About 1 hr 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 generate_keys has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def generate_keys
        # check if we are replacing a digital certificate already generated
        replacing_key = true unless self.digital_certificate.nil?
    
        # generate the new key pair
    Severity: Minor
    Found in app/models/user.rb - About 45 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

    Specify an :inverse_of option.
    Open

      belongs_to :parent, class_name: 'User'
    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 :received_invitations, class_name: 'Invitation', foreign_key: 'to_id', dependent: :destroy
    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 :children, class_name: 'User', foreign_key: 'parent_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

    Use find_by instead of dynamic find_by_name.
    Open

        user = User.find_by_name(row_hash[:name])
    Severity: Minor
    Found in app/models/user.rb by rubocop

    This cop checks dynamic find_by_* methods. Use find_by instead of dynamic method. See. https://github.com/bbatsov/rails-style-guide#find_by

    Example:

    # bad
    User.find_by_name(name)
    
    # bad
    User.find_by_name_and_email(name)
    
    # bad
    User.find_by_email!(name)
    
    # good
    User.find_by(name: name)
    
    # good
    User.find_by(name: name, email: email)
    
    # good
    User.find_by!(email: email)

    Specify a :dependent option.
    Open

      has_many :children, class_name: 'User', foreign_key: 'parent_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 an :inverse_of option.
    Open

      has_many :participants, class_name: 'Participant', foreign_key: 'user_id', dependent: :destroy
    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 :assignment_participants, class_name: 'AssignmentParticipant', foreign_key: 'user_id', dependent: :destroy
    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 :sent_invitations, class_name: 'Invitation', foreign_key: 'from_id', dependent: :destroy
    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

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

      def self.export_fields(options)
        fields = []
        fields.push("name", "full name", "email") if options["personal_details"] == "true"
        fields.push("role") if options["role"] == "true"
        fields.push("parent") if options["parent"] == "true"
    Severity: Major
    Found in app/models/user.rb and 1 other location - About 1 hr to fix
    app/models/participant.rb on lines 147..154

    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 55.

    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

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

      def self.import(row_hash, _row_header, session, id = nil)
    Severity: Minor
    Found in app/models/user.rb by rubocop

    This cop checks for unused method arguments.

    Example:

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

    Example:

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

    Do not prefix reader method names with get_.
    Open

      def get_user_list
    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

    end at 225, 4 is not aligned with def at 205, 2.
    Open

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

    This cop checks whether the end keywords of method definitions are aligned properly.

    Two modes are supported through the EnforcedStyleAlignWith configuration parameter. If it's set to start_of_line (which is the default), the end shall be aligned with the start of the line where the def keyword is. If it's set to def, the end shall be aligned with the def keyword.

    Example: EnforcedStyleAlignWith: startofline (default)

    # bad
    
    private def foo
                end
    
    # good
    
    private def foo
    end

    Example: EnforcedStyleAlignWith: def

    # bad
    
    private def foo
                end
    
    # good
    
    private def foo
            end

    Use snake_case for variable names.
    Open

          shortName = items[0]
    Severity: Minor
    Found in app/models/user.rb by rubocop

    This cop makes sure that all variables use the configured style, snake_case or camelCase, for their names.

    Example: EnforcedStyle: snake_case (default)

    # bad
    fooBar = 1
    
    # good
    foo_bar = 1

    Example: EnforcedStyle: camelCase

    # bad
    foo_bar = 1
    
    # good
    fooBar = 1

    Prefer each over for.
    Open

          for participant in participants
    Severity: Minor
    Found in app/models/user.rb by rubocop

    This cop looks for uses of the for keyword, or each method. The preferred alternative is set in the EnforcedStyle configuration parameter. An each call with a block on a single line is always allowed, however.

    Do not introduce global variables.
    Open

        anonymized_view_starter_ips = $redis.get('anonymized_view_starter_ips') || ''
    Severity: Minor
    Found in app/models/user.rb by rubocop

    This cops looks for uses of global variables. It does not report offenses for built-in global variables. Built-in global variables are allowed by default. Additionally users can allow additional variables via the AllowedVariables option.

    Note that backreferences like $1, $2, etc are not global variables.

    Example:

    # bad
    $foo = 2
    bar = $foo + 5
    
    # good
    FOO = 2
    foo = 2
    $stdin.read

    Extra empty line detected at method body end.
    Open

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

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

    Example:

    # good
    
    def foo
      # ...
    end
    
    # bad
    
    def bar
    
      # ...
    
    end

    Do not prefix writer method names with set_.
    Open

      def set_instructor(new_assignment)
    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 snake_case for variable names.
    Open

          userList = User.where("name = ?", shortName)
    Severity: Minor
    Found in app/models/user.rb by rubocop

    This cop makes sure that all variables use the configured style, snake_case or camelCase, for their names.

    Example: EnforcedStyle: snake_case (default)

    # bad
    fooBar = 1
    
    # good
    foo_bar = 1

    Example: EnforcedStyle: camelCase

    # bad
    foo_bar = 1
    
    # good
    fooBar = 1

    Do not prefix reader method names with get_.
    Open

      def get_instructor
    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

    There are no issues that match your filters.

    Category
    Status