ece517-p3/expertiza

View on GitHub

Showing 2,813 of 2,813 total issues

Perceived complexity for peer_review_strategy is too high. [21/7]
Open

  def peer_review_strategy(assignment_id, review_strategy, participants_hash)
    teams = review_strategy.teams
    participants = review_strategy.participants
    num_participants = participants.size

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

  def create
    # Flash an error if neither an action nor a page has been selected
    if params[:menu_item][:controller_action_id].blank? and
        params[:menu_item][:content_page_id].blank?
      flash[:error] = "You must specify either an action or a page!"

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

  def populate_hash_for_all_students_all_reviews(assignment,
                                                 course_participant,
                                                 reviews,
                                                 hash_per_stu,
                                                 overall_review_grade_hash,

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

  def pending_surveys
    unless session[:user] # Check for a valid user
      redirect_to '/'
      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

Assignment Branch Condition size for edit is too high. [29.58/15]
Open

  def edit
    ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].name, "Timezone not specified", request) if current_user.timezonepref.nil?
    flash.now[:error] = "You have not specified your preferred timezone yet. Please do this before you set up the deadlines." if current_user.timezonepref.nil?
    edit_params_setting
    assignment_form_assignment_staggered_deadline?

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

  def handle_rubrics_not_assigned_case
    if !empty_rubrics_list.empty? && request.original_fullpath == "/assignments/#{@assignment_form.assignment.id}/edit"
      rubrics_needed = needed_rubrics(empty_rubrics_list)
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].name, "Rubrics missing for #{@assignment_form.assignment.name}.", request)
      if flash.now[:error] != "Failed to save the assignment: [\"Total weight of rubrics should add up to either 0 or 100%\"]"

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

  def update
    participant = AssignmentParticipant.find(params[:id])
    total_score = params[:total_score]
    if format("%.2f", total_score) != params[:participant][:grade]
      # participant.update_attribute(:grade, params[:participant][:grade])

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

  def view_my_scores
    @participant = AssignmentParticipant.find(params[:id])
    @team_id = TeamsUser.team_id(@participant.parent_id, @participant.user_id)
    return if redirect_when_disallowed
    @assignment = @participant.assignment

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

  def create
    invalid_penalty_per_unit = params[:late_policy][:max_penalty].to_i < params[:late_policy][:penalty_per_unit].to_i
    flash[:error] = "The maximum penalty cannot be less than penalty per unit." if invalid_penalty_per_unit
    same_policy_name = false
    if same_policy_name != LatePolicy.check_policy_with_same_name(params[:late_policy][:policy_name], instructor_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

File response_controller_spec.rb has 304 lines of code (exceeds 250 allowed). Consider refactoring.
Open

describe ResponseController do
  let(:assignment) { build(:assignment, instructor_id: 6) }
  let(:instructor) { build(:instructor, id: 6) }
  let(:participant) { build(:participant, id: 1, user_id: 6, assignment: assignment) }
  let(:review_response) { build(:response, id: 1, map_id: 1) }
Severity: Minor
Found in spec/controllers/response_controller_spec.rb - About 3 hrs to fix

    Method all_students_all_reviews has a Cognitive Complexity of 23 (exceeds 5 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 3 hrs 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

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

      describe '.items_for_permissions' do
        context 'when inputted variable (permission_ids) is nil' do
          context 'when the controller_action_id of current item is bigger than 0' do
            context 'when perms does not exist' do
              it 'returns corresponding items' do
    Severity: Minor
    Found in spec/models/menu_item_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. [60/25]
    Open

      describe '#action_allowed?' do
        context 'when params action is edit or update' do
          before(:each) do
            controller.params = {id: '1', action: 'edit'}
          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.

    Assignment Branch Condition size for complete is too high. [28.86/15]
    Open

      def complete
        quiz_question_choices = QuizQuestionChoice.where(question_id: self.id)
        html = "<label for=\"" + self.id.to_s + "\">" + self.txt + "</label><br>"
        for i in 0..3
          txt = quiz_question_choices[i].txt
    Severity: Minor
    Found in app/models/multiple_choice_radio.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 is too high. [28.72/15]
    Open

      def self.get(sortvar = nil, sortorder = nil, user_id = nil, show = nil, parent_id = nil, _search = nil)
        conditions = if show
                       if User.find(user_id).role.name != "Teaching Assistant"
                         'questionnaires.instructor_id = ?'
                       else
    Severity: Minor
    Found in app/models/questionnaire_node.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. [28.86/15]
    Open

      def complete
        quiz_question_choices = QuizQuestionChoice.where(question_id: self.id)
        html = "<label for=\"" + self.id.to_s + "\">" + self.txt + "</label><br>"
        for i in 0..3
          txt = quiz_question_choices[i].txt

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

      def delete_all_metareviewers
        mapping = ResponseMap.find(params[:id])
        mmappings = MetareviewResponseMap.where(reviewed_object_id: mapping.map_id)
        num_unsuccessful_deletes = 0
        mmappings.each do |mmapping|

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

      def show_selection
        @user = User.find_by(name: params[:user][:name])
        if !@user.nil?
          get_role
          if @role.parent_id.nil? || @role.parent_id < session[:user].role_id || @user.id == session[:user].id
    Severity: Minor
    Found in app/controllers/users_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 generate_statistics is too high. [28.81/15]
    Open

      def generate_statistics
        @sd = SurveyDeployment.find(params[:id])
        questionnaire = if params[:global_survey] == 'true'
                          Questionnaire.find(@sd.global_survey_id)
                        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 new_feedback is too high. [28.44/15]
    Open

      def new_feedback
        review = Response.find(params[:id]) unless params[:id].nil?
        if review
          reviewer = AssignmentParticipant.where(user_id: session[:user].id, parent_id: review.map.assignment.id).first
          map = FeedbackResponseMap.where(reviewed_object_id: review.id, reviewer_id: reviewer.id).first

    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