ece517-p3/expertiza

View on GitHub

Showing 2,813 of 2,813 total issues

Method compute_scores has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

  def self.compute_scores(assessments, questions)
    scores = {}
    if assessments.present?
      scores[:max] = -999_999_999
      scores[:min] = 999_999_999
Severity: Minor
Found in app/models/answer.rb - About 2 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

Method summarize_reviews_by_criterion has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    def summarize_reviews_by_criterion(assignment, summary_ws_url)
      # @summary[reviewee][round][question]
      # @avg_score_round[reviewee][round]
      # @avg_scores_by_criterion[reviewee][round][criterion]
      nround = assignment.rounds_of_reviews
Severity: Minor
Found in app/helpers/summary_helper.rb - About 2 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

Method add_table_rows has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
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 - About 2 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

Method create has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

  def create
    user = User.find_by(name: params[:user][:name].strip)
    unless user
      urlCreate = url_for controller: 'users', action: 'new'
      flash[:error] = "\"#{params[:user][:name].strip}\" is not defined. Please <a href=\"#{urlCreate}\">create</a> this user before continuing."
Severity: Minor
Found in app/controllers/teams_users_controller.rb - About 2 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

Method save_topic_deadlines has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

  def save_topic_deadlines
    assignment = Assignment.find(params[:assignment_id])
    @assignment_submission_due_dates = assignment.due_dates.select {|due_date| due_date.deadline_type_id == 1 }
    @assignment_review_due_dates = assignment.due_dates.select {|due_date| due_date.deadline_type_id == 2 }
    due_dates = params[:due_date]
Severity: Minor
Found in app/controllers/sign_up_sheet_controller.rb - About 2 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. [46/25]
Open

  describe 'one student who has a topic sends an invitation to other student who also has a topic' do
    before(:each) do
      user = User.find_by(name: "student2064")
      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.

Function showConfirmDialogSpecial has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

$.rails.showConfirmDialogSpecial = function(link) {
  var message = link.attr('data-confirm');
  var html1 = "<div class=\"modal\" id=\"dialog-confirm1\" title=\"Delete This User?\">\n  <div class=\"modal-body\">\n    <p>" + message + "</p>\n";

  var html2 = "<div class=\"modal\" id=\"dialog-confirm2\" title=\"System Information\">\n  <div class=\"modal-body\">\n    <p>This user cannot be deleted. Do you want to rename the user account to <b>" + link.attr('data-username') + "_hidden</b>?</p>\n"; 
Severity: Major
Found in app/assets/javascripts/userDeleteConfirmBox.js - About 2 hrs to fix

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

      before(:each) do
        # create assignment and topic
        create(:assignment, name: "TestAssignment", directory_path: "TestAssignment")
        create_list(:participant, 3)
        create(:topic, topic_name: "TestTopic")
    Severity: Major
    Found in spec/features/review_assignment_spec.rb and 1 other location - About 2 hrs to fix
    spec/features/assignment_submission_spec.rb on lines 2..16

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

    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

      before(:each) do
        # create assignment and topic
        create(:assignment, name: "Assignment1684", directory_path: "Assignment1684")
        create_list(:participant, 3)
        create(:topic, topic_name: "Topic")
    Severity: Major
    Found in spec/features/assignment_submission_spec.rb and 1 other location - About 2 hrs to fix
    spec/features/review_assignment_spec.rb on lines 2..16

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

    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

    Perceived complexity for update_tag_prompt_deployments is too high. [10/7]
    Open

      def update_tag_prompt_deployments(attributes)
        unless attributes.nil?
          attributes.each do |key, value|
            TagPromptDeployment.where(id: value['deleted']).delete_all if value.key?('deleted')
            # assume if tag_prompt is there, then id, question_type, answer_length_threshold must also be there since the inputs are coupled
    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

    Cyclomatic complexity for update_tag_prompt_deployments is too high. [9/6]
    Open

      def update_tag_prompt_deployments(attributes)
        unless attributes.nil?
          attributes.each do |key, value|
            TagPromptDeployment.where(id: value['deleted']).delete_all if value.key?('deleted')
            # assume if tag_prompt is there, then id, question_type, answer_length_threshold must also be there since the inputs are coupled
    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.

    Cyclomatic complexity for html_control is too high. [9/6]
    Open

      def html_control(tag_prompt_deployment, answer, user_id)
        html = ""
        unless answer.nil?
          stored_tags = AnswerTag.where(tag_prompt_deployment_id: tag_prompt_deployment.id, answer_id: answer.id, user_id: user_id)
    
    
    Severity: Minor
    Found in app/models/tag_prompt.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 scores is too high. [18.97/15]
    Open

      def scores(questions)
        scores = {}
        scores[:team] = self # This doesn't appear to be used anywhere
        assignment.questionnaires.each do |questionnaire|
          scores[questionnaire.symbol] = {}
    Severity: Minor
    Found in app/models/assignment_team.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 candidate_topics_to_review is too high. [18.47/15]
    Open

      def candidate_topics_to_review(reviewer)
        return nil if sign_up_topics.empty? # This is not a topic assignment
    
        # Initialize contributor set with all teams participating in this assignment
        contributor_set = Array.new(contributors)
    Severity: Minor
    Found in app/models/review_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

    Perceived complexity for compute_scores is too high. [10/7]
    Open

      def self.compute_scores(assessments, questions)
        scores = {}
        if assessments.present?
          scores[:max] = -999_999_999
          scores[:min] = 999_999_999
    Severity: Minor
    Found in app/models/answer.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

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

      def email(defn, participant, assignment)
        defn[:body][:type] = "Author Feedback"
        # reviewee is a response, reviewer is a participant
        # we need to track back to find the original reviewer on whose work the author comments
        response_id_for_original_feedback = reviewed_object_id
    Severity: Minor
    Found in app/models/feedback_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 feedback_response_report is too high. [10/7]
    Open

      def self.feedback_response_report(id, _type)
        # Example query
        # SELECT distinct reviewer_id FROM response_maps where type = 'FeedbackResponseMap' and
        # reviewed_object_id in (select id from responses where
        # map_id in (select id from response_maps where reviewed_object_id = 722 and type = 'ReviewResponseMap'))
    Severity: Minor
    Found in app/models/feedback_response_map.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

    Assignment Branch Condition size for add_participant is too high. [18.22/15]
    Open

      def add_participant(user_name)
        user = User.find_by(name: user_name)
        if user.nil?
          raise "No user account exists with the name " + user_name + ". Please <a href='" + url_for(controller: 'users', action: 'new') + "'>create</a> the user first."
        end
    Severity: Minor
    Found in app/models/course.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 actions_allowed is too high. [10/7]
    Open

      def self.actions_allowed(permission_ids)
        # Hash for faster & easier lookups
        if permission_ids
          perms = {}
          for id in permission_ids do
    Severity: Minor
    Found in app/models/controller_action.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

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

      def initialize(questionnaire, assignment = nil, round = nil)
        @assignment = assignment
        @questionnaire = questionnaire
        if questionnaire.type == "ReviewQuestionnaire"
          @round = round ? round : AssignmentQuestionnaire.find_by(assignment_id: @assignment.id, questionnaire_id: questionnaire.id).used_in_round
    Severity: Minor
    Found in app/models/vm_question_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

    Severity
    Category
    Status
    Source
    Language