expertiza/expertiza

View on GitHub
spec/helpers/authorization_helper_spec.rb

Summary

Maintainability
D
2 days
Test Coverage

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

describe AuthorizationHelper do
  # Set up some dummy users
  # Inspired by spec/controllers/users_controller_spec.rb
  # Makes use of spec/factories/factories.rb
  # Use create instead of build so that these users get IDs

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

describe AuthorizationHelper do
  # Set up some dummy users
  # Inspired by spec/controllers/users_controller_spec.rb
  # Makes use of spec/factories/factories.rb
  # Use create instead of build so that these users get IDs
Severity: Major
Found in spec/helpers/authorization_helper_spec.rb - About 1 day to fix

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

      describe '.response_edit_allowed?' do
        it 'returns false if current user is not logged in' do
          map = create(:review_response_map)
          session[:user] = nil
          expect(response_edit_allowed?(map, 1)).to be false

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

      describe '.current_user_is_assignment_participant?' do
        # Makes use of existing :assignment_team, :participant, and :assignment factories
    
        it 'returns false if there is no current user' do
          session[:user] = nil

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

      describe '.current_user_ancestor_of?' do
        it 'returns false if there is no logged in user' do
          session[:user] = nil
          expect(current_user_ancestor_of?(instructor)).to be false
        end

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

      describe '.current_user_is_a?' do
        it 'returns false if there is no current user' do
          session[:user] = nil
          expect(current_user_is_a?('Student')).to be false
        end

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

      describe '.current_user_instructs_assignment?' do
        it 'returns false if there is no logged in user' do
          assignment = create(:assignment)
          session[:user] = nil
          expect(current_user_instructs_assignment?(assignment)).to be false

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

      describe '.find_assignment_from_response_id' do
        # Makes use of existing :response, :review_response_map, and :meta_review_response_map factories
    
        it 'returns the assignment if one is found without recursion' do
          response = create(:response)

    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.

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

      describe '.given_user_can_take_quiz?' do
        it 'returns false if there is no given user' do
          expect(given_user_can_take_quiz?(nil)).to be false
        end
    
    
    Severity: Major
    Found in spec/helpers/authorization_helper_spec.rb and 3 other locations - About 1 hr to fix
    spec/helpers/authorization_helper_spec.rb on lines 420..436
    spec/helpers/authorization_helper_spec.rb on lines 440..456
    spec/helpers/authorization_helper_spec.rb on lines 480..496

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

    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

      describe '.given_user_can_read?' do
        it 'returns false if there is no given user' do
          expect(given_user_can_read?(nil)).to be false
        end
    
    
    Severity: Major
    Found in spec/helpers/authorization_helper_spec.rb and 3 other locations - About 1 hr to fix
    spec/helpers/authorization_helper_spec.rb on lines 420..436
    spec/helpers/authorization_helper_spec.rb on lines 440..456
    spec/helpers/authorization_helper_spec.rb on lines 460..476

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

    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

      describe '.given_user_can_submit?' do
        it 'returns false if there is no given user' do
          expect(given_user_can_submit?(nil)).to be false
        end
    
    
    Severity: Major
    Found in spec/helpers/authorization_helper_spec.rb and 3 other locations - About 1 hr to fix
    spec/helpers/authorization_helper_spec.rb on lines 440..456
    spec/helpers/authorization_helper_spec.rb on lines 460..476
    spec/helpers/authorization_helper_spec.rb on lines 480..496

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

    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

      describe '.given_user_can_review?' do
        it 'returns false if there is no given user' do
          expect(given_user_can_review?(nil)).to be false
        end
    
    
    Severity: Major
    Found in spec/helpers/authorization_helper_spec.rb and 3 other locations - About 1 hr to fix
    spec/helpers/authorization_helper_spec.rb on lines 420..436
    spec/helpers/authorization_helper_spec.rb on lines 460..476
    spec/helpers/authorization_helper_spec.rb on lines 480..496

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

    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 'returns true if map is not of type ReviewResponseMap and logged in user is the reviewer' do
          stub_current_user(instructor, instructor.role.name, instructor.role)
    
          reviewer = create(:participant, user_id: session[:user].id)
          map = create(:meta_review_response_map, reviewer: reviewer)
    Severity: Minor
    Found in spec/helpers/authorization_helper_spec.rb and 1 other location - About 35 mins to fix
    spec/helpers/authorization_helper_spec.rb on lines 520..524

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

    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 'returns true if map is of type ReviewResponseMap and logged in user is the reviewer' do
          stub_current_user(instructor, instructor.role.name, instructor.role)
          reviewer = create(:participant, user_id: session[:user].id)
          map = create(:review_response_map, reviewer: reviewer)
          expect(response_edit_allowed?(map, map.reviewer.user_id)).to be true
    Severity: Minor
    Found in spec/helpers/authorization_helper_spec.rb and 1 other location - About 35 mins to fix
    spec/helpers/authorization_helper_spec.rb on lines 512..517

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

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

        it 'returns true if current user is an instructor and participates in assignment' do
          stub_current_user(instructor, instructor.role.name, instructor.role)
          participant = create(:participant, user: session[:user])
          expect(current_user_is_assignment_participant?(participant.assignment.id)).to be true
    Severity: Minor
    Found in spec/helpers/authorization_helper_spec.rb and 4 other locations - About 20 mins to fix
    spec/helpers/authorization_helper_spec.rb on lines 295..298
    spec/helpers/authorization_helper_spec.rb on lines 301..304
    spec/helpers/authorization_helper_spec.rb on lines 313..316
    spec/helpers/authorization_helper_spec.rb on lines 319..322

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

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

        it 'returns true if current user is a student and participates in assignment' do
          stub_current_user(student, student.role.name, student.role)
          participant = create(:participant, user: session[:user])
          expect(current_user_is_assignment_participant?(participant.assignment.id)).to be true
    Severity: Minor
    Found in spec/helpers/authorization_helper_spec.rb and 4 other locations - About 20 mins to fix
    spec/helpers/authorization_helper_spec.rb on lines 301..304
    spec/helpers/authorization_helper_spec.rb on lines 307..310
    spec/helpers/authorization_helper_spec.rb on lines 313..316
    spec/helpers/authorization_helper_spec.rb on lines 319..322

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

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

        it 'returns true if current user is an admin and participates in assignment' do
          stub_current_user(admin, admin.role.name, admin.role)
          participant = create(:participant, user: session[:user])
          expect(current_user_is_assignment_participant?(participant.assignment.id)).to be true
    Severity: Minor
    Found in spec/helpers/authorization_helper_spec.rb and 4 other locations - About 20 mins to fix
    spec/helpers/authorization_helper_spec.rb on lines 295..298
    spec/helpers/authorization_helper_spec.rb on lines 301..304
    spec/helpers/authorization_helper_spec.rb on lines 307..310
    spec/helpers/authorization_helper_spec.rb on lines 319..322

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

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

        it 'returns true if current user is a TA and participates in assignment' do
          stub_current_user(teaching_assistant, teaching_assistant.role.name, teaching_assistant.role)
          participant = create(:participant, user: session[:user])
          expect(current_user_is_assignment_participant?(participant.assignment.id)).to be true
    Severity: Minor
    Found in spec/helpers/authorization_helper_spec.rb and 4 other locations - About 20 mins to fix
    spec/helpers/authorization_helper_spec.rb on lines 295..298
    spec/helpers/authorization_helper_spec.rb on lines 307..310
    spec/helpers/authorization_helper_spec.rb on lines 313..316
    spec/helpers/authorization_helper_spec.rb on lines 319..322

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

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

        it 'returns true if current user is a super-admin and participates in assignment' do
          stub_current_user(superadmin, superadmin.role.name, superadmin.role)
          participant = create(:participant, user: session[:user])
          expect(current_user_is_assignment_participant?(participant.assignment.id)).to be true
    Severity: Minor
    Found in spec/helpers/authorization_helper_spec.rb and 4 other locations - About 20 mins to fix
    spec/helpers/authorization_helper_spec.rb on lines 295..298
    spec/helpers/authorization_helper_spec.rb on lines 301..304
    spec/helpers/authorization_helper_spec.rb on lines 307..310
    spec/helpers/authorization_helper_spec.rb on lines 313..316

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

    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

    There are no issues that match your filters.

    Category
    Status