ece517-p3/expertiza

View on GitHub

Showing 2,813 of 2,813 total issues

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

    questions.each do |question|
      q_type = params[:question_type][question_num.to_s][:type]
      params[:new_choices][question_num.to_s][q_type].keys.each do |choice_key|
        score = if params[:new_choices][question_num.to_s][q_type][choice_key]["weight"] == 1.to_s
                  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. [37/25]
Open

    context 'when the reviewers of current reviewer (ap) includes current assignment participant' do
      # This before each function is used to extract out re-appearing code used in two_node_cycle tests
      # More specifically, it is used to extract out the common code used to
      # create a relationship between two revewing participants
      before(:each) do
Severity: Minor
Found in spec/models/collusion_cycle_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.

Function render has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    render: function() {
      var colSpan = "5"
      var colDisplayStyle = {
        "display": ""
      }
Severity: Minor
Found in app/assets/javascripts/tree_display.jsx - About 1 hr to fix

    Method course_student_grade_summary has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def course_student_grade_summary
        @topics = {}
        @assignment_grades = {}
        @peer_review_scores = {}
        @final_grades = {}
    Severity: Minor
    Found in app/controllers/assessment360_controller.rb - About 1 hr to fix

      Method create has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def create
          @assignment_form = AssignmentForm.new(assignment_form_params)
          if params[:button]
            if @assignment_form.save
              @assignment_form.create_assignment_node
      Severity: Minor
      Found in app/controllers/assignments_controller.rb - About 1 hr to fix

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

          describe '#reviews_visible_to_all' do
            context 'when current assignment.reviews_visible_to_all is nil' do
              it 'sets reviews_visible_to_all attribute of current assignment to false' do
                assignment.reviews_visible_to_all = nil
                expect(assignment_form.reviews_visible_to_all).to be false
        Severity: Major
        Found in spec/models/assignment_form_spec.rb and 3 other locations - About 1 hr to fix
        spec/models/assignment_form_spec.rb on lines 203..216
        spec/models/assignment_form_spec.rb on lines 221..234
        spec/models/assignment_form_spec.rb on lines 239..252

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

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

          describe '#availability_flag' do
            context 'when current assignment.availability_flag is nil' do
              it 'sets availability_flag attribute of current assignment to false' do
                assignment.availability_flag = nil
                expect(assignment_form.availability_flag).to be false
        Severity: Major
        Found in spec/models/assignment_form_spec.rb and 3 other locations - About 1 hr to fix
        spec/models/assignment_form_spec.rb on lines 203..216
        spec/models/assignment_form_spec.rb on lines 239..252
        spec/models/assignment_form_spec.rb on lines 257..270

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

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

          describe '#staggered_deadline' do
            context 'when current assignment.staggered_deadlines is nil' do
              it 'sets staggered_deadline attribute of current assignment to false' do
                assignment.staggered_deadline = nil
                expect(assignment_form.staggered_deadline).to be false
        Severity: Major
        Found in spec/models/assignment_form_spec.rb and 3 other locations - About 1 hr to fix
        spec/models/assignment_form_spec.rb on lines 221..234
        spec/models/assignment_form_spec.rb on lines 239..252
        spec/models/assignment_form_spec.rb on lines 257..270

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

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

          describe '#micro_task' do
            context 'when current assignment.microtask is nil' do
              it 'sets microtask attribute of current assignment to false' do
                assignment.microtask = nil
                expect(assignment_form.micro_task).to be false
        Severity: Major
        Found in spec/models/assignment_form_spec.rb and 3 other locations - About 1 hr to fix
        spec/models/assignment_form_spec.rb on lines 203..216
        spec/models/assignment_form_spec.rb on lines 221..234
        spec/models/assignment_form_spec.rb on lines 257..270

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

        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

        Function Yes has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                "Yes": function() {
                  //return $.rails.confirmed(link);
                  $( this ).dialog( "close" );
                  $(html2).modal();
                  $("#dialog-confirm2").dialog({
        Severity: Minor
        Found in app/assets/javascripts/userDeleteConfirmBox.js - About 1 hr to fix

          Method complete has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def complete(count, answer = nil, questionnaire_min, questionnaire_max)
              html = '<div><label for="responses_' + count.to_s + '">' + self.txt + '</label></div>'
              html += '<input id="responses_' + count.to_s + '_score" name="responses[' + count.to_s + '][score]" type="hidden"'
              html += 'value="' + answer.answer.to_s + '"' unless answer.nil?
              html += '>'
          Severity: Minor
          Found in app/models/scale.rb - About 1 hr to fix

            Method assign_reviewers_for_team has 32 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def assign_reviewers_for_team(assignment_id, review_strategy, participants_hash)
                if ReviewResponseMap.where(reviewed_object_id: assignment_id, calibrate_to: 0)
                                    .where("created_at > :time",
                                           time: @@time_create_last_review_mapping_record).size < review_strategy.reviews_needed
            
            
            Severity: Minor
            Found in app/controllers/review_mapping_controller.rb - About 1 hr to fix

              Method match_new_teams_to_topics has 32 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def match_new_teams_to_topics(assignment)
                  unless assignment.is_intelligent
                    flash[:error] = "This action is not allowed. The assignment #{assignment.name} does not enable intelligent assignments."
                    return
                  end
              Severity: Minor
              Found in app/controllers/lottery_controller.rb - About 1 hr to fix

                Method create has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def create
                    map_id = params[:id]
                    map_id = params[:map_id] unless params[:map_id].nil? # pass map_id as a hidden field in the review form
                    @map = ResponseMap.find(map_id)
                    if params[:review][:questionnaire_id]
                Severity: Minor
                Found in app/controllers/response_controller.rb - About 1 hr to fix

                  Method import has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def self.import(row_hash, session, id)
                      raise ArgumentError.new("Not enough items. The string should contain: Author, Reviewer, ReviewOfReviewer1 <, ..., ReviewerOfReviewerN>") if row_hash.length < 3
                      row_hash[:metareviewers].each do |row|
                        # ACS Make All contributors as teams
                        contributor = AssignmentTeam.where(name: row_hash[:reviewee].to_s, parent_id:  id).first
                  Severity: Minor
                  Found in app/models/metareview_response_map.rb - About 1 hr to fix

                  Cognitive Complexity

                  Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                  A method's cognitive complexity is based on a few simple rules:

                  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                  • Code is considered more complex for each "break in the linear flow of the code"
                  • Code is considered more complex when "flow breaking structures are nested"

                  Further reading

                  Method add_to_delayed_queue has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def add_to_delayed_queue
                      duedates = AssignmentDueDate.where(parent_id: @assignment.id)
                      duedates.each do |due_date|
                        deadline_type = DeadlineType.find(due_date.deadline_type_id).name
                        diff_btw_time_left_and_threshold, min_left = get_time_diff_btw_due_date_and_now(due_date)
                  Severity: Minor
                  Found in app/models/assignment_form.rb - About 1 hr to fix

                  Cognitive Complexity

                  Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                  A method's cognitive complexity is based on a few simple rules:

                  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                  • Code is considered more complex for each "break in the linear flow of the code"
                  • Code is considered more complex when "flow breaking structures are nested"

                  Further reading

                  Function checkDeadlines has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function checkDeadlines()
                  {
                  
                    var dates = new Array();
                    var inputs = document.getElementsByTagName('input');
                  Severity: Minor
                  Found in app/assets/javascripts/application.js - About 1 hr to fix

                  Cognitive Complexity

                  Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                  A method's cognitive complexity is based on a few simple rules:

                  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                  • Code is considered more complex for each "break in the linear flow of the code"
                  • Code is considered more complex when "flow breaking structures are nested"

                  Further reading

                  Method get_total_score has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def self.get_total_score(params)
                      @response = params[:response].last
                      if @response
                        @questions = params[:questions]
                  
                  
                  Severity: Minor
                  Found in app/models/answer.rb - About 1 hr to fix

                  Cognitive Complexity

                  Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                  A method's cognitive complexity is based on a few simple rules:

                  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                  • Code is considered more complex for each "break in the linear flow of the code"
                  • Code is considered more complex when "flow breaking structures are nested"

                  Further reading

                  Method delete_questions has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def delete_questions(questionnaire_id)
                      # Deletes any questions that, as a result of the edit, are no longer in the questionnaire
                      questions = Question.where("questionnaire_id = ?", questionnaire_id)
                      @deleted_questions = []
                      questions.each do |question|
                  Severity: Minor
                  Found in app/controllers/questionnaires_controller.rb - About 1 hr to fix

                  Cognitive Complexity

                  Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                  A method's cognitive complexity is based on a few simple rules:

                  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                  • Code is considered more complex for each "break in the linear flow of the code"
                  • Code is considered more complex when "flow breaking structures are nested"

                  Further reading

                  Method get_questions_by_assignment has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def get_questions_by_assignment(assignment)
                        rubric = []
                        (0..assignment.rounds_of_reviews - 1).each do |round|
                          rubric[round] = nil
                          if assignment.varying_rubrics_by_round?
                  Severity: Minor
                  Found in app/helpers/summary_helper.rb - About 1 hr to fix

                  Cognitive Complexity

                  Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                  A method's cognitive complexity is based on a few simple rules:

                  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                  • Code is considered more complex for each "break in the linear flow of the code"
                  • Code is considered more complex when "flow breaking structures are nested"

                  Further reading

                  Severity
                  Category
                  Status
                  Source
                  Language