ari/jobsworth

View on GitHub
app/models/task_record.rb

Summary

Maintainability
C
1 day
Test Coverage

Class TaskRecord has 30 methods (exceeds 20 allowed). Consider refactoring.
Open

class TaskRecord < AbstractTask
  has_many :property_values, :through => :task_property_values

  scope :from_this_year, lambda { where('created_at > ?', Time.zone.now.beginning_of_year - 1.month) }
  scope :open_only, -> { where(:status => 0) }
Severity: Minor
Found in app/models/task_record.rb - About 3 hrs to fix

    Method update_group has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

      def update_group(user, group, value, icon = nil)
        if group == 'milestone'
          val_arr = value.split('/')
          task_project = user.projects.find_by(:name => val_arr[0])
          if user.can?(task_project, 'milestone')
    Severity: Minor
    Found in app/models/task_record.rb - About 2 hrs 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 update_group has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def update_group(user, group, value, icon = nil)
        if group == 'milestone'
          val_arr = value.split('/')
          task_project = user.projects.find_by(:name => val_arr[0])
          if user.can?(task_project, 'milestone')
    Severity: Minor
    Found in app/models/task_record.rb - About 1 hr to fix

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

        def users_to_notify(user_who_made_change=nil)
          if user_who_made_change and !user_who_made_change.receive_own_notifications?
            recipients= self.users.active.where('users.id != ? and users.receive_notifications = ?', user_who_made_change.id || 0, true)
          else
            recipients= self.users.active.where(:receive_notifications => true)
      Severity: Minor
      Found in app/models/task_record.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 score_rules has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def score_rules
          score_rules = []
      
          # Query scores only if company is using score rules
          if company.use_score_rules?
      Severity: Minor
      Found in app/models/task_record.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