ari/jobsworth

View on GitHub
app/models/user.rb

Summary

Maintainability
D
1 day
Test Coverage

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

class User < ActiveRecord::Base

  devise :database_authenticatable, :registerable, :encryptable,
         :recoverable, :rememberable, :trackable

Severity: Minor
Found in app/models/user.rb - About 5 hrs to fix

    File user.rb has 317 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'digest/md5'
    
    class User < ActiveRecord::Base
    
      devise :database_authenticatable, :registerable, :encryptable,
    Severity: Minor
    Found in app/models/user.rb - About 3 hrs to fix

      Method schedule_tasks has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

        def schedule_tasks(options={})
          options[:limit] ||= 1000000
          options[:save] = true unless options.key?(:save)
      
          if options[:save]
      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

      Method generate_widgets has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def generate_widgets
          w = new_widget
          w.name = I18n.t('widgets.top_tasks')
          w.widget_type = 0
          w.number = 5
      Severity: Minor
      Found in app/models/user.rb - About 1 hr to fix

        Method avatar_url has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

          def avatar_url(size=32, secure = false)
            if avatar?
              if size > 25 && File.exist?(avatar_large_path)
                '/users/avatar/'+id.to_s+'?large=1'
              else
        Severity: Minor
        Found in app/models/user.rb - About 55 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 can? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

          def can?(project, perm)
            return true if project.nil? or admin?
        
            @perm_cache ||= {}
            unless @perm_cache[project.id]
        Severity: Minor
        Found in app/models/user.rb - About 35 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