expertiza/expertiza

View on GitHub
app/controllers/invitations_controller.rb

Summary

Maintainability
A
50 mins
Test Coverage
F
0%

Class has too many lines. [119/100]
Open

class InvitationsController < ApplicationController
  include AuthorizationHelper
  include ConferenceHelper

  before_action :check_user_before_invitation, only: [:create]

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

Assignment Branch Condition size for check_user_before_invitation is too high. [23.96/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)
    # User/Author has information about the participant
    @student = AssignmentParticipant.find(params[:student_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

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?

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?

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_user_before_invitation
    # user is the student you are inviting to your team
    @user = User.find_by(name: params[:user][:name].strip)
    # User/Author has information about the participant
    @student = AssignmentParticipant.find(params[:student_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. [11/10]
Open

  def check_participant_before_invitation
    @participant = AssignmentParticipant.where('user_id = ? and parent_id = ?', @user.id, @student.parent_id).first
    # check if the user is a participant in the assignment
    unless @participant
      if @assignment.is_conference_assignment

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

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

  def check_participant_before_invitation
    @participant = AssignmentParticipant.where('user_id = ? and parent_id = ?', @user.id, @student.parent_id).first
    # check if the user is a participant in the assignment
    unless @participant
      if @assignment.is_conference_assignment

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
Severity: Minor
Found in app/controllers/invitations_controller.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 check_user_before_invitation has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
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)
    # User/Author has information about the participant
    @student = AssignmentParticipant.find(params[:student_id])
Severity: Minor
Found in app/controllers/invitations_controller.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

Missing top-level class documentation comment.
Open

class InvitationsController < ApplicationController

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