Assignment Branch Condition size for check_team_before_accept is too high. [20.49/15] Open
def check_team_before_accept
@inv = Invitation.find(params[:inv_id])
# check if the inviter's team is still existing, and have available slot to add the invitee
inviter_assignment_team = AssignmentTeam.team(AssignmentParticipant.find_by(user_id: @inv.from_id, parent_id: @inv.assignment_id))
if inviter_assignment_team.nil?
- 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 check_user_before_invitation is too high. [19.34/15] Open
def check_user_before_invitation
# user is the student you are inviting to your team
@user = User.find_by(name: params[:user][:name].strip)
# student has information about the participant
@student = AssignmentParticipant.find(params[:student_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 check_team_before_invitation is too high. [17.58/15] Open
def check_team_before_invitation
# team has information about the team
@team = AssignmentTeam.find(params[:team_id])
if @team.full?
- 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
Method update_join_team_request
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def update_join_team_request(user, student)
# update the status in the join_team_request to A
return unless user && student
# participant information of invitee and assignment
participant = AssignmentParticipant.where('user_id = ? and parent_id = ?', user.id, student.parent_id).first
- 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"