ece517-p3/expertiza

View on GitHub
spec/controllers/sign_up_sheet_controller_spec.rb

Summary

Maintainability
D
1 day
Test Coverage

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

describe SignUpSheetController do
  let(:assignment) { build(:assignment, id: 1, instructor_id: 6, due_dates: [due_date], microtask: true, staggered_deadline: true) }
  let(:instructor) { build(:instructor, id: 6) }
  let(:student) { build(:student, id: 8) }
  let(:participant) { build(:participant, id: 1, user_id: 6, assignment: assignment) }

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

describe SignUpSheetController do
  let(:assignment) { build(:assignment, id: 1, instructor_id: 6, due_dates: [due_date], microtask: true, staggered_deadline: true) }
  let(:instructor) { build(:instructor, id: 6) }
  let(:student) { build(:student, id: 8) }
  let(:participant) { build(:participant, id: 1, user_id: 6, assignment: assignment) }
Severity: Minor
Found in spec/controllers/sign_up_sheet_controller_spec.rb - About 6 hrs to fix

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

      describe '#signup_as_instructor_action' do
        context 'when user cannot be found' do
          it 'shows an flash error message and redirects to assignment#edit page' do
            allow(User).to receive(:find_by).with(name: 'no name').and_return(nil)
            allow(User).to receive(:find).with(8).and_return(student)

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

      describe '#create' do
        context 'when topic cannot be found' do
          context 'when new topic can be saved successfully' do
            it 'sets up a new topic and redirects to assignment#edit page' do
              allow(SignUpTopic).to receive(:where).with(topic_name: 'Hello world!', assignment_id: '1').and_return([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. [53/25]
    Open

        context 'when user can be found' do
          before(:each) do
            allow(User).to receive(:find_by).with(name: 'no name').and_return(student)
          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. [42/25]
    Open

      describe '#delete_signup_as_instructor' do
        before(:each) do
          allow(Team).to receive(:find).with('1').and_return(team)
          allow(TeamsUser).to receive(:find_by).with(team_id: 1).and_return(double('TeamsUser', user: student))
          allow(AssignmentParticipant).to receive(:find_by).with(user_id: 8, parent_id: 1).and_return(participant)

    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

        context 'when topic cannot be found' do
          context 'when new topic can be saved successfully' do
            it 'sets up a new topic and redirects to assignment#edit page' do
              allow(SignUpTopic).to receive(:where).with(topic_name: 'Hello world!', assignment_id: '1').and_return([nil])
              allow_any_instance_of(SignUpSheetController).to receive(:undo_link)

    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 '#delete_signup' do
        before(:each) do
          allow(participant).to receive(:team).and_return(team)
        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. [36/25]
    Open

          context 'when an assignment_participant can be found' do
            before(:each) do
              allow(AssignmentParticipant).to receive(:exists?).with(user_id: 8, parent_id: '1').and_return(true)
            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. [33/25]
    Open

      describe '#update' do
        context 'when topic cannot be found' do
          it 'shows an error flash message and redirects to assignment#edit page' do
            allow(SignUpTopic).to receive(:find).with('1').and_return(nil)
            params = {id: 1, assignment_id: 1}

    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 '#save_topic_deadlines' do
        context 'when topic_due_date cannot be found' do
          it 'creates a new topic_due_date record and redirects to assignment#edit page' do
            assignment.due_dates = [due_date, due_date2]
            allow(SignUpTopic).to receive(:where).with(assignment_id: '1').and_return([topic])

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

      describe '#list' do
        before(:each) do
          allow(SignUpTopic).to receive(:find_slots_filled).with(1).and_return([topic])
          allow(SignUpTopic).to receive(:find_slots_waitlisted).with(1).and_return([])
          allow(SignUpTopic).to receive(:where).with(assignment_id: 1, private_to: nil).and_return([topic])

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

        context 'when both submitted files and hyperlinks of current team are empty and drop topic deadline is not nil and its due date has already passed' do
          it 'shows a flash error message and redirects to assignment#edit page' do
            due_date.due_at = DateTime.now.in_time_zone - 1.day
            allow(assignment.due_dates).to receive(:find_by).with(deadline_type_id: 6).and_return(due_date)
            allow(team).to receive(:submitted_files).and_return([])
    Severity: Major
    Found in spec/controllers/sign_up_sheet_controller_spec.rb and 1 other location - About 1 hr to fix
    spec/controllers/sign_up_sheet_controller_spec.rb on lines 306..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 65.

    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

        context 'when both submitted files and hyperlinks of current team are empty and drop topic deadline is not nil and its due date has already passed' do
          it 'shows a flash error message and redirects to sign_up_sheet#list page' do
            due_date.due_at = DateTime.now.in_time_zone - 1.day
            allow(assignment.due_dates).to receive(:find_by).with(deadline_type_id: 6).and_return(due_date)
            allow(team).to receive(:submitted_files).and_return([])
    Severity: Major
    Found in spec/controllers/sign_up_sheet_controller_spec.rb and 1 other location - About 1 hr to fix
    spec/controllers/sign_up_sheet_controller_spec.rb on lines 354..364

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

    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

        context 'when both submitted files and hyperlinks of current team are empty and drop topic deadline is nil' do
          it 'shows a flash success message and redirects to assignment#edit page' do
            allow(team).to receive(:submitted_files).and_return([])
            allow(team).to receive(:hyperlinks).and_return([])
            allow(SignedUpTeam).to receive(:find_team_users).with(1, 6).and_return([team])
    Severity: Major
    Found in spec/controllers/sign_up_sheet_controller_spec.rb and 1 other location - About 1 hr to fix
    spec/controllers/sign_up_sheet_controller_spec.rb on lines 320..330

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

    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

        context 'when both submitted files and hyperlinks of current team are empty and drop topic deadline is nil' do
          it 'shows a flash success message and redirects to sign_up_sheet#list page' do
            allow(team).to receive(:submitted_files).and_return([])
            allow(team).to receive(:hyperlinks).and_return([])
            allow(SignedUpTeam).to receive(:find_team_users).with(1, 6).and_return([team])
    Severity: Major
    Found in spec/controllers/sign_up_sheet_controller_spec.rb and 1 other location - About 1 hr to fix
    spec/controllers/sign_up_sheet_controller_spec.rb on lines 368..378

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

    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

        context 'when either submitted files or hyperlinks of current team are not empty' do
          it 'shows a flash error message and redirects to sign_up_sheet#list page' do
            allow(assignment).to receive(:instructor).and_return(instructor)
            params = {id: 1}
            session = {user: instructor}
    Severity: Minor
    Found in spec/controllers/sign_up_sheet_controller_spec.rb and 1 other location - About 40 mins to fix
    spec/controllers/sign_up_sheet_controller_spec.rb on lines 343..350

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

    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

        context 'when either submitted files or hyperlinks of current team are not empty' do
          it 'shows a flash error message and redirects to assignment#edit page' do
            allow(assignment).to receive(:instructor).and_return(instructor)
            params = {id: 1}
            session = {user: instructor}
    Severity: Minor
    Found in spec/controllers/sign_up_sheet_controller_spec.rb and 1 other location - About 40 mins to fix
    spec/controllers/sign_up_sheet_controller_spec.rb on lines 295..302

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

    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

    Prefer Date or Time over DateTime.
    Open

            due_date.due_at = DateTime.now.in_time_zone - 1.day

    This cop checks for uses of DateTime that should be replaced by Date or Time.

    Example:

    # bad - uses `DateTime` for current time
    DateTime.now
    
    # good - uses `Time` for current time
    Time.now
    
    # bad - uses `DateTime` for modern date
    DateTime.iso8601('2016-06-29')
    
    # good - uses `Date` for modern date
    Date.iso8601('2016-06-29')
    
    # good - uses `DateTime` with start argument for historical date
    DateTime.iso8601('1751-04-23', Date::ENGLAND)

    Prefer Date or Time over DateTime.
    Open

            due_date.due_at = DateTime.now.in_time_zone - 1.day

    This cop checks for uses of DateTime that should be replaced by Date or Time.

    Example:

    # bad - uses `DateTime` for current time
    DateTime.now
    
    # good - uses `Time` for current time
    Time.now
    
    # bad - uses `DateTime` for modern date
    DateTime.iso8601('2016-06-29')
    
    # good - uses `Date` for modern date
    Date.iso8601('2016-06-29')
    
    # good - uses `DateTime` with start argument for historical date
    DateTime.iso8601('1751-04-23', Date::ENGLAND)

    There are no issues that match your filters.

    Category
    Status