Showing 2 of 2 total issues
Consider simplifying this complex logical expression. Open
Open
if devise_controller? && resource_name == :user && (
# registration
action_name == 'new' || action_name == 'create' ||
# change password. Only for logout user because this action_names are also used on user_edit_registration_path
((action_name == 'edit' || action_name == 'update') && !user_signed_in?)
Method handle_omniauth_for_new_user
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
def handle_omniauth_for_new_user(provider_name, authentication)
# No user associated with the authentication so we need to create a new one
user = user_service.build_with_omniauth
if user_has_missing_only_email?(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"