gorums/WatchIoT

View on GitHub

Showing 21 of 21 total issues

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 deploy has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

      def deploy
        yaml = params[:deploy]
        errors = Project.evaluate yaml
    
        num_errors = errors.nil? || errors.empty? ? 0 : errors.length
    Severity: Minor
    Found in app/controllers/projects_controller.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

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

      def transfer(user, user_member_id)
        raise StandardError, 'The member is not valid' if
            user.nil? || user_member_id.nil?
    
        raise StandardError, 'The member is not valid' unless
    Severity: Minor
    Found in app/models/space.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 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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

      def account_primary_email
        redirect_to '/' + @user.username + '/setting/account'
    
        email = Email.primary(@user.id, params[:id])
    
    
    Severity: Minor
    Found in app/controllers/setting_controller.rb and 1 other location - About 40 mins to fix
    app/controllers/setting_controller.rb on lines 79..88

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 37.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

      def account_verify_email
        redirect_to '/' + @user.username + '/setting/account'
    
        email = Email.send_verify(@user.id, params[:id])
    
    
    Severity: Minor
    Found in app/controllers/setting_controller.rb and 1 other location - About 40 mins to fix
    app/controllers/setting_controller.rb on lines 65..74

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 37.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

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

      def self.find_email_forgot (email_s)
        emails = Email.where(email: email_s.downcase).all
        return if emails.nil? || emails.empty?
        return emails.first if emails.length == 1
    
    
    Severity: Minor
    Found in app/models/email.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 find_or_create_member has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.find_or_create_member(email_member)
        return if email_member.nil?
        emails = Email.where(email: email_member).all
        # if dont exist create a new account
        return User.create_new_account(email_member) if emails.nil? || emails.empty?
    Severity: Minor
    Found in app/models/team.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 name_format has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def name_format
        self.name.gsub!(/[^0-9a-z\-_ ]/i, '_') unless self.name.nil?
        self.name.gsub!(/\s+/, '-') unless self.name.nil?
        self.name = self.name.downcase unless self.name.nil?
      end
    Severity: Minor
    Found in app/models/space.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 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

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

      def allow
        @user = User.find_by_username(params[:username]) || not_found
        @user if auth? && @user.username == me.username ||
              Team.find_member(@user.id, me.id).exists? || unauthorized
        @spaces = Space.find_by_user_order(@user.id).all
    Severity: Minor
    Found in app/controllers/application_controller.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 do_login has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def do_login
        @user = User.new(user_params)
        user = User.login(user_params[:username], user_params[:passwd])
    
        cookies[:auth_token] = user.auth_token unless params[:remember_me]
    Severity: Minor
    Found in app/controllers/users_controller.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 allow_me has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def allow_me
        @user = User.find_by_username(params[:username]) || not_found
        @user if auth? && me.username == @user.username || unauthorized
        @spaces = Space.find_by_user_order(@user.id).all
      rescue Errors::UnauthorizedError
    Severity: Minor
    Found in app/controllers/setting_controller.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 name_format has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def name_format
        self.name.gsub!(/[^0-9a-z\-_ ]/i, '_') unless self.name.nil?
        self.name.gsub!(/\s+/, '-') unless self.name.nil?
        self.name = self.name.downcase unless self.name.nil?
      end
    Severity: Minor
    Found in app/models/project.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

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

      def name_format
        self.name.gsub!(/[^0-9a-z\-_ ]/i, '_') unless self.name.nil?
        self.name.gsub!(/\s+/, '-') unless self.name.nil?
        self.name = self.name.downcase unless self.name.nil?
    Severity: Minor
    Found in app/models/project.rb and 1 other location - About 25 mins to fix
    app/models/space.rb on lines 121..124

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 29.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

      def name_format
        self.name.gsub!(/[^0-9a-z\-_ ]/i, '_') unless self.name.nil?
        self.name.gsub!(/\s+/, '-') unless self.name.nil?
        self.name = self.name.downcase unless self.name.nil?
    Severity: Minor
    Found in app/models/space.rb and 1 other location - About 25 mins to fix
    app/models/project.rb on lines 166..169

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 29.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

      rescue => ex
        flash[:error] = clear_exception ex.message
        redirect_to '/' + @user.username + '/' + @space.name + '/' + @project.name
      end
    Severity: Minor
    Found in app/controllers/projects_controller.rb and 1 other location - About 15 mins to fix
    app/controllers/projects_controller.rb on lines 118..121

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 25.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Severity
    Category
    Status
    Source
    Language