app/models/user.rb
Class User
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
Open
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable, :lockable and :timeoutable
devise :database_authenticatable, :registerable, :omniauthable,
:recoverable, :rememberable, :trackable, :validatable
Method update_with_password_pass
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
Open
def update_with_password_pass(params={})
if params[:password].blank? and params[:email] == self.email
params.delete(:current_password)
params.delete(:password)
- 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
Complex method User#update_with_password_pass (30.8) Open
Open
def update_with_password_pass(params={})
if params[:password].blank? and params[:email] == self.email
params.delete(:current_password)
params.delete(:password)
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Complex method User::from_omniauth (25.8) Open
Open
def self.from_omniauth(auth)
auth_token = Authorization.where(provider: auth.provider, uid: auth.uid).first
# If we have a token without an associated user (user canceled signup), we delete it and the user has to sign up
if (auth_token && auth_token.user.nil?)
auth_token.destroy
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool