expertiza/expertiza

View on GitHub
app/models/assignment.rb

Summary

Maintainability
D
2 days
Test Coverage
F
42%

Class has too many lines. [489/100]
Open

class Assignment < ApplicationRecord
  require 'analytic/assignment_analytic'
  include Scoring
  include AssignmentAnalytic
  include ReviewAssignment
Severity: Minor
Found in app/models/assignment.rb by rubocop

This cop checks if the length a class exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

File assignment.rb has 491 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class Assignment < ApplicationRecord
  require 'analytic/assignment_analytic'
  include Scoring
  include AssignmentAnalytic
  include ReviewAssignment
Severity: Minor
Found in app/models/assignment.rb - About 7 hrs to fix

    Class Assignment has 54 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class Assignment < ApplicationRecord
      require 'analytic/assignment_analytic'
      include Scoring
      include AssignmentAnalytic
      include ReviewAssignment
    Severity: Major
    Found in app/models/assignment.rb - About 7 hrs to fix

      Assignment Branch Condition size for csv_row is too high. [56.05/15]
      Open

        def self.csv_row(detail_options, answer)
          teams_csv = []
          @response = Response.find(answer.response_id)
          map = ResponseMap.find(@response.map_id)
          @reviewee = Team.find_by id: map.reviewee_id
      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 response_map_to_metareview is too high. [43.58/15]
      Open

        def response_map_to_metareview(metareviewer)
          response_map_set = Array.new(review_mappings)
          # Reject response maps without responses
          response_map_set.reject! { |response_map| response_map.response.empty? }
          raise 'There are no reviews to metareview at this time for this assignment.' if response_map_set.empty?
      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 find_review_period is too high. [40.3/15]
      Open

        def find_review_period(round)
          # If round is nil, it means the same questionnaire is used for every round. Thus, we return all periods.
          # If round is not nil, we return only the period of that round.
      
          submission_type = DeadlineType.find_by(name: 'submission').id
      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 export_data is too high. [36.52/15]
      Open

        def self.export_data(csv, scores, options)
          @scores = scores
          (0..@scores[:teams].length - 1).each do |index|
            team = @scores[:teams][index.to_s.to_sym]
            first_participant = team[:team].participants[0] unless team[:team].participants[0].nil?
      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 delete is too high. [33.78/15]
      Open

        def delete(force = nil)
          begin
            maps = ReviewResponseMap.where(reviewed_object_id: id)
            maps.each { |map| map.delete(force) }
          rescue StandardError
      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 path is too high. [33.38/15]
      Open

        def path
          if course_id.nil? && instructor_id.nil?
            raise 'The path cannot be created. The assignment must be associated with either a course or an instructor.'
          end
      
      
      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

      Method has too many lines. [26/10]
      Open

        def delete(force = nil)
          begin
            maps = ReviewResponseMap.where(reviewed_object_id: id)
            maps.each { |map| map.delete(force) }
          rescue StandardError
      Severity: Minor
      Found in app/models/assignment.rb by rubocop

      This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

      Method has too many lines. [21/10]
      Open

        def self.export_details(csv, parent_id, detail_options)
          return csv unless detail_options.value?('true')
      
          @assignment = Assignment.find(parent_id)
          @answers = {} # Contains all answer objects for this assignment
      Severity: Minor
      Found in app/models/assignment.rb by rubocop

      This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

      Method has too many lines. [20/10]
      Open

        def find_review_period(round)
          # If round is nil, it means the same questionnaire is used for every round. Thus, we return all periods.
          # If round is not nil, we return only the period of that round.
      
          submission_type = DeadlineType.find_by(name: 'submission').id
      Severity: Minor
      Found in app/models/assignment.rb by rubocop

      This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

      Assignment Branch Condition size for export_details is too high. [23.49/15]
      Open

        def self.export_details(csv, parent_id, detail_options)
          return csv unless detail_options.value?('true')
      
          @assignment = Assignment.find(parent_id)
          @answers = {} # Contains all answer objects for this assignment
      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

      Method has too many lines. [18/10]
      Open

        def response_map_to_metareview(metareviewer)
          response_map_set = Array.new(review_mappings)
          # Reject response maps without responses
          response_map_set.reject! { |response_map| response_map.response.empty? }
          raise 'There are no reviews to metareview at this time for this assignment.' if response_map_set.empty?
      Severity: Minor
      Found in app/models/assignment.rb by rubocop

      This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

      Assignment Branch Condition size for review_questionnaire_id is too high. [22.76/15]
      Open

        def review_questionnaire_id(round_number = nil, topic_id = nil)
          # If round is not given, try to retrieve current round from the next due date
          if round_number.nil?
            next_due_date = DueDate.get_next_due_date(id)
            round_number = 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 export is too high. [22.67/15]
      Open

        def self.export(csv, parent_id, options)
          @assignment = Assignment.find(parent_id)
          @questions = {}
          questionnaires = @assignment.questionnaires
          questionnaires.each do |questionnaire|
      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

      Method has too many lines. [17/10]
      Open

        def self.export_data(csv, scores, options)
          @scores = scores
          (0..@scores[:teams].length - 1).each do |index|
            team = @scores[:teams][index.to_s.to_sym]
            first_participant = team[:team].participants[0] unless team[:team].participants[0].nil?
      Severity: Minor
      Found in app/models/assignment.rb by rubocop

      This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

      Method has too many lines. [15/10]
      Open

        def self.csv_row(detail_options, answer)
          teams_csv = []
          @response = Response.find(answer.response_id)
          map = ResponseMap.find(@response.map_id)
          @reviewee = Team.find_by id: map.reviewee_id
      Severity: Minor
      Found in app/models/assignment.rb by rubocop

      This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

      Method has too many lines. [15/10]
      Open

        def self.export(csv, parent_id, options)
          @assignment = Assignment.find(parent_id)
          @questions = {}
          questionnaires = @assignment.questionnaires
          questionnaires.each do |questionnaire|
      Severity: Minor
      Found in app/models/assignment.rb by rubocop

      This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

      Method has too many lines. [15/10]
      Open

        def self.export_data_fields(options, team, teams_csv, participants_score)
          if options['team_score'] == 'true'
            if team[:scores]
              teams_csv.push(team[:scores][:max], team[:scores][:min], team[:scores][:avg])
            else
      Severity: Minor
      Found in app/models/assignment.rb by rubocop

      This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

      Method has too many lines. [15/10]
      Open

        def add_participant(user_name, can_submit, can_review, can_take_quiz, can_mentor)
          user = User.find_by(name: user_name)
          if user.nil?
            raise "The user account with the name #{user_name} does not exist. Please <a href='" +
                  url_for(controller: 'users', action: 'new') + "'>create</a> the user first."
      Severity: Minor
      Found in app/models/assignment.rb by rubocop

      This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

      Cyclomatic complexity for csv_row is too high. [10/6]
      Open

        def self.csv_row(detail_options, answer)
          teams_csv = []
          @response = Response.find(answer.response_id)
          map = ResponseMap.find(@response.map_id)
          @reviewee = Team.find_by id: map.reviewee_id
      Severity: Minor
      Found in app/models/assignment.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.

      Method has too many lines. [13/10]
      Open

        def review_questionnaire_id(round_number = nil, topic_id = nil)
          # If round is not given, try to retrieve current round from the next due date
          if round_number.nil?
            next_due_date = DueDate.get_next_due_date(id)
            round_number = next_due_date.try(:round)
      Severity: Minor
      Found in app/models/assignment.rb by rubocop

      This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

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

        def self.csv_row(detail_options, answer)
          teams_csv = []
          @response = Response.find(answer.response_id)
          map = ResponseMap.find(@response.map_id)
          @reviewee = Team.find_by id: map.reviewee_id
      Severity: Minor
      Found in app/models/assignment.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

      Method has too many lines. [13/10]
      Open

        def remove_assignment_from_course
          oldpath = begin
                      path
                    rescue StandardError
                      nil
      Severity: Minor
      Found in app/models/assignment.rb by rubocop

      This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

      Method has too many lines. [11/10]
      Open

        def path
          if course_id.nil? && instructor_id.nil?
            raise 'The path cannot be created. The assignment must be associated with either a course or an instructor.'
          end
      
      
      Severity: Minor
      Found in app/models/assignment.rb by rubocop

      This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

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

        def find_review_period(round)
          # If round is nil, it means the same questionnaire is used for every round. Thus, we return all periods.
          # If round is not nil, we return only the period of that round.
      
          submission_type = DeadlineType.find_by(name: 'submission').id
      Severity: Minor
      Found in app/models/assignment.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 add_participant is too high. [16.4/15]
      Open

        def add_participant(user_name, can_submit, can_review, can_take_quiz, can_mentor)
          user = User.find_by(name: user_name)
          if user.nil?
            raise "The user account with the name #{user_name} does not exist. Please <a href='" +
                  url_for(controller: 'users', action: 'new') + "'>create</a> the user first."
      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

      Method has too many lines. [11/10]
      Open

        def self.generate_answer(answers, assignment)
          # get all response maps for this assignment
          @response_maps_for_assignment = ResponseMap.find_by_sql(["SELECT * FROM response_maps WHERE reviewed_object_id = #{assignment.id}"])
          # for each map, get the response & answer associated with it
          @response_maps_for_assignment.each do |map|
      Severity: Minor
      Found in app/models/assignment.rb by rubocop

      This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

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

        def delete(force = nil)
          begin
            maps = ReviewResponseMap.where(reviewed_object_id: id)
            maps.each { |map| map.delete(force) }
          rescue StandardError
      Severity: Minor
      Found in app/models/assignment.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.

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

        def find_review_period(round)
          # If round is nil, it means the same questionnaire is used for every round. Thus, we return all periods.
          # If round is not nil, we return only the period of that round.
      
          submission_type = DeadlineType.find_by(name: 'submission').id
      Severity: Minor
      Found in app/models/assignment.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

      Method has too many lines. [11/10]
      Open

        def questionnaire_ids(round)
          questionnaire_ids = if round.nil?
                                AssignmentQuestionnaire.where(assignment_id: id)
                              else
                                AssignmentQuestionnaire.where(assignment_id: id, used_in_round: round)
      Severity: Minor
      Found in app/models/assignment.rb by rubocop

      This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

      Method has too many lines. [11/10]
      Open

        def self.export_fields(options)
          fields = []
          fields << 'Team Name'
          fields << 'Team Member(s)'
          EXPORT_FIELDS.each do |key, value|
      Severity: Minor
      Found in app/models/assignment.rb by rubocop

      This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

      Assignment Branch Condition size for export_data_fields is too high. [15.17/15]
      Open

        def self.export_data_fields(options, team, teams_csv, participants_score)
          if options['team_score'] == 'true'
            if team[:scores]
              teams_csv.push(team[:scores][:max], team[:scores][:min], team[:scores][:avg])
            else
      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

      Method export_data has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.export_data(csv, scores, options)
          @scores = scores
          (0..@scores[:teams].length - 1).each do |index|
            team = @scores[:teams][index.to_s.to_sym]
            first_participant = team[:team].participants[0] unless team[:team].participants[0].nil?
      Severity: Minor
      Found in app/models/assignment.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 delete has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def delete(force = nil)
          begin
            maps = ReviewResponseMap.where(reviewed_object_id: id)
            maps.each { |map| map.delete(force) }
          rescue StandardError
      Severity: Minor
      Found in app/models/assignment.rb - About 1 hr to fix

        Method csv_row has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

          def self.csv_row(detail_options, answer)
            teams_csv = []
            @response = Response.find(answer.response_id)
            map = ResponseMap.find(@response.map_id)
            @reviewee = Team.find_by id: map.reviewee_id
        Severity: Minor
        Found in app/models/assignment.rb - About 55 mins 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 export has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def self.export(csv, parent_id, options)
            @assignment = Assignment.find(parent_id)
            @questions = {}
            questionnaires = @assignment.questionnaires
            questionnaires.each do |questionnaire|
        Severity: Minor
        Found in app/models/assignment.rb - About 45 mins 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 delete has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def delete(force = nil)
            begin
              maps = ReviewResponseMap.where(reviewed_object_id: id)
              maps.each { |map| map.delete(force) }
            rescue StandardError
        Severity: Minor
        Found in app/models/assignment.rb - About 45 mins 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_participant has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

          def add_participant(user_name, can_submit, can_review, can_take_quiz, can_mentor)
        Severity: Minor
        Found in app/models/assignment.rb - About 35 mins to fix

          Method export_individual_data_fields has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

            def self.export_individual_data_fields(review_type, score_name, teams_csv, participants_score, options)
          Severity: Minor
          Found in app/models/assignment.rb - About 35 mins to fix

            Method current_stage_name has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

              def current_stage_name(topic_id = nil)
                if staggered_deadline?
                  return (topic_id.nil? ? 'Unknown' : current_stage(topic_id))
                end
            
            
            Severity: Minor
            Found in app/models/assignment.rb - About 35 mins 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 export_details has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def self.export_details(csv, parent_id, detail_options)
                return csv unless detail_options.value?('true')
            
                @assignment = Assignment.find(parent_id)
                @answers = {} # Contains all answer objects for this assignment
            Severity: Minor
            Found in app/models/assignment.rb - About 25 mins 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 questionnaire_ids has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def questionnaire_ids(round)
                questionnaire_ids = if round.nil?
                                      AssignmentQuestionnaire.where(assignment_id: id)
                                    else
                                      AssignmentQuestionnaire.where(assignment_id: id, used_in_round: round)
            Severity: Minor
            Found in app/models/assignment.rb - About 25 mins 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

            1 trailing blank lines detected.
            Open

            Severity: Minor
            Found in app/models/assignment.rb by rubocop

            Redundant self detected.
            Open

                self.enable_pair_programming
            Severity: Minor
            Found in app/models/assignment.rb by rubocop

            This cop checks for redundant uses of self.

            The usage of self is only needed when:

            • Sending a message to same object with zero arguments in presence of a method name clash with an argument or a local variable.

            • Calling an attribute writer to prevent an local variable assignment.

            Note, with using explicit self you can only send messages with public or protected scope, you cannot send private messages this way.

            Note we allow uses of self with operators because it would be awkward otherwise.

            Example:

            # bad
            def foo(bar)
              self.baz
            end
            
            # good
            def foo(bar)
              self.bar  # Resolves name clash with the argument.
            end
            
            def foo
              bar = 1
              self.bar  # Resolves name clash with the local variable.
            end
            
            def foo
              %w[x y z].select do |bar|
                self.bar == bar  # Resolves name clash with argument of the block.
              end
            end

            Missing top-level class documentation comment.
            Open

            class Assignment < ApplicationRecord
            Severity: Minor
            Found in app/models/assignment.rb by rubocop

            This cop checks for missing top-level documentation of classes and modules. Classes with no body are exempt from the check and so are namespace modules - modules that have nothing in their bodies except classes, other modules, or constant definitions.

            The documentation requirement is annulled if the class or module has a "#:nodoc:" comment next to it. Likewise, "#:nodoc: all" does the same for all its children.

            Example:

            # bad
            class Person
              # ...
            end
            
            # good
            # Description/Explanation of Person class
            class Person
              # ...
            end

            Missing space after #.
            Open

                #This is a hack, we should actually check if we have more than one rubric of a given type eg, review
            Severity: Minor
            Found in app/models/assignment.rb by rubocop

            This cop checks whether comments have a leading space after the # denoting the start of the comment. The leading space is not required for some RDoc special syntax, like #++, #--, #:nodoc, =begin- and =end comments, "shebang" directives, or rackup options.

            Example:

            # bad
            #Some comment
            
            # good
            # Some comment

            Use a guard clause instead of wrapping the code inside a conditional expression.
            Open

                if answers[round_num][res_type].any?
            Severity: Minor
            Found in app/models/assignment.rb by rubocop

            Use a guard clause instead of wrapping the code inside a conditional expression

            Example:

            # bad
            def test
              if something
                work
              end
            end
            
            # good
            def test
              return unless something
              work
            end
            
            # also good
            def test
              work if something
            end
            
            # bad
            if something
              raise 'exception'
            else
              ok
            end
            
            # good
            raise 'exception' if something
            ok

            There are no issues that match your filters.

            Category
            Status