Class ProfileController
has 58 methods (exceeds 20 allowed). Consider refactoring. Open
class ProfileController < PublicController
needs_profile
before_action :check_access_to_profile, except: [:join, :join_not_logged, :index, :add]
before_action :store_location, only: [:join, :join_not_logged, :report_abuse, :send_mail]
before_action :login_required, only: [:add, :join, :leave, :unblock, :leave_scrap, :remove_scrap, :remove_activity, :view_more_activities, :view_more_network_activities, :report_abuse, :register_report, :leave_comment_on_activity, :send_mail, :follow, :unfollow]
File profile_controller.rb
has 477 lines of code (exceeds 250 allowed). Consider refactoring. Open
class ProfileController < PublicController
needs_profile
before_action :check_access_to_profile, except: [:join, :join_not_logged, :index, :add]
before_action :store_location, only: [:join, :join_not_logged, :report_abuse, :send_mail]
before_action :login_required, only: [:add, :join, :leave, :unblock, :leave_scrap, :remove_scrap, :remove_activity, :view_more_activities, :view_more_network_activities, :report_abuse, :register_report, :leave_comment_on_activity, :send_mail, :follow, :unfollow]
Method register_report
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def register_report
unless verify_captcha(:report_abuse, nil, user, environment, profile)
render plain: {
ok: false,
error: {
Method register_report
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def register_report
unless verify_captcha(:report_abuse, nil, user, environment, profile)
render plain: {
ok: false,
error: {
- 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 join
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def join
if !user.memberships.include?(profile)
return if profile.community? && show_confirmation_modal?(profile)
profile.add_member(user)
- 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 leave_comment_on_activity
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def leave_comment_on_activity
@comment = Comment.new(params[:comment])
@comment.author = user
@activity = ActionTracker::Record.find(params[:source_id])
@comment.source_type, @comment.source_id = (@activity.target_type == "Article" ? ["Article", @activity.target_id] : [@activity.class.to_s, @activity.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 leave_scrap
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def leave_scrap
sender = params[:sender_id].nil? ? current_user.person : Person.find(params[:sender_id])
receiver = params[:receiver_id].nil? ? @profile : Person.find(params[:receiver_id])
@scrap = Scrap.new(params[:scrap])
@scrap.sender = sender
- 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 unfollow
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def unfollow
follower = params[:follower_id].present? ? Person.find_by(id: params[:follower_id]) : current_person
if follower && follower.follows?(profile)
follower.unfollow(profile)
- 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 index
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def index
@offsets = { wall: 0, network: 0 }
page = (params[:page] || 1).to_i
if logged_in?
@activities = loop_fetch_activities(@profile.activities, :wall, page) if @profile.display_to?(user, :wall)
- 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 send_mail
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def send_mail
@mailing = profile.mailings.build(params[:mailing])
@mailing.data = session[:members_filtered] ? { members_filtered: session[:members_filtered] } : {}
@email_templates = profile.email_templates.where template_type: :organization_members
if request.post?
- 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"