gorums/WatchIoT

View on GitHub
app/models/user.rb

Summary

Maintainability
B
5 hrs
Test Coverage

Class User has 22 methods (exceeds 20 allowed). Consider refactoring.
Open

class User < ActiveRecord::Base
  attr_accessor :passwd_confirmation, :passwd_new, :remember_me

  has_many :teams
  has_many :emails
Severity: Minor
Found in app/models/user.rb - About 2 hrs to fix

    Method reset_passwd has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def reset_passwd(params)
        passwd_confirmation = params[:passwd_new] == params[:passwd_confirmation]
        passwd_is_short = params[:passwd_new].nil? || params[:passwd_new].length < 8
    
        raise StandardError, 'Password has less than 8 characters' if passwd_is_short
    Severity: Minor
    Found in app/models/user.rb - About 45 mins 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

    Method send_forgot_notification has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.send_forgot_notification(criteria)
        return if criteria.nil? || criteria.empty?
        user = User.find_by_username criteria # find by username
        email = Email.find_primary_by_email(criteria).take # find by primary email
    
    
    Severity: Minor
    Found in app/models/user.rb - About 45 mins 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

    Method authenticate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.authenticate(email, passwd)
        return if passwd.nil? || passwd.empty? || email.nil? || email.empty?
        user_email = Email.find_primary_by_email(email).take
    
        user = user_email.user unless user_email.nil?
    Severity: Minor
    Found in app/models/user.rb - About 45 mins 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

    Method change_passwd has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def change_passwd(params)
        old_password = BCrypt::Engine.hash_secret(params[:passwd], self.passwd_salt)
        passwd_confirmation = params[:passwd_new] == params[:passwd_confirmation]
        same_old_passwd = self.passwd == old_password
        passwd_is_short = params[:passwd_new].nil? || params[:passwd_new].length < 8
    Severity: Minor
    Found in app/models/user.rb - About 25 mins 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

    Method save_user_and_email has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.save_user_and_email(user, email, checked = false)
        passwd_confirm = user.passwd == user.passwd_confirmation
        passwd_is_short = user.passwd.nil? || user.passwd.length < 8
    
        raise StandardError, 'Password has less than 8 characters' if passwd_is_short
    Severity: Minor
    Found in app/models/user.rb - About 25 mins 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

    There are no issues that match your filters.

    Category
    Status