expertiza/expertiza

View on GitHub
spec/features/quiz_spec.rb

Summary

Maintainability
B
5 hrs
Test Coverage

File quiz_spec.rb has 359 lines of code (exceeds 250 allowed). Consider refactoring.
Open

include InstructorInterfaceHelperSpec

def create_assignment_due_date
  set_deadline_type
  set_deadline_right
Severity: Minor
Found in spec/features/quiz_spec.rb - About 4 hrs to fix

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

    describe 'Student can create quizzes and edit them', js: true do
      before(:each) do
        create_default_test_data 1
      end
    
    
    Severity: Minor
    Found in spec/features/quiz_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.

    Method has too many lines. [20/10]
    Open

    def create_choices_for_weighted_questionnaire(ques_id, type)
      if type == 'TrueFalse'
        [
          create(:quiz_question_choice, question: @question, txt: 'True_' + ques_id, iscorrect: 1),
          create(:quiz_question_choice, question: @question, txt: 'False_' + ques_id)
    Severity: Minor
    Found in spec/features/quiz_spec.rb by rubocop

    This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

    Assignment Branch Condition size for create_choices_for_weighted_questionnaire is too high. [22.09/15]
    Open

    def create_choices_for_weighted_questionnaire(ques_id, type)
      if type == 'TrueFalse'
        [
          create(:quiz_question_choice, question: @question, txt: 'True_' + ques_id, iscorrect: 1),
          create(:quiz_question_choice, question: @question, txt: 'False_' + ques_id)
    Severity: Minor
    Found in spec/features/quiz_spec.rb by rubocop

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

    Assignment Branch Condition size for setup_score_views is too high. [20/15]
    Open

    def setup_score_views
      create :score_view, q1_id: @questionnaire.id, s_question_id: @question1.id, question_weight: 4, s_score: 1, s_response_id: @response.id, s_comments: 'True_1'
      create :score_view, q1_id: @questionnaire.id, s_question_id: @question2.id, question_weight: 2, s_score: 0, s_response_id: @response.id, s_comments: 'False_2'
      create :score_view, q1_id: @questionnaire.id, s_question_id: @question3.id, question_weight: 6, s_score: 0, s_response_id: @response.id, s_comments: 'Answer2_3'
      create :score_view, q1_id: @questionnaire.id, s_question_id: @question4.id, question_weight: 8, s_score: 1, s_response_id: @response.id, s_comments: 'Answer1_4'
    Severity: Minor
    Found in spec/features/quiz_spec.rb by rubocop

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

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

    describe 'appropriate quiz taking times', js: true do
      before(:each) do
        @instructor = create(:instructor)
        @assignment = create :assignment, require_quiz: true, instructor: @instructor, course: nil, num_quiz_questions: 1, review_topic_threshold: 1
        create_assignment_due_date
    Severity: Minor
    Found in spec/features/quiz_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. [26/25]
    Open

    describe 'Grading of quizzes takes weights into consideration', js: true do
      before :each do
        @instructor = create(:instructor)
        @assignment = create :assignment, require_quiz: true, instructor: @instructor, course: nil, num_quiz_questions: 4
        create_assignment_due_date
    Severity: Minor
    Found in spec/features/quiz_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

      before :each do
        @instructor = create(:instructor)
        @assignment = create :assignment, require_quiz: true, instructor: @instructor, course: nil, num_quiz_questions: 4
        create_assignment_due_date
        create_student1
    Severity: Minor
    Found in spec/features/quiz_spec.rb and 1 other location - About 35 mins to fix
    spec/features/quiz_spec.rb on lines 350..359

    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

      before :each do
        @instructor = create(:instructor)
        @assignment = create :assignment, require_quiz: true, instructor: @instructor, course: nil, num_quiz_questions: 1
        create_assignment_due_date
        create_student1
    Severity: Minor
    Found in spec/features/quiz_spec.rb and 1 other location - About 35 mins to fix
    spec/features/quiz_spec.rb on lines 382..391

    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

    Prefer Date or Time over DateTime.
    Open

      create :assignment_due_date, due_at: (DateTime.now.in_time_zone + 1.day)
    Severity: Minor
    Found in spec/features/quiz_spec.rb by rubocop

    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

      create :assignment_due_date, due_at: (DateTime.now.in_time_zone + 1.day), deadline_type: @review_deadline_type
    Severity: Minor
    Found in spec/features/quiz_spec.rb by rubocop

    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)

    include is used at the top level. Use inside class or module.
    Open

    include InstructorInterfaceHelperSpec
    Severity: Minor
    Found in spec/features/quiz_spec.rb by rubocop

    This cop checks that include, extend and prepend exists at the top level. Using these at the top level affects the behavior of Object. There will not be using include, extend and prepend at the top level. Let's use it inside class or module.

    Example:

    # bad
    include M
    
    class C
    end
    
    # bad
    extend M
    
    class C
    end
    
    # bad
    prepend M
    
    class C
    end
    
    # good
    class C
      include M
    end
    
    # good
    class C
      extend M
    end
    
    # good
    class C
      prepend M
    end

    There are no issues that match your filters.

    Category
    Status