ece517-p3/expertiza

View on GitHub

Showing 2,813 of 2,813 total issues

Assignment Branch Condition size for create_topic_deadline is too high. [15.26/15]
Open

  def create_topic_deadline(due_date, offset, topic_id)
    topic_deadline = TopicDueDate.new
    topic_deadline.parent_id = topic_id
    topic_deadline.due_at = Time.zone.parse(due_date.due_at.to_s) + offset.to_i
    topic_deadline.deadline_type_id = due_date.deadline_type_id
Severity: Minor
Found in app/helpers/deadline_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 submit is too high. [15.3/15]
Open

  def submit
    if !params[:add_comment].nil?
      add_comment
    elsif !params[:approve_suggestion].nil?
      approve_suggestion

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 delete_questions is too high. [15.81/15]
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|

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

  def index
    if params.key?(:response_id)
      join_query = sanitize_sql_array(["LEFT JOIN answers ON answers.question_id = questions.id AND answers.response_id = '?'", params[:response_id]])
    end
    where_query = sanitize_sql_array(["questions.questionnaire_id = '?'", params[:questionnaire_id]]) if params.key?(:questionnaire_id)

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

  def delete_all
    assignment = Assignment.find(params[:assignment_id])
    if assignment.nil?
      flash[:error] = "Assignment #" + assignment.id + " does not currently exist."
      return

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. [15.33/15]
Open

  def update
    @role = Role.find(params[:id])

    if @role.update_with_params(params[:role])
      Role.rebuild_cache
Severity: Minor
Found in app/controllers/roles_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 set_content is too high. [15.39/15]
Open

  def set_content(new_response = false)
    @title = @map.get_title
    if @map.survey?
      @survey_parent = @map.survey_parent
    else

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 action_allowed? is too high. [15.3/15]
Open

  def action_allowed?
    case params[:action]
    when 'list', 'new', 'create', 'bookmark_rating', 'save_bookmark_rating_score'
      current_role_name.eql? 'Student'
    when 'edit', 'update', 'destroy'

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

  def self.take_quiz assignment_id, reviewer_id
    quizzes = []
    reviewer = Participant.where(user_id: reviewer_id, parent_id: assignment_id).first
    reviewed_team_response_maps = ReviewResponseMap.where(reviewer_id: reviewer.id)
    reviewed_team_response_maps.each do |team_response_map_record|

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

  def after_login(user)
    session[:user] = user
    session[:impersonate] = false
    ExpertizaLogger.info LoggerMessage.new("", user.name, 'Login successful')
    AuthController.set_current_role(user.role_id, session)
Severity: Minor
Found in app/controllers/auth_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 set_current_role is too high. [15.81/15]
Open

  def self.set_current_role(role_id, session)
    return unless role_id
    role = Role.find role_id
    if role
      Role.rebuild_cache if !role.cache || !role.cache.try(:has_key?, :credentials)
Severity: Minor
Found in app/controllers/auth_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 sign_up is too high. [15.33/15]
Open

  def sign_up
    @assignment = AssignmentParticipant.find(params[:id]).assignment
    @user_id = session[:user].id
    # Always use team_id ACS
    # s = Signupsheet.new

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

describe TagPrompt do
  let(:ct_criterion) { Criterion.new id: 1, type: "Criterion", seq: 1.0, txt: "test txt", weight: 1 }
  let(:ct_cbox) { Criterion.new id: 1, type: "Checkbox", seq: 1.0, txt: "test txt", weight: 1 }
  let(:ct_text) { Criterion.new id: 1, type: "Text", seq: 1.0, txt: "test txt", weight: 1 }
  let(:an_long) { Answer.new question: ct_criterion, answer: 5, comments: "test comments" }
Severity: Minor
Found in spec/models/tag_prompt_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. [41/25]
Open

  describe ".import" do
    context 'when record is empty' do
      it 'raises an ArgumentError' do
        expect { AssignmentParticipant.import({}, nil, nil, nil) }.to raise_error(ArgumentError, 'No user id has been specified.')
      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.

Method get_questions_from_csv has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def self.get_questions_from_csv(questionnaire, file)
    questions = []
    custom_rubric = questionnaire.section == "Custom"

    CSV::Reader.parse(file) do |row|
Severity: Minor
Found in app/helpers/questionnaire_helper.rb - About 1 hr to fix

    Method display_directory_tree has 41 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def display_directory_tree(participant, files, display_to_reviewer_flag)
        index = 0
        participant = @participant if @participant # TODO: Verify why this is needed
        assignment = participant.assignment # participant is @map.contributor
        topic_id = SignedUpTeam.topic_id(participant.parent_id, participant.user_id) # participant is @map.reviewer
    Severity: Minor
    Found in app/helpers/submitted_content_helper.rb - About 1 hr to fix

      Method automatic_review_mapping has 41 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def automatic_review_mapping
          assignment_id = params[:id].to_i
          participants = AssignmentParticipant.where(parent_id: params[:id].to_i).to_a.select(&:can_review).shuffle!
          teams = AssignmentTeam.where(parent_id: params[:id].to_i).to_a.shuffle!
          max_team_size = Integer(params[:max_team_size]) # Assignment.find(assignment_id).max_team_size
      Severity: Minor
      Found in app/controllers/review_mapping_controller.rb - About 1 hr to fix

        Method calculate_score has 40 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def calculate_score(map, response)
            questionnaire = Questionnaire.find(map.reviewed_object_id)
            scores = []
            valid = true
            questions = Question.where(questionnaire_id: questionnaire.id)
        Severity: Minor
        Found in app/controllers/student_quizzes_controller.rb - About 1 hr to fix

          Method complete has a Cognitive Complexity of 13 (exceeds 5 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

          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_answer has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

            def add_answer(answer)
              # We want to add each response score from this review (answer) to its corresponding
              # question row.
              @list_of_rows.each do |row|
                next unless row.question_id == answer.question_id
          Severity: Minor
          Found in app/models/vm_question_response.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