ece517-p3/expertiza

View on GitHub
spec/models/user_spec.rb

Summary

Maintainability
B
5 hrs
Test Coverage

Block has too many lines. [374/25]
Open

describe User do
  let(:user) do
    User.new name: 'abc', fullname: 'abc xyz', email: 'abcxyz@gmail.com', password: '12345678', password_confirmation: '12345678',
             email_on_submission: 1, email_on_review: 1, email_on_review_of_review: 0, copy_of_emails: 1, handle: 'handle'
  end
Severity: Minor
Found in spec/models/user_spec.rb by rubocop

This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

File user_spec.rb has 376 lines of code (exceeds 250 allowed). Consider refactoring.
Open

describe User do
  let(:user) do
    User.new name: 'abc', fullname: 'abc xyz', email: 'abcxyz@gmail.com', password: '12345678', password_confirmation: '12345678',
             email_on_submission: 1, email_on_review: 1, email_on_review_of_review: 0, copy_of_emails: 1, handle: 'handle'
  end
Severity: Minor
Found in spec/models/user_spec.rb - About 5 hrs to fix

    Block has too many lines. [30/25]
    Open

      describe '.export' do
        before(:each) do
          allow(User).to receive(:all).and_return([user])
          allow(user).to receive_message_chain(:role, :name).and_return('Student')
          allow(user).to receive_message_chain(:parent, :name).and_return('Instructor')
    Severity: Minor
    Found in spec/models/user_spec.rb by rubocop

    This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

    Block has too many lines. [27/25]
    Open

      describe '.search_users' do
        let(:role) { Role.new }
    
        before(:each) do
          allow(User).to receive_message_chain(:order, :where).with("(role_id in (?) or id = ?) and name like ?", role.get_available_roles, @user_id, '%name%')
    Severity: Minor
    Found in spec/models/user_spec.rb by rubocop

    This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

    Block has too many lines. [27/25]
    Open

      describe '#email' do
        it 'returns the email of the user' do
          expect(user.email).to eq('abcxyz@gmail.com')
        end
    
    
    Severity: Minor
    Found in spec/models/user_spec.rb by rubocop

    This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

    Block has too many lines. [26/25]
    Open

      describe '#get_user_list' do
        before(:each) do
          allow(user).to receive_message_chain("role.super_admin?") { false }
          allow(user).to receive_message_chain("role.instructor?") { false }
          allow(user).to receive_message_chain("role.ta?") { false }
    Severity: Minor
    Found in spec/models/user_spec.rb by rubocop

    This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

    Use find_by instead of dynamic find_by_login.
    Open

            expect(User.find_by_login('abcxyz@gmail.com')).to eq(user)
    Severity: Minor
    Found in spec/models/user_spec.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)

    Use find_by instead of dynamic find_by_login.
    Open

            expect(User.find_by_login('abc@gmail.com')).to eq(user)
    Severity: Minor
    Found in spec/models/user_spec.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)

    Line is too long. [163/160]
    Open

          allow(User).to receive_message_chain(:order, :where).with("(role_id in (?) or id = ?) and fullname like ?", role.get_available_roles, @user_id, '%fullname%')
    Severity: Minor
    Found in spec/models/user_spec.rb by rubocop

    Useless assignment to variable - role.
    Open

          role = Role.new
    Severity: Minor
    Found in spec/models/user_spec.rb by rubocop

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

    assigned but unused variable - foo

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

    Example:

    # bad
    
    def some_method
      some_var = 1
      do_something
    end

    Example:

    # good
    
    def some_method
      some_var = 1
      do_something(some_var)
    end

    Useless assignment to variable - user_id.
    Open

          user_id = double
    Severity: Minor
    Found in spec/models/user_spec.rb by rubocop

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

    assigned but unused variable - foo

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

    Example:

    # bad
    
    def some_method
      some_var = 1
      do_something
    end

    Example:

    # good
    
    def some_method
      some_var = 1
      do_something(some_var)
    end

    Use %r around regular expression.
    Open

          expect { User.from_params(user: {}) }.to raise_error(RuntimeError, /a href='users\/new\/1'>create an account<\/a> for this user to continue/)
    Severity: Minor
    Found in spec/models/user_spec.rb by rubocop

    This cop enforces using // or %r around regular expressions.

    Example: EnforcedStyle: slashes (default)

    # bad
    snake_case = %r{^[\dA-Z_]+$}
    
    # bad
    regex = %r{
      foo
      (bar)
      (baz)
    }x
    
    # good
    snake_case = /^[\dA-Z_]+$/
    
    # good
    regex = /
      foo
      (bar)
      (baz)
    /x

    Example: EnforcedStyle: percent_r

    # bad
    snake_case = /^[\dA-Z_]+$/
    
    # bad
    regex = /
      foo
      (bar)
      (baz)
    /x
    
    # good
    snake_case = %r{^[\dA-Z_]+$}
    
    # good
    regex = %r{
      foo
      (bar)
      (baz)
    }x

    Example: EnforcedStyle: mixed

    # bad
    snake_case = %r{^[\dA-Z_]+$}
    
    # bad
    regex = /
      foo
      (bar)
      (baz)
    /x
    
    # good
    snake_case = /^[\dA-Z_]+$/
    
    # good
    regex = %r{
      foo
      (bar)
      (baz)
    }x

    Example: AllowInnerSlashes: false (default)

    # If `false`, the cop will always recommend using `%r` if one or more
    # slashes are found in the regexp string.
    
    # bad
    x =~ /home\//
    
    # good
    x =~ %r{home/}

    Example: AllowInnerSlashes: true

    # good
    x =~ /home\//

    There are no issues that match your filters.

    Category
    Status