expertiza/expertiza

View on GitHub
spec/controllers/assignments_controller_spec.rb

Summary

Maintainability
D
1 day
Test Coverage

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

describe AssignmentsController do
  let(:assignment) do
    build(:assignment, id: 1, name: 'test assignment', instructor_id: 6, staggered_deadline: true, directory_path: 'test_assignment',
                       participants: [build(:participant)], teams: [build(:assignment_team)], course_id: 1)
  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. [103/25]
Open

  describe '#update' do
    context 'when params does not have key :assignment_form' do
      context 'when assignment is saved successfully' do
        it 'shows a note flash message and redirects to tree_display#index page' do
          allow(assignment).to receive(:save).and_return(true)

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

  describe '#create' do
    before(:each) do
      allow(AssignmentForm).to receive(:new).with(any_args).and_return(assignment_form)
      @used_params = {
        button: true,

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

describe AssignmentsController do
  let(:assignment) do
    build(:assignment, id: 1, name: 'test assignment', instructor_id: 6, staggered_deadline: true, directory_path: 'test_assignment',
                       participants: [build(:participant)], teams: [build(:assignment_team)], course_id: 1)
  end
Severity: Minor
Found in spec/controllers/assignments_controller_spec.rb - About 6 hrs to fix

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

        context 'when params has key :assignment_form' do
          before(:each) do
            new_assignment_questionnaire = AssignmentQuestionnaire.new
            allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: '1').and_return([assignment_questionnaire])
            allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 2).and_return([])

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

        before(:each) do
          allow(AssignmentForm).to receive(:new).with(any_args).and_return(assignment_form)
          @used_params = {
            button: true,
            assignment_form: {

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

      describe '#action_allowed?' do
        context 'when params action is edit or update' do
          before(:each) do
            controller.params = { id: '1', action: 'edit' }
          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

        context 'when params action is edit or update' do
          before(:each) do
            controller.params = { id: '1', action: 'edit' }
          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. [40/25]
    Open

          before(:each) do
            new_assignment_questionnaire = AssignmentQuestionnaire.new
            allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: '1').and_return([assignment_questionnaire])
            allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 2).and_return([])
            allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 2, used_in_round: anything).and_return([])

    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 '#delete' do
        context 'when assignment is deleted successfully' do
          it 'shows a success flash message and redirects to tree_display#list page' do
            assignment_form = AssignmentForm.new
            allow(AssignmentForm).to receive(:new).and_return(assignment_form)

    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

        context 'when params does not have key :assignment_form' do
          context 'when assignment is saved successfully' do
            it 'shows a note flash message and redirects to tree_display#index page' do
              allow(assignment).to receive(:save).and_return(true)
              request_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.

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

          @new_params = {
            button: true,
            assignment_form: {
              assignment_questionnaire: [{ 'assignment_id' => '1', 'questionnaire_id' => '666', 'dropdown' => 'true',
                                           'questionnaire_weight' => '100', 'notification_limit' => '15', 'used_in_round' => '1' }],
    Severity: Major
    Found in spec/controllers/assignments_controller_spec.rb and 1 other location - About 2 hrs to fix
    spec/controllers/assignments_controller_spec.rb on lines 106..135

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

    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

          @used_params = {
            button: true,
            assignment_form: {
              assignment_questionnaire: [{ 'assignment_id' => '1', 'questionnaire_id' => '666', 'dropdown' => 'true',
                                           'questionnaire_weight' => '100', 'notification_limit' => '15', 'used_in_round' => '1' }],
    Severity: Major
    Found in spec/controllers/assignments_controller_spec.rb and 1 other location - About 2 hrs to fix
    spec/controllers/assignments_controller_spec.rb on lines 136..165

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

    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

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

          context 'when current user is the instructor of the course which current assignment belongs to' do
            it 'allows certain action' do
              stub_current_user(instructor2, instructor2.role.name, instructor2.role)
              allow(Course).to receive(:find).with(1).and_return(double('Course', instructor_id: 66))
              expect(controller.send(:action_allowed?)).to be true
    Severity: Minor
    Found in spec/controllers/assignments_controller_spec.rb and 1 other location - About 35 mins to fix
    spec/controllers/duties_controller_spec.rb on lines 44..48

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

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

          context 'when current user is the ta of the course which current assignment belongs to' do
            it 'allows certain action' do
              stub_current_user(ta, ta.role.name, ta.role)
              allow(TaMapping).to receive(:exists?).with(ta_id: 8, course_id: 1).and_return(true)
              expect(controller.send(:action_allowed?)).to be true
    Severity: Minor
    Found in spec/controllers/assignments_controller_spec.rb and 2 other locations - About 35 mins to fix
    spec/controllers/duties_controller_spec.rb on lines 36..40
    spec/controllers/submission_records_controller_spec.rb on lines 61..65

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

    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 current user is a ta but not the ta of the course which current assignment belongs to' do
            it 'does not allow certain action' do
              stub_current_user(ta, ta.role.name, ta.role)
              allow(TaMapping).to receive(:exists?).with(ta_id: 8, course_id: 1).and_return(false)
              expect(controller.send(:action_allowed?)).to be false
    Severity: Minor
    Found in spec/controllers/assignments_controller_spec.rb and 1 other location - About 35 mins to fix
    spec/controllers/submission_records_controller_spec.rb on lines 69..73

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

    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

      let(:assignment) do
        build(:assignment, id: 1, name: 'test assignment', instructor_id: 6, staggered_deadline: true, directory_path: 'test_assignment',
                           participants: [build(:participant)], teams: [build(:assignment_team)], course_id: 1)
    Severity: Minor
    Found in spec/controllers/assignments_controller_spec.rb and 4 other locations - About 15 mins to fix
    spec/controllers/assignment_questionnaire_controller_spec.rb on lines 8..10
    spec/controllers/assignments_controller_spec.rb on lines 6..8
    spec/controllers/teams_users_controller_spec.rb on lines 9..11
    spec/support/teams_shared.rb on lines 14..16

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

    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

      let(:assignment2) do
        build(:assignment, id: 2, name: 'new test assignment', instructor_id: 6, staggered_deadline: true, directory_path: 'new_test_assignment',
                           participants: [build(:participant)], teams: [build(:assignment_team)], course_id: 1)
    Severity: Minor
    Found in spec/controllers/assignments_controller_spec.rb and 4 other locations - About 15 mins to fix
    spec/controllers/assignment_questionnaire_controller_spec.rb on lines 8..10
    spec/controllers/assignments_controller_spec.rb on lines 2..4
    spec/controllers/teams_users_controller_spec.rb on lines 9..11
    spec/support/teams_shared.rb on lines 14..16

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

    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

    Useless assignment to variable - user_session.
    Open

            user_session = { user: instructor }

    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

    There are no issues that match your filters.

    Category
    Status