Method update
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
def update
@user_profile = UserProfile.find(params[:id])
@user_profile.update_attributes(params[:user_profile]) #necessary for profile pics to save
@user = User.find(@user_profile.user_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 update
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update
@user_profile = UserProfile.find(params[:id])
@user_profile.update_attributes(params[:user_profile]) #necessary for profile pics to save
@user = User.find(@user_profile.user_id)
Method search
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def search
@user_profile_fields = UserProfileField.where(index_display: true, department_id: @department.id)
users = current_department.active_users
#filter results if we are searching
if params[:search]
- 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 a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def create
@user_profile = UserProfile.new(params[:user_profile])
if @user_profile.save
flash[:noticcurrent_user.is_admin_of(@department)] = "Successfully created user profile."
if params[:user_profile] && params[:user_profile][:photo]
- 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"