Method create
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
def create
# if it's an admin creating new requests (inviting) for his space
if params[:type] == 'invite' && can?(:manage_join_requests, @space)
success, errors, already_invited = process_invitations
- 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 process_additions
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def process_additions
errors = []
success = []
ids = params[:candidates].try(:split, ',') || []
ids.each do |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"
Further reading
Method save_for_accept_and_decline
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def save_for_accept_and_decline(msg)
respond_to do |format|
if @join_request.save
format.html {
flash[:success] = msg
- 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 create
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create
# if it's an admin creating new requests (inviting) for his space
if params[:type] == 'invite' && can?(:manage_join_requests, @space)
success, errors, already_invited = process_invitations
Method process_additions
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def process_additions
errors = []
success = []
ids = params[:candidates].try(:split, ',') || []
ids.each do |id|
Method decline
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def decline
# canceling a request/invitation means it will be destroyed, otherwise it is actually
# marked as declined and kept in the database
user_canceling_request = @join_request.is_request? && @join_request.candidate == current_user
admin_canceling_invitation = @join_request.is_invite? &&
- 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 process_invitations
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def process_invitations
already_invited = []
errors = []
success = []
ids = params[:candidates].try(:split, ',') || []
- 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 process_invitations
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def process_invitations
already_invited = []
errors = []
success = []
ids = params[:candidates].try(:split, ',') || []
Method allowed_params
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def allowed_params
is_space_admin = @space.present? && can?(:manage_join_requests, @space)
if params[:action] == "create"
if is_space_admin
[ :role_id, :comment ]
- 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"