File users_controller.rb
has 252 lines of code (exceeds 250 allowed). Consider refactoring. Open
class UsersController < ApplicationController
cache_sweeper :pseud_sweeper
before_action :check_user_status, only: [:edit, :update]
before_action :load_user, except: [:activate, :delete_confirmation, :index]
Method destroy_author
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def destroy_author
@sole_authored_works = @user.sole_authored_works
@coauthored_works = @user.coauthored_works
if params[:cancel_button]
Method activate
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def activate
if params[:id].blank?
flash[:error] = ts('Your activation key is missing.')
redirect_to root_path
Method destroy_author
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def destroy_author
@sole_authored_works = @user.sole_authored_works
@coauthored_works = @user.coauthored_works
if params[:cancel_button]
- 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 changed_username
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def changed_username
render(:change_username) && return unless params[:new_login].present?
@new_login = params[:new_login]
- 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 activate
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def activate
if params[:id].blank?
flash[:error] = ts('Your activation key is missing.')
redirect_to root_path
- 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 changed_email
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def changed_email
if !params[:new_email].blank? && reauthenticate
new_email = params[:new_email]
# Please note: This comparison is not technically correct. According to
- 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 update
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def update
authorize @user.profile if logged_in_as_admin?
if @user.profile.update(profile_params)
if logged_in_as_admin? && @user.profile.ticket_url.present?
link = view_context.link_to("Ticket ##{@user.profile.ticket_number}", @user.profile.ticket_url)
- 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"