ece517-p3/expertiza

View on GitHub
app/helpers/review_mapping_helper.rb

Summary

Maintainability
D
1 day
Test Coverage

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

module ReviewMappingHelper
  def create_report_table_header(headers = {})
    table_header = "<div class = 'reviewreport'>\
                    <table width='100% cellspacing='0' cellpadding='2' border='0' class='table table-striped'>\
                    <tr bgcolor='#CCCCCC'>"

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

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

module ReviewMappingHelper
  def create_report_table_header(headers = {})
    table_header = "<div class = 'reviewreport'>\
                    <table width='100% cellspacing='0' cellpadding='2' border='0' class='table table-striped'>\
                    <tr bgcolor='#CCCCCC'>"
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. [33/15]
    Open

      def sort_reviewer_by_review_volume_desc
        @reviewers.each do |r|
          r.overall_avg_vol,
              r.avg_vol_in_round_1,
              r.avg_vol_in_round_2,

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

      def get_team_name_color_in_review_report(response_map)
        assignment_created = @assignment.created_at
        assignment_due_dates = DueDate.where(parent_id: response_map.reviewed_object_id)
        if Response.exists?(map_id: response_map.id)
          if !response_map.try(:reviewer).try(:review_grade).nil?
    Severity: Minor
    Found in app/helpers/review_mapping_helper.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

    Assignment Branch Condition size for get_each_round_score_awarded_for_review_report is too high. [25.32/15]
    Open

      def get_each_round_score_awarded_for_review_report(reviewer_id, team_id)
        (1..@assignment.num_review_rounds).each {|round| instance_variable_set("@score_awarded_round_" + round.to_s, '-----') }
        (1..@assignment.num_review_rounds).each do |round|
          if @review_scores[reviewer_id] && @review_scores[reviewer_id][round] && @review_scores[reviewer_id][round][team_id] && @review_scores[reviewer_id][round][team_id] != -1.0
            instance_variable_set("@score_awarded_round_" + round.to_s, @review_scores[reviewer_id][round][team_id].inspect + '%')

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

      def get_min_max_avg_value_for_review_report(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 calcutate_average_author_feedback_score is too high. [24.29/15]
    Open

      def calcutate_average_author_feedback_score(assignment_id, max_team_size, response_map_id, reviewee_id)
        review_response = ResponseMap.where(id: response_map_id).try(:first).try(:response).try(:last)
        author_feedback_avg_score = "-- / --"
        unless review_response.nil?
          user = TeamsUser.where(team_id: reviewee_id).try(:first).try(:user) if max_team_size == 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

    Assignment Branch Condition size for get_team_name_color_in_review_report is too high. [23.62/15]
    Open

      def get_team_name_color_in_review_report(response_map)
        assignment_created = @assignment.created_at
        assignment_due_dates = DueDate.where(parent_id: response_map.reviewed_object_id)
        if Response.exists?(map_id: response_map.id)
          if !response_map.try(:reviewer).try(:review_grade).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

    Assignment Branch Condition size for initialize_chart_elements is too high. [21.68/15]
    Open

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

    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_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

      Perceived complexity for get_team_name_color_in_review_report is too high. [12/7]
      Open

        def get_team_name_color_in_review_report(response_map)
          assignment_created = @assignment.created_at
          assignment_due_dates = DueDate.where(parent_id: response_map.reviewed_object_id)
          if Response.exists?(map_id: response_map.id)
            if !response_map.try(:reviewer).try(:review_grade).nil?

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

        def get_each_round_review_and_feedback_response_map_for_feedback_report(author)
          @team_id = TeamsUser.team_id(@id.to_i, author.user_id)
          # Calculate how many responses one team received from each round
          # It is the feedback number each team member should make
          @review_response_map_ids = ReviewResponseMap.where(["reviewed_object_id = ? and reviewee_id = ?", @id, @team_id]).pluck("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

      Cyclomatic complexity for get_team_name_color_in_review_report is too high. [8/6]
      Open

        def get_team_name_color_in_review_report(response_map)
          assignment_created = @assignment.created_at
          assignment_due_dates = DueDate.where(parent_id: response_map.reviewed_object_id)
          if Response.exists?(map_id: response_map.id)
            if !response_map.try(:reviewer).try(:review_grade).nil?

      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 list_review_submissions is too high. [16.82/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 = ''
          if !team.nil? and !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

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

        def calcutate_average_author_feedback_score(assignment_id, max_team_size, response_map_id, reviewee_id)
          review_response = ResponseMap.where(id: response_map_id).try(:first).try(:response).try(:last)
          author_feedback_avg_score = "-- / --"
          unless review_response.nil?
            user = TeamsUser.where(team_id: reviewee_id).try(:first).try(:user) if max_team_size == 1
      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 get_team_name_color_in_review_report has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def get_team_name_color_in_review_report(response_map)
          assignment_created = @assignment.created_at
          assignment_due_dates = DueDate.where(parent_id: response_map.reviewed_object_id)
          if Response.exists?(map_id: response_map.id)
            if !response_map.try(:reviewer).try(:review_grade).nil?
      Severity: Minor
      Found in app/helpers/review_mapping_helper.rb - About 1 hr to fix

        Method initialize_chart_elements has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def initialize_chart_elements(reviewer)
            round = 0
            labels = []
            reviewer_data = []
            all_reviewers_data = []
        Severity: Minor
        Found in app/helpers/review_mapping_helper.rb - About 1 hr to fix

          Avoid deeply nested control flow statements.
          Open

                        color.push link_updated_since_last?(round, assignment_due_dates, link_updated_at) ? 'purple' : 'green'
          Severity: Major
          Found in app/helpers/review_mapping_helper.rb - About 45 mins to fix

            Method sort_reviewer_by_review_volume_desc has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def sort_reviewer_by_review_volume_desc
                @reviewers.each do |r|
                  r.overall_avg_vol,
                      r.avg_vol_in_round_1,
                      r.avg_vol_in_round_2,
            Severity: Minor
            Found in app/helpers/review_mapping_helper.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 get_min_max_avg_value_for_review_report has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def get_min_max_avg_value_for_review_report(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

            Avoid more than 3 levels of block nesting.
            Open

                        if link.nil? or (link !~ %r{https*:\/\/wiki(.*)}) # can be extended for github links in future
                          color.push 'green'
                        else
                          link_updated_at = get_link_updated_at(link)
                          color.push link_updated_since_last?(round, assignment_due_dates, link_updated_at) ? 'purple' : 'green'

            This cop checks for excessive nesting of conditional and looping constructs.

            You can configure if blocks are considered using the CountBlocks option. When set to false (the default) blocks are not counted towards the nesting level. Set to true to count blocks as well.

            The maximum level of nesting allowed is configurable.

            Do not use to_time on Date objects, because they know nothing about the time zone in use.
            Open

                res.to_time

            This cop checks for the correct use of Date methods, such as Date.today, Date.current etc.

            Using Date.today is dangerous, because it doesn't know anything about Rails time zone. You must use Time.zone.today instead.

            The cop also reports warnings when you are using 'to_time' method, because it doesn't know about Rails time zone either.

            Two styles are supported for this cop. When EnforcedStyle is 'strict' then the Date methods (today, current, yesterday, tomorrow) are prohibited and the usage of both 'totime' and 'totimeincurrent_zone' is reported as warning.

            When EnforcedStyle is 'flexible' then only 'Date.today' is prohibited and only 'to_time' is reported as warning.

            Example: EnforcedStyle: strict

            # bad
            Date.current
            Date.yesterday
            Date.today
            date.to_time
            date.to_time_in_current_zone
            
            # good
            Time.zone.today
            Time.zone.today - 1.day

            Example: EnforcedStyle: flexible (default)

            # bad
            Date.today
            date.to_time
            
            # good
            Time.zone.today
            Time.zone.today - 1.day
            Date.current
            Date.yesterday
            date.to_time_in_current_zone

            Tagging a string as html safe may be a security risk.
            Open

                metric.html_safe

            This cop checks for the use of output safety calls like htmlsafe, raw, and safeconcat. These methods do not escape content. They simply return a SafeBuffer containing the content as is. Instead, use safe_join to join content and escape it and concat to concatenate content and escape it, ensuring its safety.

            Example:

            user_content = "hi"
            
            # bad
            "

            #{user_content}

            ".html_safe # => ActiveSupport::SafeBuffer "

            hi

            " # good content_tag(:p, user_content) # => ActiveSupport::SafeBuffer "

            <b>hi</b>

            " # bad out = "" out << "
          • #{user_content}
          • " out << "
          • #{user_content}
          • " out.html_safe # => ActiveSupport::SafeBuffer "
          • hi
          • hi
          • " # good out = [] out << content_tag(:li, user_content) out << content_tag(:li, user_content) safe_join(out) # => ActiveSupport::SafeBuffer # "
          • <b>hi</b>
          • <b>hi</b>
          • " # bad out = "

            trusted content

            ".html_safe out.safe_concat(user_content) # => ActiveSupport::SafeBuffer "

            trusted_content

            hi" # good out = "

            trusted content

            ".html_safe out.concat(user_content) # => ActiveSupport::SafeBuffer # "

            trusted_content

            <b>hi</b>" # safe, though maybe not good style out = "trusted content" result = out.concat(user_content) # => String "trusted contenthi" # because when rendered in ERB the String will be escaped: # <%= result %> # => trusted content<b>hi</b> # bad (user_content + " " + content_tag(:span, user_content)).html_safe # => ActiveSupport::SafeBuffer "hi <span><b>hi</b></span>" # good safe_join([user_content, " ", content_tag(:span, user_content)]) # => ActiveSupport::SafeBuffer # "<b>hi</b> <span>&lt;b&gt;hi&lt;/b&gt;</span>"

            Tagging a string as html safe may be a security risk.
            Open

                table_header.html_safe

            This cop checks for the use of output safety calls like htmlsafe, raw, and safeconcat. These methods do not escape content. They simply return a SafeBuffer containing the content as is. Instead, use safe_join to join content and escape it and concat to concatenate content and escape it, ensuring its safety.

            Example:

            user_content = "hi"
            
            # bad
            "

            #{user_content}

            ".html_safe # => ActiveSupport::SafeBuffer "

            hi

            " # good content_tag(:p, user_content) # => ActiveSupport::SafeBuffer "

            <b>hi</b>

            " # bad out = "" out << "
          • #{user_content}
          • " out << "
          • #{user_content}
          • " out.html_safe # => ActiveSupport::SafeBuffer "
          • hi
          • hi
          • " # good out = [] out << content_tag(:li, user_content) out << content_tag(:li, user_content) safe_join(out) # => ActiveSupport::SafeBuffer # "
          • <b>hi</b>
          • <b>hi</b>
          • " # bad out = "

            trusted content

            ".html_safe out.safe_concat(user_content) # => ActiveSupport::SafeBuffer "

            trusted_content

            hi" # good out = "

            trusted content

            ".html_safe out.concat(user_content) # => ActiveSupport::SafeBuffer # "

            trusted_content

            <b>hi</b>" # safe, though maybe not good style out = "trusted content" result = out.concat(user_content) # => String "trusted contenthi" # because when rendered in ERB the String will be escaped: # <%= result %> # => trusted content<b>hi</b> # bad (user_content + " " + content_tag(:span, user_content)).html_safe # => ActiveSupport::SafeBuffer "hi <span><b>hi</b></span>" # good safe_join([user_content, " ", content_tag(:span, user_content)]) # => ActiveSupport::SafeBuffer # "<b>hi</b> <span>&lt;b&gt;hi&lt;/b&gt;</span>"

            Tagging a string as html safe may be a security risk.
            Open

                html.html_safe

            This cop checks for the use of output safety calls like htmlsafe, raw, and safeconcat. These methods do not escape content. They simply return a SafeBuffer containing the content as is. Instead, use safe_join to join content and escape it and concat to concatenate content and escape it, ensuring its safety.

            Example:

            user_content = "hi"
            
            # bad
            "

            #{user_content}

            ".html_safe # => ActiveSupport::SafeBuffer "

            hi

            " # good content_tag(:p, user_content) # => ActiveSupport::SafeBuffer "

            <b>hi</b>

            " # bad out = "" out << "
          • #{user_content}
          • " out << "
          • #{user_content}
          • " out.html_safe # => ActiveSupport::SafeBuffer "
          • hi
          • hi
          • " # good out = [] out << content_tag(:li, user_content) out << content_tag(:li, user_content) safe_join(out) # => ActiveSupport::SafeBuffer # "
          • <b>hi</b>
          • <b>hi</b>
          • " # bad out = "

            trusted content

            ".html_safe out.safe_concat(user_content) # => ActiveSupport::SafeBuffer "

            trusted_content

            hi" # good out = "

            trusted content

            ".html_safe out.concat(user_content) # => ActiveSupport::SafeBuffer # "

            trusted_content

            <b>hi</b>" # safe, though maybe not good style out = "trusted content" result = out.concat(user_content) # => String "trusted contenthi" # because when rendered in ERB the String will be escaped: # <%= result %> # => trusted content<b>hi</b> # bad (user_content + " " + content_tag(:span, user_content)).html_safe # => ActiveSupport::SafeBuffer "hi <span><b>hi</b></span>" # good safe_join([user_content, " ", content_tag(:span, user_content)]) # => ActiveSupport::SafeBuffer # "<b>hi</b> <span>&lt;b&gt;hi&lt;/b&gt;</span>"

            Tagging a string as html safe may be a security risk.
            Open

                html.html_safe

            This cop checks for the use of output safety calls like htmlsafe, raw, and safeconcat. These methods do not escape content. They simply return a SafeBuffer containing the content as is. Instead, use safe_join to join content and escape it and concat to concatenate content and escape it, ensuring its safety.

            Example:

            user_content = "hi"
            
            # bad
            "

            #{user_content}

            ".html_safe # => ActiveSupport::SafeBuffer "

            hi

            " # good content_tag(:p, user_content) # => ActiveSupport::SafeBuffer "

            <b>hi</b>

            " # bad out = "" out << "
          • #{user_content}
          • " out << "
          • #{user_content}
          • " out.html_safe # => ActiveSupport::SafeBuffer "
          • hi
          • hi
          • " # good out = [] out << content_tag(:li, user_content) out << content_tag(:li, user_content) safe_join(out) # => ActiveSupport::SafeBuffer # "
          • <b>hi</b>
          • <b>hi</b>
          • " # bad out = "

            trusted content

            ".html_safe out.safe_concat(user_content) # => ActiveSupport::SafeBuffer "

            trusted_content

            hi" # good out = "

            trusted content

            ".html_safe out.concat(user_content) # => ActiveSupport::SafeBuffer # "

            trusted_content

            <b>hi</b>" # safe, though maybe not good style out = "trusted content" result = out.concat(user_content) # => String "trusted contenthi" # because when rendered in ERB the String will be escaped: # <%= result %> # => trusted content<b>hi</b> # bad (user_content + " " + content_tag(:span, user_content)).html_safe # => ActiveSupport::SafeBuffer "hi <span><b>hi</b></span>" # good safe_join([user_content, " ", content_tag(:span, user_content)]) # => ActiveSupport::SafeBuffer # "<b>hi</b> <span>&lt;b&gt;hi&lt;/b&gt;</span>"

            Line is too long. [164/160]
            Open

                  feedback_response = ResponseMap.where(reviewed_object_id: review_response.id, reviewer_id: author.id).try(:first).try(:response).try(:last) unless author.nil?

            Use normalcase for variable numbers.
            Open

              def display_volume_metric(overall_avg_vol, avg_vol_in_round_1, avg_vol_in_round_2, avg_vol_in_round_3)

            This cop makes sure that all numbered variables use the configured style, snakecase, normalcase or noninteger, for their numbering.

            Example: EnforcedStyle: snake_case

            # bad
            
            variable1 = 1
            
            # good
            
            variable_1 = 1

            Example: EnforcedStyle: normalcase (default)

            # bad
            
            variable_1 = 1
            
            # good
            
            variable1 = 1

            Example: EnforcedStyle: non_integer

            # bad
            
            variable1 = 1
            
            variable_1 = 1
            
            # good
            
            variableone = 1
            
            variable_one = 1

            Useless assignment to variable - sum. Use + instead of +=.
            Open

                @all_reviewers_avg_vol_in_round_3 = @reviewers.inject(0) {|sum, r| sum += r.avg_vol_in_round_3 } / (@reviewers.blank? ? 1 : @reviewers.length)

            This cop checks for every useless assignment to local variable in every scope. The basic idea for this cop was from the warning of ruby -cw:

            assigned but unused variable - foo

            Currently this cop has advanced logic that detects unreferenced reassignments and properly handles varied cases such as branch, loop, rescue, ensure, etc.

            Example:

            # bad
            
            def some_method
              some_var = 1
              do_something
            end

            Example:

            # good
            
            def some_method
              some_var = 1
              do_something(some_var)
            end

            Useless assignment to variable - sum. Use + instead of +=.
            Open

                @all_reviewers_avg_vol_in_round_1 = @reviewers.inject(0) {|sum, r| sum += r.avg_vol_in_round_1 } / (@reviewers.blank? ? 1 : @reviewers.length)

            This cop checks for every useless assignment to local variable in every scope. The basic idea for this cop was from the warning of ruby -cw:

            assigned but unused variable - foo

            Currently this cop has advanced logic that detects unreferenced reassignments and properly handles varied cases such as branch, loop, rescue, ensure, etc.

            Example:

            # bad
            
            def some_method
              some_var = 1
              do_something
            end

            Example:

            # good
            
            def some_method
              some_var = 1
              do_something(some_var)
            end

            Use normalcase for variable numbers.
            Open

                @all_reviewers_avg_vol_in_round_3 = @reviewers.inject(0) {|sum, r| sum += r.avg_vol_in_round_3 } / (@reviewers.blank? ? 1 : @reviewers.length)

            This cop makes sure that all numbered variables use the configured style, snakecase, normalcase or noninteger, for their numbering.

            Example: EnforcedStyle: snake_case

            # bad
            
            variable1 = 1
            
            # good
            
            variable_1 = 1

            Example: EnforcedStyle: normalcase (default)

            # bad
            
            variable_1 = 1
            
            # good
            
            variable1 = 1

            Example: EnforcedStyle: non_integer

            # bad
            
            variable1 = 1
            
            variable_1 = 1
            
            # good
            
            variableone = 1
            
            variable_one = 1

            Useless assignment to variable - sum. Use + instead of +=.
            Open

                @all_reviewers_avg_vol_in_round_2 = @reviewers.inject(0) {|sum, r| sum += r.avg_vol_in_round_2 } / (@reviewers.blank? ? 1 : @reviewers.length)

            This cop checks for every useless assignment to local variable in every scope. The basic idea for this cop was from the warning of ruby -cw:

            assigned but unused variable - foo

            Currently this cop has advanced logic that detects unreferenced reassignments and properly handles varied cases such as branch, loop, rescue, ensure, etc.

            Example:

            # bad
            
            def some_method
              some_var = 1
              do_something
            end

            Example:

            # good
            
            def some_method
              some_var = 1
              do_something(some_var)
            end

            Use normalcase for variable numbers.
            Open

              def display_volume_metric(overall_avg_vol, avg_vol_in_round_1, avg_vol_in_round_2, avg_vol_in_round_3)

            This cop makes sure that all numbered variables use the configured style, snakecase, normalcase or noninteger, for their numbering.

            Example: EnforcedStyle: snake_case

            # bad
            
            variable1 = 1
            
            # good
            
            variable_1 = 1

            Example: EnforcedStyle: normalcase (default)

            # bad
            
            variable_1 = 1
            
            # good
            
            variable1 = 1

            Example: EnforcedStyle: non_integer

            # bad
            
            variable1 = 1
            
            variable_1 = 1
            
            # good
            
            variableone = 1
            
            variable_one = 1

            Use normalcase for variable numbers.
            Open

              def display_volume_metric(overall_avg_vol, avg_vol_in_round_1, avg_vol_in_round_2, avg_vol_in_round_3)

            This cop makes sure that all numbered variables use the configured style, snakecase, normalcase or noninteger, for their numbering.

            Example: EnforcedStyle: snake_case

            # bad
            
            variable1 = 1
            
            # good
            
            variable_1 = 1

            Example: EnforcedStyle: normalcase (default)

            # bad
            
            variable_1 = 1
            
            # good
            
            variable1 = 1

            Example: EnforcedStyle: non_integer

            # bad
            
            variable1 = 1
            
            variable_1 = 1
            
            # good
            
            variableone = 1
            
            variable_one = 1

            Useless assignment to variable - round.
            Open

                  round += 1

            This cop checks for every useless assignment to local variable in every scope. The basic idea for this cop was from the warning of ruby -cw:

            assigned but unused variable - foo

            Currently this cop has advanced logic that detects unreferenced reassignments and properly handles varied cases such as branch, loop, rescue, ensure, etc.

            Example:

            # bad
            
            def some_method
              some_var = 1
              do_something
            end

            Example:

            # good
            
            def some_method
              some_var = 1
              do_something(some_var)
            end

            Use normalcase for variable numbers.
            Open

                @all_reviewers_avg_vol_in_round_2 = @reviewers.inject(0) {|sum, r| sum += r.avg_vol_in_round_2 } / (@reviewers.blank? ? 1 : @reviewers.length)

            This cop makes sure that all numbered variables use the configured style, snakecase, normalcase or noninteger, for their numbering.

            Example: EnforcedStyle: snake_case

            # bad
            
            variable1 = 1
            
            # good
            
            variable_1 = 1

            Example: EnforcedStyle: normalcase (default)

            # bad
            
            variable_1 = 1
            
            # good
            
            variable1 = 1

            Example: EnforcedStyle: non_integer

            # bad
            
            variable1 = 1
            
            variable_1 = 1
            
            # good
            
            variableone = 1
            
            variable_one = 1

            Line is too long. [176/160]
            Open

                  if @review_scores[reviewer_id] && @review_scores[reviewer_id][round] && @review_scores[reviewer_id][round][team_id] && @review_scores[reviewer_id][round][team_id] != -1.0

            Useless assignment to variable - sum. Use + instead of +=.
            Open

                @all_reviewers_overall_avg_vol = @reviewers.inject(0) {|sum, r| sum += r.overall_avg_vol } / (@reviewers.blank? ? 1 : @reviewers.length)

            This cop checks for every useless assignment to local variable in every scope. The basic idea for this cop was from the warning of ruby -cw:

            assigned but unused variable - foo

            Currently this cop has advanced logic that detects unreferenced reassignments and properly handles varied cases such as branch, loop, rescue, ensure, etc.

            Example:

            # bad
            
            def some_method
              some_var = 1
              do_something
            end

            Example:

            # good
            
            def some_method
              some_var = 1
              do_something(some_var)
            end

            Use normalcase for variable numbers.
            Open

                @all_reviewers_avg_vol_in_round_1 = @reviewers.inject(0) {|sum, r| sum += r.avg_vol_in_round_1 } / (@reviewers.blank? ? 1 : @reviewers.length)

            This cop makes sure that all numbered variables use the configured style, snakecase, normalcase or noninteger, for their numbering.

            Example: EnforcedStyle: snake_case

            # bad
            
            variable1 = 1
            
            # good
            
            variable_1 = 1

            Example: EnforcedStyle: normalcase (default)

            # bad
            
            variable_1 = 1
            
            # good
            
            variable1 = 1

            Example: EnforcedStyle: non_integer

            # bad
            
            variable1 = 1
            
            variable_1 = 1
            
            # good
            
            variableone = 1
            
            variable_one = 1

            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

            There are no issues that match your filters.

            Category
            Status