expertiza/expertiza

View on GitHub
spec/models/assignment_spec.rb

Summary

Maintainability
C
1 day
Test Coverage

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

describe Assignment do
  let(:assignment) { build(:assignment, id: 1, name: 'no assignment', participants: [participant], teams: [team]) }
  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 490 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]) }
  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 - About 7 hrs to fix

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

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

    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 '#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 54..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 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

    Line is too long. [232/160]
    Open

            @assignment_due_date = create(:assignment_due_date, parent_id: assignment.id, review_allowed_id: dead_rigth.id, review_of_review_allowed_id: dead_rigth.id, submission_allowed_id: dead_rigth.id, deadline_type: @deadline_type)
    Severity: Minor
    Found in spec/models/assignment_spec.rb by rubocop

    Use %r around regular expression.
    Open

            expect { assignment.add_participant('no one', nil, nil, nil) }.to raise_error(RuntimeError, /a href='users\/new\/1'>create<\/a> the user first/)
    Severity: Minor
    Found in spec/models/assignment_spec.rb by rubocop

    This cop enforces using // or %r around regular expressions.

    Example: EnforcedStyle: slashes (default)

    # bad
    snake_case = %r{^[\dA-Z_]+$}
    
    # bad
    regex = %r{
      foo
      (bar)
      (baz)
    }x
    
    # good
    snake_case = /^[\dA-Z_]+$/
    
    # good
    regex = /
      foo
      (bar)
      (baz)
    /x

    Example: EnforcedStyle: percent_r

    # bad
    snake_case = /^[\dA-Z_]+$/
    
    # bad
    regex = /
      foo
      (bar)
      (baz)
    /x
    
    # good
    snake_case = %r{^[\dA-Z_]+$}
    
    # good
    regex = %r{
      foo
      (bar)
      (baz)
    }x

    Example: EnforcedStyle: mixed

    # bad
    snake_case = %r{^[\dA-Z_]+$}
    
    # bad
    regex = /
      foo
      (bar)
      (baz)
    /x
    
    # good
    snake_case = /^[\dA-Z_]+$/
    
    # good
    regex = %r{
      foo
      (bar)
      (baz)
    }x

    Example: AllowInnerSlashes: false (default)

    # If `false`, the cop will always recommend using `%r` if one or more
    # slashes are found in the regexp string.
    
    # bad
    x =~ /home\//
    
    # good
    x =~ %r{home/}

    Example: AllowInnerSlashes: true

    # good
    x =~ /home\//

    Line is too long. [169/160]
    Open

                                                                                            .to(['Num of reviews required cannot be greater than number of reviews allowed'])
    Severity: Minor
    Found in spec/models/assignment_spec.rb by rubocop

    Line is too long. [182/160]
    Open

                                                                                            .to(['Number of Meta-Reviews required cannot be greater than number of meta-reviews allowed'])
    Severity: Minor
    Found in spec/models/assignment_spec.rb by rubocop

    There are no issues that match your filters.

    Category
    Status