Assignment Branch Condition size for view_team is too high. [37.34/15] Open
def view_team
@participant = AssignmentParticipant.find(params[:id])
@assignment = @participant.assignment
@team = @participant.team
@team_id = @team.id
- Read upRead up
- Exclude checks
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 update is too high. [29.34/15] Open
def update
participant = AssignmentParticipant.find(params[:id])
total_score = params[:total_score]
if format("%.2f", total_score) != params[:participant][:grade]
# participant.update_attribute(:grade, params[:participant][:grade])
- Read upRead up
- Exclude checks
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 view_my_scores is too high. [29.98/15] Open
def view_my_scores
@participant = AssignmentParticipant.find(params[:id])
@team_id = TeamsUser.team_id(@participant.parent_id, @participant.user_id)
return if redirect_when_disallowed
@assignment = @participant.assignment
- Read upRead up
- Exclude checks
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_all_penalties is too high. [26/15] Open
def calculate_all_penalties(assignment_id)
@all_penalties = {}
@assignment = Assignment.find(assignment_id)
calculate_for_participants = true unless @assignment.is_penalty_calculated
Participant.where(parent_id: assignment_id).each do |participant|
- Read upRead up
- Exclude checks
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 instructor_review is too high. [25.18/15] Open
def instructor_review
participant = AssignmentParticipant.find(params[:id])
reviewer = AssignmentParticipant.find_or_create_by(user_id: session[:user].id, parent_id: participant.assignment.id)
reviewer.set_handle if reviewer.new_record?
review_exists = true
- Read upRead up
- Exclude checks
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
File grades_controller.rb
has 265 lines of code (exceeds 250 allowed). Consider refactoring. Open
class GradesController < ApplicationController
helper :file
helper :submitted_content
helper :penalty
include PenaltyHelper
Assignment Branch Condition size for action_allowed? is too high. [20.64/15] Open
def action_allowed?
case params[:action]
when 'view_my_scores'
['Instructor',
'Teaching Assistant',
- Read upRead up
- Exclude checks
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 redirect_when_disallowed is too high. [19.65/15] Open
def redirect_when_disallowed
# For author feedback, participants need to be able to read feedback submitted by other teammates.
# If response is anything but author feedback, only the person who wrote feedback should be able to see it.
## This following code was cloned from response_controller.
- Read upRead up
- Exclude checks
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 view is too high. [19.75/15] Open
def view
@assignment = Assignment.find(params[:id])
questionnaires = @assignment.questionnaires
if @assignment.varying_rubrics_by_round?
- Read upRead up
- Exclude checks
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 make_chart is too high. [18.89/15] Open
def make_chart
@grades_bar_charts = {}
participant_score_types = %i[metareview feedback teammate]
if @pscore[:review]
scores = []
- Read upRead up
- Exclude checks
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 calculate_all_penalties is too high. [7/6] Open
def calculate_all_penalties(assignment_id)
@all_penalties = {}
@assignment = Assignment.find(assignment_id)
calculate_for_participants = true unless @assignment.is_penalty_calculated
Participant.where(parent_id: assignment_id).each do |participant|
- Read upRead up
- Exclude checks
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 calculate_all_penalties
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def calculate_all_penalties(assignment_id)
@all_penalties = {}
@assignment = Assignment.find(assignment_id)
calculate_for_participants = true unless @assignment.is_penalty_calculated
Participant.where(parent_id: assignment_id).each do |participant|
- Read upRead up
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 view_team
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def view_team
@participant = AssignmentParticipant.find(params[:id])
@assignment = @participant.assignment
@team = @participant.team
@team_id = @team.id
Method redirect_when_disallowed
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def redirect_when_disallowed
# For author feedback, participants need to be able to read feedback submitted by other teammates.
# If response is anything but author feedback, only the person who wrote feedback should be able to see it.
## This following code was cloned from response_controller.
- Read upRead up
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 view_team
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def view_team
@participant = AssignmentParticipant.find(params[:id])
@assignment = @participant.assignment
@team = @participant.team
@team_id = @team.id
- Read upRead up
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"