expertiza/expertiza

View on GitHub
spec/models/assignment_spec.rb

Summary

Maintainability
D
1 day
Test Coverage

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

describe Assignment do
  let(:assignment) { build(:assignment, id: 1, name: 'no assignment', participants: [participant], teams: [team], max_team_size: 2) }
  let(:instructor) { build(:instructor, id: 6) }
  let(:student) { build(:student, id: 3, name: 'no one') }
  let(:review_response_map) { build(:review_response_map, response: [response], reviewer: build(:participant), reviewee: build(:assignment_team)) }
Severity: Minor
Found in spec/models/assignment_spec.rb by rubocop

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

File assignment_spec.rb has 659 lines of code (exceeds 250 allowed). Consider refactoring.
Open

describe Assignment do
  let(:assignment) { build(:assignment, id: 1, name: 'no assignment', participants: [participant], teams: [team], max_team_size: 2) }
  let(:instructor) { build(:instructor, id: 6) }
  let(:student) { build(:student, id: 3, name: 'no one') }
  let(:review_response_map) { build(:review_response_map, response: [response], reviewer: build(:participant), reviewee: build(:assignment_team)) }
Severity: Major
Found in spec/models/assignment_spec.rb - About 1 day to fix

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

      describe '#review_questionnaire_id' do
        context 'when corresponding active record for assignment_questionnaire is found' do
          before(:each) do
            allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: assignment.id).and_return(
              [assignment_questionnaire1, assignment_questionnaire2]
    Severity: Minor
    Found in spec/models/assignment_spec.rb by rubocop

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

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

      describe 'has correct csv values?' do
        before(:each) do
          create(:assignment)
          create(:assignment_team, name: 'team1')
          @student = create(:student, name: 'student1')
    Severity: Minor
    Found in spec/models/assignment_spec.rb by rubocop

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

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

        context 'when corresponding active record for assignment_questionnaire is found' do
          before(:each) do
            allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: assignment.id).and_return(
              [assignment_questionnaire1, assignment_questionnaire2]
            )
    Severity: Minor
    Found in spec/models/assignment_spec.rb by rubocop

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

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

      describe '#delete' do
        before(:each) do
          allow(ReviewResponseMap).to receive(:where).with(reviewed_object_id: 1).and_return([review_response_map])
          allow(TeammateReviewResponseMap).to receive(:where).with(reviewed_object_id: 1).and_return([teammate_review_response_map])
        end
    Severity: Minor
    Found in spec/models/assignment_spec.rb by rubocop

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

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

      describe '#current_stage_name' do
        context 'when assignment has staggered deadline' do
          before(:each) { allow(assignment).to receive(:staggered_deadline?).and_return(true) }
          context 'topic_id is nil' do
            it 'returns Unknow' do
    Severity: Minor
    Found in spec/models/assignment_spec.rb by rubocop

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

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

          before(:each) do
            allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: assignment.id).and_return(
              [assignment_questionnaire1, assignment_questionnaire2]
            )
            allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: assignment.id, used_in_round: 2).and_return([])
    Severity: Minor
    Found in spec/models/assignment_spec.rb and 1 other location - About 45 mins to fix
    spec/models/self_review_response_map_spec.rb on lines 15..20

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

    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

      describe '#topics?' do
        context 'when sign_up_topics array is not empty' do
          it 'says current assignment has topics' do
            assignment.sign_up_topics << build(:topic)
            expect(assignment.topics?).to be true
    Severity: Minor
    Found in spec/models/assignment_spec.rb and 1 other location - About 40 mins to fix
    spec/models/assignment_spec.rb on lines 74..85

    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

      describe '#teams?' do
        context 'when teams array is not empty' do
          it 'says current assignment has teams' do
            assignment.teams << build(:assignment_team)
            expect(assignment.teams?).to be true
    Severity: Minor
    Found in spec/models/assignment_spec.rb and 1 other location - About 40 mins to fix
    spec/models/assignment_spec.rb on lines 50..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 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 the assignment has rounds' do
          it 'it returns the id of the associated questionnaires from the round' do
            allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, used_in_round: 1).and_return([assignment_questionnaire1])
            expect(assignment.questionnaire_ids(1)).to eq([assignment_questionnaire1])
    Severity: Minor
    Found in spec/models/assignment_spec.rb and 1 other location - About 25 mins to fix
    spec/models/course_spec.rb on lines 53..56

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

    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

    Extra empty line detected at block body end.
    Open

    
      end
    Severity: Minor
    Found in spec/models/assignment_spec.rb by rubocop

    This cops checks if empty lines around the bodies of blocks match the configuration.

    Example: EnforcedStyle: empty_lines

    # good
    
    foo do |bar|
    
      # ...
    
    end

    Example: EnforcedStyle: noemptylines (default)

    # good
    
    foo do |bar|
      # ...
    end

    1 trailing blank lines detected.
    Open

    Severity: Minor
    Found in spec/models/assignment_spec.rb by rubocop

    There are no issues that match your filters.

    Category
    Status