ece517-p3/expertiza

View on GitHub

Showing 2,813 of 2,813 total issues

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

  describe '#cycle_similarity_score' do
    context 'when collusion cycle has been calculated, verify the similarity score' do
      it 'returns similarity score based on inputted 2 node cycle' do
        c = [[participant1, 90], [participant2, 70]]
        expect(cycle.cycle_similarity_score(c)).to eql(20.0)
Severity: Major
Found in spec/models/collusion_cycle_spec.rb and 1 other location - About 1 hr to fix
spec/models/collusion_cycle_spec.rb on lines 397..409

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

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

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

  describe '.add_signup_topic' do
    it 'will return an empty Hash when there are no topics' do
      assignment = double('Assignment')
      allow(assignment).to receive(:num_review_rounds) { nil }
      allow(Assignment).to receive(:find) { assignment }
Severity: Minor
Found in spec/models/sign_up_sheet_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. [43/25]
Open

  describe 'one student should send an invitation to other student and both does not have topics' do
    before(:each) do
      user = User.find_by(name: "student2066")
      stub_current_user(user, user.role.name, user.role)
      visit '/student_task/list'
Severity: Minor
Found in spec/features/team_creation_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 add_reviews has 45 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def add_reviews(participant, team, vary)
    if @questionnaire_type == "ReviewQuestionnaire"
      reviews = if vary
                  ReviewResponseMap.get_responses_for_team_round(team, @round)
                else
Severity: Minor
Found in app/models/vm_question_response.rb - About 1 hr to fix

    Method all_students_all_reviews has 45 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def all_students_all_reviews
        course = Course.find(params[:course_id])
        @assignments = course.assignments.reject(&:is_calibrated).reject {|a| a.participants.empty? }
        @course_participants = course.get_participants
        if @course_participants.empty?
    Severity: Minor
    Found in app/controllers/assessment360_controller.rb - About 1 hr to fix

      Method associated_courses has 45 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def associated_courses(user)
          # NOTE: testing for roles in general is a bad practice but since the data base does not provide clear
          # way to get this association we have no other choice
          case user.role_id
            # admin and super admin should be able to see all courses
      Severity: Minor
      Found in app/helpers/course_helper.rb - About 1 hr to fix

        Method build_tone_analysis_report has 45 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def build_tone_analysis_report
            uri =  WEBSERVICE_CONFIG['sentiment_webservice_url'] + "analyze_reviews_bulk"
            index = 0
            @sentiment_summary = []
            keys = @review_final_versions.keys
        Severity: Minor
        Found in app/controllers/popup_controller.rb - About 1 hr to fix

          Perceived complexity for update_assignment_questionnaires is too high. [8/7]
          Open

            def update_assignment_questionnaires(attributes)
              return false unless attributes
              validate_assignment_questionnaires_weights(attributes)
              @errors = @assignment.errors
              unless @has_errors
          Severity: Minor
          Found in app/models/assignment_form.rb by rubocop

          This cop tries to produce a complexity score that's a measure of the complexity the reader experiences when looking at a method. For that reason it considers when nodes as something that doesn't add as much complexity as an if or a &&. Except if it's one of those special case/when constructs where there's no expression after case. Then the cop treats it as an if/elsif/elsif... and lets all the when nodes count. In contrast to the CyclomaticComplexity cop, this cop considers else nodes as adding complexity.

          Example:

          def my_method                   # 1
            if cond                       # 1
              case var                    # 2 (0.8 + 4 * 0.2, rounded)
              when 1 then func_one
              when 2 then func_two
              when 3 then func_three
              when 4..10 then func_other
              end
            else                          # 1
              do_something until a && b   # 2
            end                           # ===
          end                             # 7 complexity points

          Perceived complexity for assignment_tagging_progress is too high. [8/7]
          Open

            def assignment_tagging_progress
              teams = Team.where(parent_id: self.assignment_id)
              questions = Question.where(questionnaire_id: self.questionnaire.id, type: self.question_type)
              questions_ids = questions.map(&:id)
              user_answer_tagging = []
          Severity: Minor
          Found in app/models/tag_prompt_deployment.rb by rubocop

          This cop tries to produce a complexity score that's a measure of the complexity the reader experiences when looking at a method. For that reason it considers when nodes as something that doesn't add as much complexity as an if or a &&. Except if it's one of those special case/when constructs where there's no expression after case. Then the cop treats it as an if/elsif/elsif... and lets all the when nodes count. In contrast to the CyclomaticComplexity cop, this cop considers else nodes as adding complexity.

          Example:

          def my_method                   # 1
            if cond                       # 1
              case var                    # 2 (0.8 + 4 * 0.2, rounded)
              when 1 then func_one
              when 2 then func_two
              when 3 then func_three
              when 4..10 then func_other
              end
            else                          # 1
              do_something until a && b   # 2
            end                           # ===
          end                             # 7 complexity points

          Cyclomatic complexity for update_assignment_questionnaires is too high. [7/6]
          Open

            def update_assignment_questionnaires(attributes)
              return false unless attributes
              validate_assignment_questionnaires_weights(attributes)
              @errors = @assignment.errors
              unless @has_errors
          Severity: Minor
          Found in app/models/assignment_form.rb by rubocop

          This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

          An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

          Assignment Branch Condition size for initialize is too high. [16.82/15]
          Open

            def initialize(args = {})
              @assignment = Assignment.new(args[:assignment])
              if args[:assignment].nil?
                @assignment.course = Course.find(args[:parent_id]) if args[:parent_id]
                @assignment.instructor = @assignment.course.instructor if @assignment.course
          Severity: Minor
          Found in app/models/assignment_form.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 add_to_delayed_queue is too high. [16.64/15]
          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 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

          Cyclomatic complexity for import is too high. [7/6]
          Open

            def self.import(row_hash, _session, assignment_id)
              reviewee_user_name = row_hash[:reviewee].to_s
              reviewee_user = User.find_by(name: reviewee_user_name)
              raise ArgumentError, "Cannot find reviewee user." unless reviewee_user
              reviewee_participant = AssignmentParticipant.find_by(user_id: reviewee_user.id, parent_id: assignment_id)
          Severity: Minor
          Found in app/models/review_response_map.rb by rubocop

          This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

          An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

          Cyclomatic complexity for assignment_tagging_progress is too high. [7/6]
          Open

            def assignment_tagging_progress
              teams = Team.where(parent_id: self.assignment_id)
              questions = Question.where(questionnaire_id: self.questionnaire.id, type: self.question_type)
              questions_ids = questions.map(&:id)
              user_answer_tagging = []
          Severity: Minor
          Found in app/models/tag_prompt_deployment.rb by rubocop

          This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

          An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

          Assignment Branch Condition size for email is too high. [16.49/15]
          Open

            def email(defn, _participant, assignment)
              defn[:body][:type] = "Peer Review"
              AssignmentTeam.find(reviewee_id).users.each do |user|
                defn[:body][:obj_name] = assignment.name
                defn[:body][:first_name] = User.find(user.id).fullname
          Severity: Minor
          Found in app/models/review_response_map.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

          Perceived complexity for reassign_topic is too high. [8/7]
          Open

            def self.reassign_topic(session_user_id, assignment_id, topic_id)
              # find whether assignment is team assignment
              assignment = Assignment.find(assignment_id)
          
              # making sure that the drop date deadline hasn't passed
          Severity: Minor
          Found in app/models/sign_up_topic.rb by rubocop

          This cop tries to produce a complexity score that's a measure of the complexity the reader experiences when looking at a method. For that reason it considers when nodes as something that doesn't add as much complexity as an if or a &&. Except if it's one of those special case/when constructs where there's no expression after case. Then the cop treats it as an if/elsif/elsif... and lets all the when nodes count. In contrast to the CyclomaticComplexity cop, this cop considers else nodes as adding complexity.

          Example:

          def my_method                   # 1
            if cond                       # 1
              case var                    # 2 (0.8 + 4 * 0.2, rounded)
              when 1 then func_one
              when 2 then func_two
              when 3 then func_three
              when 4..10 then func_other
              end
            else                          # 1
              do_something until a && b   # 2
            end                           # ===
          end                             # 7 complexity points

          Cyclomatic complexity for reassign_topic is too high. [7/6]
          Open

            def self.reassign_topic(session_user_id, assignment_id, topic_id)
              # find whether assignment is team assignment
              assignment = Assignment.find(assignment_id)
          
              # making sure that the drop date deadline hasn't passed
          Severity: Minor
          Found in app/models/sign_up_topic.rb by rubocop

          This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

          An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

          Cyclomatic complexity for isvalid is too high. [7/6]
          Open

            def isvalid(choice_info)
              valid = "valid"
              valid = "Please make sure all questions have text" if self.txt == ''
              correct_count = 0
              choice_info.each do |_idx, value|
          Severity: Minor
          Found in app/models/multiple_choice_radio.rb by rubocop

          This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

          An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

          Cyclomatic complexity for import is too high. [7/6]
          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

          This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

          An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

          Perceived complexity for get is too high. [8/7]
          Open

            def self.get(sortvar = nil, sortorder = nil, user_id = nil, show = nil, parent_id = nil, _search = nil)
              if show
                conditions = if User.find(user_id).role.name != "Teaching Assistant"
                               'assignments.instructor_id = ?'
                             else
          Severity: Minor
          Found in app/models/assignment_node.rb by rubocop

          This cop tries to produce a complexity score that's a measure of the complexity the reader experiences when looking at a method. For that reason it considers when nodes as something that doesn't add as much complexity as an if or a &&. Except if it's one of those special case/when constructs where there's no expression after case. Then the cop treats it as an if/elsif/elsif... and lets all the when nodes count. In contrast to the CyclomaticComplexity cop, this cop considers else nodes as adding complexity.

          Example:

          def my_method                   # 1
            if cond                       # 1
              case var                    # 2 (0.8 + 4 * 0.2, rounded)
              when 1 then func_one
              when 2 then func_two
              when 3 then func_three
              when 4..10 then func_other
              end
            else                          # 1
              do_something until a && b   # 2
            end                           # ===
          end                             # 7 complexity points
          Severity
          Category
          Status
          Source
          Language