File people_controller.rb
has 325 lines of code (exceeds 250 allowed). Consider refactoring. Open
class PeopleController < Devise::RegistrationsController
include ConfigRecaptcha
skip_before_action :verify_authenticity_token, :only => [:create]
skip_before_action :require_no_authentication, :only => [:new]
Method create
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
def create
domain = @current_community ? @current_community.full_url : "#{request.protocol}#{request.host_with_port}"
error_redirect_path = domain + sign_up_path
unless validate_recaptcha(params['g-recaptcha-response'])
- 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 20 (exceeds 5 allowed). Consider refactoring. Open
def update
target_user = Person.find_by!(username: params[:id], community_id: @current_community.id)
if @current_user != target_user
logger.info "ADMIN ACTION: admin='#{@current_user.id}' update person='#{target_user.id}' params=#{params.inspect}"
end
- 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 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update
target_user = Person.find_by!(username: params[:id], community_id: @current_community.id)
if @current_user != target_user
logger.info "ADMIN ACTION: admin='#{@current_user.id}' update person='#{target_user.id}' params=#{params.inspect}"
end
Method create
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create
domain = @current_community ? @current_community.full_url : "#{request.protocol}#{request.host_with_port}"
error_redirect_path = domain + sign_up_path
unless validate_recaptcha(params['g-recaptcha-response'])
Method person_create_params
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def person_create_params(params)
result = params.require(:person).slice(
:given_name,
:family_name,
:display_name,
Avoid too many return
statements within this method. Open
redirect_to error_redirect_path and return
Method new
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def new
@selected_tribe_navi_tab = "members"
redirect_to search_path if logged_in?
session[:invitation_code] = params[:code] if params[:code]
service_init
- 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"