ece517-p3/expertiza

View on GitHub
spec/controllers/questionnaires_controller_spec.rb

Summary

Maintainability
C
1 day
Test Coverage

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

describe QuestionnairesController do
  let(:questionnaire) do
    build(id: 1, name: 'questionnaire', ta_id: 8, course_id: 1, private: false, min_question_score: 0, max_question_score: 5, type: 'ReviewQuestionnaire')
  end
  let(:questionnaire) { build(:questionnaire) }

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

describe QuestionnairesController do
  let(:questionnaire) do
    build(id: 1, name: 'questionnaire', ta_id: 8, course_id: 1, private: false, min_question_score: 0, max_question_score: 5, type: 'ReviewQuestionnaire')
  end
  let(:questionnaire) { build(:questionnaire) }
Severity: Major
Found in spec/controllers/questionnaires_controller_spec.rb - About 1 day to fix

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

      describe '#create_quiz_questionnaire, #create_questionnaire and #save' do
        context 'when quiz is valid' do
          before(:each) do
            # create_quiz_questionnaire
            allow_any_instance_of(QuestionnairesController).to receive(:valid_quiz).and_return('valid')

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

      describe '#update_quiz' do
        context 'when @questionnaire is nil' do
          it 'redirects to submitted_content#view page' do
            allow(Questionnaire).to receive(:find).with('1').and_return(nil)
            params = {id: 1, pid: 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. [54/25]
    Open

      describe '#action_allowed?' do
        let(:questionnaire) { build(:questionnaire, id: 1) }
        let(:instructor) { build(:instructor, id: 1) }
        let(:ta) { build(:teaching_assistant, id: 10, parent_id: 66) }
        context 'when params action is edit or update' do

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

        context 'when @questionnaire is not nil' do
          it 'updates all quiz questions and redirects to submitted_content#view page' do
            params = {id: 1,
                      pid: 1,
                      save: 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. [49/25]
    Open

      describe '#delete' do
        context 'when @questionnaire.assignments returns non-empty array' do
          it 'sends the error message to flash[:error]' do
            questionnaire1 = double('Questionnaire',
                                    name: 'test questionnaire',

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

        context 'when quiz is valid' do
          before(:each) do
            # create_quiz_questionnaire
            allow_any_instance_of(QuestionnairesController).to receive(:valid_quiz).and_return('valid')
          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. [48/25]
    Open

      describe '#new_quiz' do
        context 'when an assignment requires quiz' do
          before(:each) do
            @params = {aid: 1,
                       model: 'QuizQuestionnaire',

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

          it 'updates all quiz questions and redirects to submitted_content#view page' do
            params = {id: 1,
                      pid: 1,
                      save: true,
                      questionnaire: {name: 'test questionnaire',

    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

      describe '#valid_quiz' do
        before(:each) do
          allow(Assignment).to receive_message_chain(:find, :num_quiz_questions).with('1').with(no_args).and_return(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. [39/25]
    Open

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

        context 'when an assignment requires quiz' do
          before(:each) do
            @params = {aid: 1,
                       model: 'QuizQuestionnaire',
                       pid: 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. [29/25]
    Open

      describe '#update' do
        before(:each) do
          @questionnaire1 = double('Questionnaire', id: 1)
          allow(Questionnaire).to receive(:find).with('1').and_return(@questionnaire1)
          @params = {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. [26/25]
    Open

      describe '#save_all_questions' do
        context 'when params[:save] is not nil, params[:view_advice] is nil' do
          it 'redirects to questionnaires#edit page after saving all questions' do
            allow(Question).to receive(:find).with('1').and_return(question)
            allow(question).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.

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

        context 'when @questionnaire is not nil' do
          it 'renders the questionnaires#edit page' do
            allow(Questionnaire).to receive(:find).with('1').and_return(double('Questionnaire', instructor_id: 6))
            session = {user: instructor}
            params = {id: 1}
    Severity: Minor
    Found in spec/controllers/questionnaires_controller_spec.rb and 1 other location - About 40 mins to fix
    spec/controllers/course_controller_spec.rb on lines 29..35

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

    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

                                             '3' => {MultipleChoiceCheckbox: {'1' => {iscorrect: '1', txt: 'a31'},
                                                                              '2' => {iscorrect: '0', txt: 'a32'},
                                                                              '3' => {iscorrect: '1', txt: 'a33'},
                                                                              '4' => {iscorrect: '0', txt: 'a34'}}}},
    Severity: Minor
    Found in spec/controllers/questionnaires_controller_spec.rb and 1 other location - About 20 mins to fix
    spec/controllers/questionnaires_controller_spec.rb on lines 530..534

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

    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

                                              '3' => {MultipleChoiceCheckbox:
                                                          {'1' => {iscorrect: '1', txt: 'a31'},
                                                           '2' => {iscorrect: '0', txt: 'a32'},
                                                           '3' => {iscorrect: '1', txt: 'a33'},
                                                           '4' => {iscorrect: '0', txt: 'a34'}}}}}
    Severity: Minor
    Found in spec/controllers/questionnaires_controller_spec.rb and 1 other location - About 20 mins to fix
    spec/controllers/questionnaires_controller_spec.rb on lines 614..617

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

    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

    There are no issues that match your filters.

    Category
    Status