expertiza/expertiza

View on GitHub
spec/controllers/impersonate_controller_spec.rb

Summary

Maintainability
F
4 days
Test Coverage

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

describe ImpersonateController do
  let(:instructor) { build(:instructor, id: 2) }
  let(:student1) { build(:student, id: 30, name: :Amanda) }
  let(:student2) { build(:student, id: 40, name: :Brian) }
  let(:admin) { build(:admin, id: 3, name: :Admin) }

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. [261/25]
Open

  context '#impersonate' do
    it 'when input is blank' do
      request.env['HTTP_REFERER'] = 'http://www.example.com'
      @params = { user: { name: '' } }
      get :impersonate, params: @params

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 impersonate_controller_spec.rb has 274 lines of code (exceeds 250 allowed). Consider refactoring.
Open

describe ImpersonateController do
  let(:instructor) { build(:instructor, id: 2) }
  let(:student1) { build(:student, id: 30, name: :Amanda) }
  let(:student2) { build(:student, id: 40, name: :Brian) }
  let(:admin) { build(:admin, id: 3, name: :Admin) }
Severity: Minor
Found in spec/controllers/impersonate_controller_spec.rb - About 2 hrs to fix

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

        it 'instructor should be able to impersonate a user while already impersonating a user but from nav bar' do
          allow(User).to receive(:find_by).with(name: student1.name).and_return(student1)
          allow(User).to receive(:find_by).with(name: student2.name).and_return(student2)
          allow(instructor).to receive(:can_impersonate?).with(student1).and_return(true)
          allow(instructor).to receive(:can_impersonate?).with(student2).and_return(true)
    Severity: Major
    Found in spec/controllers/impersonate_controller_spec.rb and 1 other location - About 3 hrs to fix
    spec/controllers/impersonate_controller_spec.rb on lines 268..282

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

    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

        it 'instructor should be able to impersonate a user while already impersonating a user' do
          allow(User).to receive(:find_by).with(name: student1.name).and_return(student1)
          allow(User).to receive(:find_by).with(name: student2.name).and_return(student2)
          allow(instructor).to receive(:can_impersonate?).with(student1).and_return(true)
          allow(instructor).to receive(:can_impersonate?).with(student2).and_return(true)
    Severity: Major
    Found in spec/controllers/impersonate_controller_spec.rb and 1 other location - About 3 hrs to fix
    spec/controllers/impersonate_controller_spec.rb on lines 285..300

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

    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 8 locations. Consider refactoring.
    Open

        it 'super admin should be able to impersonate a student with their real name' do
          stub_current_user(super_admin, super_admin.role.name, super_admin.role)       
          allow(User).to receive(:find_by).with(name: student1.name).and_return(student1)
          allow(super_admin).to receive(:can_impersonate?).with(student1).and_return(true)
          request.env['HTTP_REFERER'] = 'http://www.example.com'
    Severity: Major
    Found in spec/controllers/impersonate_controller_spec.rb and 7 other locations - About 2 hrs to fix
    spec/controllers/impersonate_controller_spec.rb on lines 87..98
    spec/controllers/impersonate_controller_spec.rb on lines 134..145
    spec/controllers/impersonate_controller_spec.rb on lines 148..159
    spec/controllers/impersonate_controller_spec.rb on lines 162..173
    spec/controllers/impersonate_controller_spec.rb on lines 201..212
    spec/controllers/impersonate_controller_spec.rb on lines 215..226
    spec/controllers/impersonate_controller_spec.rb on lines 229..240

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

    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 8 locations. Consider refactoring.
    Open

        it 'super admin should be able to impersonate a teaching assistant with their real name' do
          stub_current_user(super_admin, super_admin.role.name, super_admin.role)
          allow(User).to receive(:find_by).with(name: teaching_assistant.name).and_return(teaching_assistant)
          allow(super_admin).to receive(:can_impersonate?).with(teaching_assistant).and_return(true)
          request.env['HTTP_REFERER'] = 'http://www.example.com'
    Severity: Major
    Found in spec/controllers/impersonate_controller_spec.rb and 7 other locations - About 2 hrs to fix
    spec/controllers/impersonate_controller_spec.rb on lines 87..98
    spec/controllers/impersonate_controller_spec.rb on lines 134..145
    spec/controllers/impersonate_controller_spec.rb on lines 148..159
    spec/controllers/impersonate_controller_spec.rb on lines 162..173
    spec/controllers/impersonate_controller_spec.rb on lines 187..198
    spec/controllers/impersonate_controller_spec.rb on lines 215..226
    spec/controllers/impersonate_controller_spec.rb on lines 229..240

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

    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 8 locations. Consider refactoring.
    Open

        it 'teaching assistant should be able to impersonate a student with their real name' do
          stub_current_user(teaching_assistant, teaching_assistant.role.name, teaching_assistant.role)
          allow(User).to receive(:find_by).with(name: student1.name).and_return(student1)
          allow(teaching_assistant).to receive(:can_impersonate?).with(student1).and_return(true)
          request.env['HTTP_REFERER'] = 'http://www.example.com'
    Severity: Major
    Found in spec/controllers/impersonate_controller_spec.rb and 7 other locations - About 2 hrs to fix
    spec/controllers/impersonate_controller_spec.rb on lines 134..145
    spec/controllers/impersonate_controller_spec.rb on lines 148..159
    spec/controllers/impersonate_controller_spec.rb on lines 162..173
    spec/controllers/impersonate_controller_spec.rb on lines 187..198
    spec/controllers/impersonate_controller_spec.rb on lines 201..212
    spec/controllers/impersonate_controller_spec.rb on lines 215..226
    spec/controllers/impersonate_controller_spec.rb on lines 229..240

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

    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 8 locations. Consider refactoring.
    Open

        it 'super admin should be able to impersonate an admin with their real name' do
          stub_current_user(super_admin, super_admin.role.name, super_admin.role)
          allow(User).to receive(:find_by).with(name: admin.name).and_return(admin)
          allow(super_admin).to receive(:can_impersonate?).with(admin).and_return(true)
          request.env['HTTP_REFERER'] = 'http://www.example.com'
    Severity: Major
    Found in spec/controllers/impersonate_controller_spec.rb and 7 other locations - About 2 hrs to fix
    spec/controllers/impersonate_controller_spec.rb on lines 87..98
    spec/controllers/impersonate_controller_spec.rb on lines 134..145
    spec/controllers/impersonate_controller_spec.rb on lines 148..159
    spec/controllers/impersonate_controller_spec.rb on lines 162..173
    spec/controllers/impersonate_controller_spec.rb on lines 187..198
    spec/controllers/impersonate_controller_spec.rb on lines 201..212
    spec/controllers/impersonate_controller_spec.rb on lines 215..226

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

    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 8 locations. Consider refactoring.
    Open

        it 'admin should be able to impersonate a student with their real name' do
          stub_current_user(admin, admin.role.name, admin.role)       
          allow(User).to receive(:find_by).with(name: student1.name).and_return(student1)
          allow(admin).to receive(:can_impersonate?).with(student1).and_return(true)
          request.env['HTTP_REFERER'] = 'http://www.example.com'
    Severity: Major
    Found in spec/controllers/impersonate_controller_spec.rb and 7 other locations - About 2 hrs to fix
    spec/controllers/impersonate_controller_spec.rb on lines 87..98
    spec/controllers/impersonate_controller_spec.rb on lines 148..159
    spec/controllers/impersonate_controller_spec.rb on lines 162..173
    spec/controllers/impersonate_controller_spec.rb on lines 187..198
    spec/controllers/impersonate_controller_spec.rb on lines 201..212
    spec/controllers/impersonate_controller_spec.rb on lines 215..226
    spec/controllers/impersonate_controller_spec.rb on lines 229..240

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

    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 8 locations. Consider refactoring.
    Open

        it 'admin should be able to impersonate a teaching assistant with their real name' do
          stub_current_user(admin, admin.role.name, admin.role)
          allow(User).to receive(:find_by).with(name: teaching_assistant.name).and_return(teaching_assistant)
          allow(admin).to receive(:can_impersonate?).with(teaching_assistant).and_return(true)
          request.env['HTTP_REFERER'] = 'http://www.example.com'
    Severity: Major
    Found in spec/controllers/impersonate_controller_spec.rb and 7 other locations - About 2 hrs to fix
    spec/controllers/impersonate_controller_spec.rb on lines 87..98
    spec/controllers/impersonate_controller_spec.rb on lines 134..145
    spec/controllers/impersonate_controller_spec.rb on lines 162..173
    spec/controllers/impersonate_controller_spec.rb on lines 187..198
    spec/controllers/impersonate_controller_spec.rb on lines 201..212
    spec/controllers/impersonate_controller_spec.rb on lines 215..226
    spec/controllers/impersonate_controller_spec.rb on lines 229..240

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

    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 8 locations. Consider refactoring.
    Open

        it 'super admin should be able to impersonate an instructor with their real name' do
          stub_current_user(super_admin, super_admin.role.name, super_admin.role)
          allow(User).to receive(:find_by).with(name: instructor.name).and_return(instructor)
          allow(super_admin).to receive(:can_impersonate?).with(instructor).and_return(true)
          request.env['HTTP_REFERER'] = 'http://www.example.com'
    Severity: Major
    Found in spec/controllers/impersonate_controller_spec.rb and 7 other locations - About 2 hrs to fix
    spec/controllers/impersonate_controller_spec.rb on lines 87..98
    spec/controllers/impersonate_controller_spec.rb on lines 134..145
    spec/controllers/impersonate_controller_spec.rb on lines 148..159
    spec/controllers/impersonate_controller_spec.rb on lines 162..173
    spec/controllers/impersonate_controller_spec.rb on lines 187..198
    spec/controllers/impersonate_controller_spec.rb on lines 201..212
    spec/controllers/impersonate_controller_spec.rb on lines 229..240

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

    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 8 locations. Consider refactoring.
    Open

        it 'admin should be able to impersonate an instructor with their real name' do
          stub_current_user(admin, admin.role.name, admin.role)
          allow(User).to receive(:find_by).with(name: instructor.name).and_return(instructor)
          allow(admin).to receive(:can_impersonate?).with(instructor).and_return(true)
          request.env['HTTP_REFERER'] = 'http://www.example.com'
    Severity: Major
    Found in spec/controllers/impersonate_controller_spec.rb and 7 other locations - About 2 hrs to fix
    spec/controllers/impersonate_controller_spec.rb on lines 87..98
    spec/controllers/impersonate_controller_spec.rb on lines 134..145
    spec/controllers/impersonate_controller_spec.rb on lines 148..159
    spec/controllers/impersonate_controller_spec.rb on lines 187..198
    spec/controllers/impersonate_controller_spec.rb on lines 201..212
    spec/controllers/impersonate_controller_spec.rb on lines 215..226
    spec/controllers/impersonate_controller_spec.rb on lines 229..240

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

    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

        it 'instructor should be able to impersonate a teaching assistant user with their real name' do
          allow(User).to receive(:find_by).with(name: teaching_assistant.name).and_return(teaching_assistant)
          allow(instructor).to receive(:can_impersonate?).with(teaching_assistant).and_return(true)
          request.env['HTTP_REFERER'] = 'http://www.example.com'
          @params = { user: { name: teaching_assistant.name } }
    Severity: Major
    Found in spec/controllers/impersonate_controller_spec.rb and 1 other location - About 1 hr to fix
    spec/controllers/impersonate_controller_spec.rb on lines 41..51

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

    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

        it 'instructor should be able to impersonate a user with their real name' do
          allow(User).to receive(:find_by).with(name: student1.name).and_return(student1)
          allow(instructor).to receive(:can_impersonate?).with(student1).and_return(true)
          request.env['HTTP_REFERER'] = 'http://www.example.com'
          @params = { user: { name: student1.name } }
    Severity: Major
    Found in spec/controllers/impersonate_controller_spec.rb and 1 other location - About 1 hr to fix
    spec/controllers/impersonate_controller_spec.rb on lines 74..84

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

    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 4 locations. Consider refactoring.
    Open

        it 'teaching assistant should not be able to impersonate an instructor with their real name' do
          stub_current_user(teaching_assistant, teaching_assistant.role.name, teaching_assistant.role)
          allow(User).to receive(:find_by).with(name: instructor.name).and_return(instructor)
          allow(teaching_assistant).to receive(:can_impersonate?).with(instructor).and_return(false)
          request.env['HTTP_REFERER'] = 'http://www.example.com'
    Severity: Major
    Found in spec/controllers/impersonate_controller_spec.rb and 3 other locations - About 1 hr to fix
    spec/controllers/impersonate_controller_spec.rb on lines 112..120
    spec/controllers/impersonate_controller_spec.rb on lines 123..131
    spec/controllers/impersonate_controller_spec.rb on lines 176..184

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

    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 4 locations. Consider refactoring.
    Open

        it 'teaching assistant should not be able to impersonate an super admin with their real name' do
          stub_current_user(teaching_assistant, teaching_assistant.role.name, teaching_assistant.role)
          allow(User).to receive(:find_by).with(name: super_admin.name).and_return(super_admin)
          allow(teaching_assistant).to receive(:can_impersonate?).with(super_admin).and_return(false)
          request.env['HTTP_REFERER'] = 'http://www.example.com'
    Severity: Major
    Found in spec/controllers/impersonate_controller_spec.rb and 3 other locations - About 1 hr to fix
    spec/controllers/impersonate_controller_spec.rb on lines 101..109
    spec/controllers/impersonate_controller_spec.rb on lines 112..120
    spec/controllers/impersonate_controller_spec.rb on lines 176..184

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

    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 4 locations. Consider refactoring.
    Open

        it 'admin should not be able to impersonate a super admin with their real name' do
          stub_current_user(admin, admin.role.name, admin.role)
          allow(User).to receive(:find_by).with(name: super_admin.name).and_return(super_admin)
          allow(admin).to receive(:can_impersonate?).with(super_admin).and_return(false)
          request.env['HTTP_REFERER'] = 'http://www.example.com'
    Severity: Major
    Found in spec/controllers/impersonate_controller_spec.rb and 3 other locations - About 1 hr to fix
    spec/controllers/impersonate_controller_spec.rb on lines 101..109
    spec/controllers/impersonate_controller_spec.rb on lines 112..120
    spec/controllers/impersonate_controller_spec.rb on lines 123..131

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

    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 4 locations. Consider refactoring.
    Open

        it 'teaching assistant should not be able to impersonate an admin with their real name' do
          stub_current_user(teaching_assistant, teaching_assistant.role.name, teaching_assistant.role)
          allow(User).to receive(:find_by).with(name: admin.name).and_return(admin)
          allow(teaching_assistant).to receive(:can_impersonate?).with(admin).and_return(false)
          request.env['HTTP_REFERER'] = 'http://www.example.com'
    Severity: Major
    Found in spec/controllers/impersonate_controller_spec.rb and 3 other locations - About 1 hr to fix
    spec/controllers/impersonate_controller_spec.rb on lines 101..109
    spec/controllers/impersonate_controller_spec.rb on lines 123..131
    spec/controllers/impersonate_controller_spec.rb on lines 176..184

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

    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

        it 'instructor should not be able to impersonate an admin user with their real name' do
          allow(User).to receive(:find_by).with(name: admin.name).and_return(admin)
          allow(instructor).to receive(:can_impersonate?).with(admin).and_return(false)
          request.env['HTTP_REFERER'] = 'http://www.example.com'
          @params = { user: { name: admin.name } }
    Severity: Major
    Found in spec/controllers/impersonate_controller_spec.rb and 1 other location - About 1 hr to fix
    spec/controllers/impersonate_controller_spec.rb on lines 54..61

    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

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

        it 'instructor should not be able to impersonate a super admin user with their real name' do
          allow(User).to receive(:find_by).with(name: super_admin.name).and_return(super_admin)
          allow(instructor).to receive(:can_impersonate?).with(super_admin).and_return(false)
          request.env['HTTP_REFERER'] = 'http://www.example.com'
          @params = { user: { name: super_admin.name } }
    Severity: Major
    Found in spec/controllers/impersonate_controller_spec.rb and 1 other location - About 1 hr to fix
    spec/controllers/impersonate_controller_spec.rb on lines 64..71

    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

    Trailing whitespace detected.
    Open

          stub_current_user(admin, admin.role.name, admin.role)       

    Trailing whitespace detected.
    Open

          stub_current_user(super_admin, super_admin.role.name, super_admin.role)       

    There are no issues that match your filters.

    Category
    Status