ece517-p3/expertiza

View on GitHub
app/models/on_the_fly_calc.rb

Summary

Maintainability
A
2 hrs
Test Coverage

Assignment Branch Condition size for compute_avg_and_ranges_hash is too high. [29.22/15]
Open

  def compute_avg_and_ranges_hash
    scores = {}
    contributors = self.contributors # assignment_teams
    if self.varying_rubrics_by_round?
      rounds = self.rounds_of_reviews
Severity: Minor
Found in app/models/on_the_fly_calc.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 scores_varying_rubrics is too high. [27.29/15]
Open

def scores_varying_rubrics
  rounds = self.rounds_of_reviews
  (1..rounds).each do |round|
    review_questionnaire_id = review_questionnaire_id(round)
    @questions = Question.where('questionnaire_id = ?', review_questionnaire_id)
Severity: Minor
Found in app/models/on_the_fly_calc.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 scores_varying_rubrics has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

def scores_varying_rubrics
  rounds = self.rounds_of_reviews
  (1..rounds).each do |round|
    review_questionnaire_id = review_questionnaire_id(round)
    @questions = Question.where('questionnaire_id = ?', review_questionnaire_id)
Severity: Minor
Found in app/models/on_the_fly_calc.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 calc_review_score has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

def calc_review_score
  if !@corresponding_response.empty?
    @this_review_score_raw = Answer.get_total_score(response: @corresponding_response, questions: @questions)
    if @this_review_score_raw
      @this_review_score = ((@this_review_score_raw * 100) / 100.0).round if @this_review_score_raw >= 0.0
Severity: Minor
Found in app/models/on_the_fly_calc.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 compute_avg_and_ranges_hash has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def compute_avg_and_ranges_hash
    scores = {}
    contributors = self.contributors # assignment_teams
    if self.varying_rubrics_by_round?
      rounds = self.rounds_of_reviews
Severity: Minor
Found in app/models/on_the_fly_calc.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

Final newline missing.
Open

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

Move @response_maps = ResponseMap.where('reviewed_object_id = ? && type = ?', self.id, @response_type) out of the conditional.
Open

      @response_maps = ResponseMap.where('reviewed_object_id = ? && type = ?', self.id, @response_type)
Severity: Minor
Found in app/models/on_the_fly_calc.rb by rubocop

This cop checks for identical lines at the beginning or end of each branch of a conditional statement.

Example:

# bad
if condition
  do_x
  do_z
else
  do_y
  do_z
end

# good
if condition
  do_x
else
  do_y
end
do_z

# bad
if condition
  do_z
  do_x
else
  do_z
  do_y
end

# good
do_z
if condition
  do_x
else
  do_y
end

# bad
case foo
when 1
  do_x
when 2
  do_x
else
  do_x
end

# good
case foo
when 1
  do_x
  do_y
when 2
  # nothing
else
  do_x
  do_z
end

Move @response_maps = ResponseMap.where('reviewed_object_id = ? && type = ?', self.id, @response_type) out of the conditional.
Open

      @response_maps = ResponseMap.where('reviewed_object_id = ? && type = ?', self.id, @response_type)
Severity: Minor
Found in app/models/on_the_fly_calc.rb by rubocop

This cop checks for identical lines at the beginning or end of each branch of a conditional statement.

Example:

# bad
if condition
  do_x
  do_z
else
  do_y
  do_z
end

# good
if condition
  do_x
else
  do_y
end
do_z

# bad
if condition
  do_z
  do_x
else
  do_z
  do_y
end

# good
do_z
if condition
  do_x
else
  do_y
end

# bad
case foo
when 1
  do_x
when 2
  do_x
else
  do_x
end

# good
case foo
when 1
  do_x
  do_y
when 2
  # nothing
else
  do_x
  do_z
end

There are no issues that match your filters.

Category
Status