ece517-p3/expertiza

View on GitHub

Showing 2,813 of 2,813 total issues

Perceived complexity for hash_rows_with_headers is too high. [19/7]
Open

  def hash_rows_with_headers(header, body)
    new_body = []
    if params[:model] == "User" or params[:model] == "AssignmentParticipant" or params[:model] == "CourseParticipant" or params[:model] == "SignUpTopic"
      # header.map! { |column_name| column_name.to_sym }
      header.map!(&:to_sym)

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 impersonate is too high. [19/7]
Open

  def impersonate
    if params[:user]
      message = "No user exists with the name '#{params[:user][:name]}'."
    elsif params[:impersonate]
      message = "No user exists with the name '#{params[:impersonate][:name]}'."

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

Assignment Branch Condition size for show_team is too high. [27.09/15]
Open

  def show_team
    if !(assignment = Assignment.find(params[:assignment_id])).nil? and !(topic = SignUpTopic.find(params[:id])).nil?
      @results = ad_info(assignment.id, topic.id)
      @results.each do |result|
        result.keys.each do |key|

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 deploy_survey is too high. [27.17/15]
Open

def deploy_survey(start_date, end_date, survey_name)
  login_as('instructor6')
  expect(page).to have_content('Manage content')
  create_assignment_questionnaire survey_name
  survey = Questionnaire.where(name: survey_name)
Severity: Minor
Found in spec/features/survey_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 deploy_course_survey is too high. [27.17/15]
Open

def deploy_course_survey(start_date, end_date, survey_name)
  login_as('instructor6')
  expect(page).to have_content('Manage content')
  create_course_questionnaire survey_name
  survey = Questionnaire.where(name: survey_name)
Severity: Minor
Found in spec/features/course_survey_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 deploy_assignment_survey is too high. [27.02/15]
Open

def deploy_assignment_survey(start_date, end_date, survey_name)
  login_as('instructor6')
  expect(page).to have_content('Manage content')
  create_assignment_questionnaire survey_name
  survey = Questionnaire.where(name: survey_name)

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

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

  let(:questionnaire) { Questionnaire.new min_question_score: 0, max_question_score: 5 }
  let(:scale) { Scale.new id: 1, type: "Scale", seq: 1.0, txt: "test txt", weight: 1, questionnaire: questionnaire }
  let(:answer) { Answer.new answer: 8 }

  describe "#edit" do
Severity: Major
Found in spec/models/scale_spec.rb and 1 other location - About 3 hrs to fix
spec/models/criterion_spec.rb on lines 2..30

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

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

  let(:questionnaire) { Questionnaire.new min_question_score: 0, max_question_score: 5 }
  let(:criterion) { Criterion.new id: 1, type: "Criterion", seq: 1.0, txt: "test txt", weight: 1, questionnaire: questionnaire }
  let(:answer) { Answer.new answer: 8 }

  describe "#edit" do
Severity: Major
Found in spec/models/criterion_spec.rb and 1 other location - About 3 hrs to fix
spec/models/scale_spec.rb on lines 2..30

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

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

    context 'when params has key :assignment_form' do
      before(:each) do
        assignment_questionnaire = double('AssignmentQuestionnaire')
        allow(AssignmentQuestionnaire).to receive(:new).with(any_args).and_return(assignment_questionnaire)
        allow(assignment_questionnaire).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.

File assignment_form_spec.rb has 291 lines of code (exceeds 250 allowed). Consider refactoring.
Open

describe AssignmentForm do
  let(:assignment) { build(:assignment, id: 1) }
  let(:due_date) { build(:assignment_due_date) }
  let(:assignment_form) { AssignmentForm.new }
  let(:user) { double('Instructor', timezonepref: 'Eastern Time (US & Canada)') }
Severity: Minor
Found in spec/models/assignment_form_spec.rb - About 3 hrs to fix

    Assignment Branch Condition size for view_completed_question is too high. [26.25/15]
    Open

      def view_completed_question(count, answer)
        if self.type == 'TextField' and self.break_before == true
          html = '<b>' + count.to_s + ". " + self.txt + "</b>"
          html += '&nbsp;&nbsp;&nbsp;&nbsp;'
          html += answer.comments.to_s
    Severity: Minor
    Found in app/models/text_field.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 complete is too high. [26.93/15]
    Open

      def complete(count, answer = nil)
        html = '<p style="width: 80%;"><label for="responses_' + count.to_s + '"">' + self.txt + '&nbsp;&nbsp;</label>'
        html += '<input id="responses_' + count.to_s + '_score" name="responses[' + count.to_s + '][score]" type="hidden" value="" style="min-width: 100px;">'
        html += '<select id="responses_' + count.to_s + '_comments" label=' + self.txt + ' name="responses[' + count.to_s + '][comment]">'
    
    
    Severity: Minor
    Found in app/models/dropdown.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 review_questionnaire_id is too high. [26.4/15]
    Open

      def review_questionnaire_id(round = nil)
        # Get the round it's in from the next duedates
        if round.nil?
          next_due_date = DueDate.get_next_due_date(self.id)
          round = next_due_date.try(:round)
    Severity: Minor
    Found in app/models/assignment.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_table_rows is too high. [26.57/15]
    Open

      def add_table_rows questionnaire_max, questions, answers, code, tag_prompt_deployments = nil, current_user = nil
        count = 0
        # loop through questions so the the questions are displayed in order based on seq (sequence number)
        questions.each do |question|
          count += 1 if !question.is_a? QuestionnaireHeader and question.break_before == true
    Severity: Minor
    Found in app/models/response.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 get_volume_of_review_comments is too high. [26.02/15]
    Open

      def self.get_volume_of_review_comments(assignment_id, reviewer_id)
        comments, counter,
            @comments_in_round1, @counter_in_round1,
            @comments_in_round2, @counter_in_round2,
            @comments_in_round3, @counter_in_round3 = Response.concatenate_all_review_comments(assignment_id, reviewer_id)
    Severity: Minor
    Found in app/models/response.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 significant_difference? is too high. [26.94/15]
    Open

      def significant_difference?
        map_class = self.map.class
        existing_responses = map_class.get_assessments_for(self.map.reviewee)
        average_score_on_same_artifact_from_others, count = Response.avg_scores_and_count_for_prev_reviews(existing_responses, self)
        # if this response is the first on this artifact, there's no grade conflict
    Severity: Minor
    Found in app/models/response.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 calculate_penalty is too high. [26.8/15]
    Open

      def calculate_penalty(participant_id)
        @submission_deadline_type_id = 1
        @review_deadline_type_id = 2
        @meta_review_deadline_type_id = 5
    
    
    Severity: Minor
    Found in app/helpers/penalty_helper.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 view_heatgrid is too high. [26.17/15]
    Open

      def view_heatgrid(participant_id, type)
        # get participant, team, questionnaires for assignment.
        @participant = AssignmentParticipant.find(participant_id)
        @assignment = @participant.assignment
        @team = @participant.team
    Severity: Minor
    Found in app/helpers/grades_helper.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 update is too high. [26.5/15]
    Open

      def update
        @team = Team.find(params[:id])
        parent = Object.const_get(session[:team_type]).find(@team.parent_id)
        begin
          Team.check_for_existing(parent, params[:team][:name], session[:team_type])
    Severity: Minor
    Found in app/controllers/teams_controller.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 create is too high. [26.85/15]
    Open

      def create
        if params[:assignment_id].nil?
          flash[:error] = "Missing assignment:" + params[:assignment_id]
          return
        end

    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

    Severity
    Category
    Status
    Source
    Language