expertiza/expertiza

View on GitHub
app/helpers/review_mapping_helper.rb

Summary

Maintainability
C
1 day
Test Coverage
F
18%

Module has too many lines. [318/100]
Open

module ReviewMappingHelper
  def create_report_table_header(headers = {})
    render partial: 'report_table_header', locals: { headers: headers }
  end

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

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

  def display_volume_metric_chart(reviewer)
    labels, reviewer_data, all_reviewers_data = initialize_chart_elements(reviewer)
    data = {
      labels: labels,
      datasets: [

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. [37/10]
Open

  def display_tagging_interval_chart(intervals)
    # if someone did not do any tagging in 30 seconds, then ignore this interval
    threshold = 30
    intervals = intervals.select { |v| v < threshold }
    unless intervals.empty?

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.

File review_mapping_helper.rb has 348 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module ReviewMappingHelper
  def create_report_table_header(headers = {})
    render partial: 'report_table_header', locals: { headers: headers }
  end

Severity: Minor
Found in app/helpers/review_mapping_helper.rb - About 4 hrs to fix

    Assignment Branch Condition size for sort_reviewer_by_review_volume_desc is too high. [32.7/15]
    Open

      def sort_reviewer_by_review_volume_desc
        @reviewers.each do |r|
          # get the volume of review comments
          review_volumes = Response.volume_of_review_comments(@assignment.id, r.id)
          r.avg_vol_per_round = []

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

      def review_metrics(round, team_id)
        %i[max min avg].each { |metric| instance_variable_set('@' + metric.to_s, '-----') }
        if @avg_and_ranges[team_id] && @avg_and_ranges[team_id][round] && %i[max min avg].all? { |k| @avg_and_ranges[team_id][round].key? k }
          %i[max min avg].each do |metric|
            metric_value = @avg_and_ranges[team_id][round][metric].nil? ? '-----' : @avg_and_ranges[team_id][round][metric].round(0).to_s + '%'

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

      def calculate_key_chart_information(intervals)
        # if someone did not do any tagging in 30 seconds, then ignore this interval
        threshold = 30
        interval_precision = 2 # Round to 2 Decimal Places
        intervals = intervals.select { |v| v < threshold }

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

      def get_awarded_review_score(reviewer_id, team_id)
        # Storing redundantly computed value in num_rounds variable
        num_rounds = @assignment.num_review_rounds
        # Setting values of instance variables
        (1..num_rounds).each { |round| instance_variable_set('@score_awarded_round_' + round.to_s, '-----') }

    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 sort_reviewer_by_review_volume_desc
        @reviewers.each do |r|
          # get the volume of review comments
          review_volumes = Response.volume_of_review_comments(@assignment.id, r.id)
          r.avg_vol_per_round = []

    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 display_volume_metric_chart has 57 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def display_volume_metric_chart(reviewer)
        labels, reviewer_data, all_reviewers_data = initialize_chart_elements(reviewer)
        data = {
          labels: labels,
          datasets: [
    Severity: Major
    Found in app/helpers/review_mapping_helper.rb - About 2 hrs to fix

      Assignment Branch Condition size for get_data_for_review_report is too high. [20.71/15]
      Open

        def get_data_for_review_report(reviewed_object_id, reviewer_id, type)
          rspan = 0
          (1..@assignment.num_review_rounds).each { |round| instance_variable_set('@review_in_round_' + round.to_s, 0) }
      
          response_maps = ResponseMap.where(['reviewed_object_id = ? AND reviewer_id = ? AND type = ?', reviewed_object_id, reviewer_id, type])

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

        def initialize_chart_elements(reviewer)
          round = 0
          labels = []
          reviewer_data = []
          all_reviewers_data = []

      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. [13/10]
      Open

        def get_team_color(response_map)
          # Storing redundantly computed value in a variable
          assignment_created = @assignment.created_at
          # Storing redundantly computed value in a variable
          assignment_due_dates = DueDate.where(parent_id: response_map.reviewed_object_id)

      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. [13/10]
      Open

        def calculate_key_chart_information(intervals)
          # if someone did not do any tagging in 30 seconds, then ignore this interval
          threshold = 30
          interval_precision = 2 # Round to 2 Decimal Places
          intervals = intervals.select { |v| v < threshold }

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

        def submitted_within_round?(round, response_map, assignment_created, assignment_due_dates)
          submission_due_date = assignment_due_dates.where(round: round, deadline_type_id: 1).try(:first).try(:due_at)
          submission = SubmissionRecord.where(team_id: response_map.reviewee_id, operation: ['Submit File', 'Submit Hyperlink'])
          subm_created_at = submission.where(created_at: assignment_created..submission_due_date)
          if round > 1

      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 check_submission_state(response_map, assignment_created, assignment_due_dates, round, color)
          if submitted_within_round?(round, response_map, assignment_created, assignment_due_dates)
            color.push 'purple'
          else
            link = submitted_hyperlink(round, response_map, assignment_created, assignment_due_dates)

      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 get_data_for_review_report(reviewed_object_id, reviewer_id, type)
          rspan = 0
          (1..@assignment.num_review_rounds).each { |round| instance_variable_set('@review_in_round_' + round.to_s, 0) }
      
          response_maps = ResponseMap.where(['reviewed_object_id = ? AND reviewer_id = ? AND type = ?', reviewed_object_id, reviewer_id, type])

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

        def list_review_submissions(participant_id, reviewee_team_id, response_map_id)
          participant = Participant.find(participant_id)
          team = AssignmentTeam.find(reviewee_team_id)
          html = ''
          unless team.nil? || participant.nil?

      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 display_tagging_interval_chart has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def display_tagging_interval_chart(intervals)
          # if someone did not do any tagging in 30 seconds, then ignore this interval
          threshold = 30
          intervals = intervals.select { |v| v < threshold }
          unless intervals.empty?
      Severity: Minor
      Found in app/helpers/review_mapping_helper.rb - About 1 hr to fix

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

          def check_submission_state(response_map, assignment_created, assignment_due_dates, round, color)
            if submitted_within_round?(round, response_map, assignment_created, assignment_due_dates)
              color.push 'purple'
            else
              link = submitted_hyperlink(round, response_map, assignment_created, assignment_due_dates)
        Severity: Minor
        Found in app/helpers/review_mapping_helper.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 sort_reviewer_by_review_volume_desc has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

          def sort_reviewer_by_review_volume_desc
            @reviewers.each do |r|
              # get the volume of review comments
              review_volumes = Response.volume_of_review_comments(@assignment.id, r.id)
              r.avg_vol_per_round = []
        Severity: Minor
        Found in app/helpers/review_mapping_helper.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 check_submission_state has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

          def check_submission_state(response_map, assignment_created, assignment_due_dates, round, color)
        Severity: Minor
        Found in app/helpers/review_mapping_helper.rb - About 35 mins to fix

          Method get_team_color has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            def get_team_color(response_map)
              # Storing redundantly computed value in a variable
              assignment_created = @assignment.created_at
              # Storing redundantly computed value in a variable
              assignment_due_dates = DueDate.where(parent_id: response_map.reviewed_object_id)
          Severity: Minor
          Found in app/helpers/review_mapping_helper.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 review_metrics has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            def review_metrics(round, team_id)
              %i[max min avg].each { |metric| instance_variable_set('@' + metric.to_s, '-----') }
              if @avg_and_ranges[team_id] && @avg_and_ranges[team_id][round] && %i[max min avg].all? { |k| @avg_and_ranges[team_id][round].key? k }
                %i[max min avg].each do |metric|
                  metric_value = @avg_and_ranges[team_id][round][metric].nil? ? '-----' : @avg_and_ranges[team_id][round][metric].round(0).to_s + '%'
          Severity: Minor
          Found in app/helpers/review_mapping_helper.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

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

              if @avg_and_ranges[team_id] && @avg_and_ranges[team_id][round] && %i[max min avg].all? { |k| @avg_and_ranges[team_id][round].key? k }

          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

          Missing top-level module documentation comment.
          Open

          module ReviewMappingHelper

          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 top-level class documentation comment.
          Open

            class ReviewStrategy

          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

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

              unless intervals.empty?

          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

          Missing top-level class documentation comment.
          Open

            class StudentReviewStrategy < ReviewStrategy

          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 top-level class documentation comment.
          Open

            class TeamReviewStrategy < ReviewStrategy

          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

          There are no issues that match your filters.

          Category
          Status