nerdhub/hcking

View on GitHub
app/models/user.rb

Summary

Maintainability
A
3 hrs
Test Coverage

Class User has 21 methods (exceeds 20 allowed). Consider refactoring.
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
Severity: Minor
Found in app/models/user.rb - About 2 hrs to fix

    Method update_with_password_pass has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

      def update_with_password_pass(params={})
    
        if params[:password].blank? and params[:email] == self.email
          params.delete(:current_password)
          params.delete(:password)
    Severity: Minor
    Found in app/models/user.rb - About 1 hr to fix

    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

      def update_with_password_pass(params={})
    
        if params[:password].blank? and params[:email] == self.email
          params.delete(:current_password)
          params.delete(:password)
    Severity: Minor
    Found in app/models/user.rb by flog

    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

      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
    Severity: Minor
    Found in app/models/user.rb by flog

    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

    There are no issues that match your filters.

    Category
    Status