JumpstartLab/tracks

View on GitHub
app/models/todo.rb

Summary

Maintainability
D
2 days
Test Coverage

Class Todo has 34 methods (exceeds 20 allowed). Consider refactoring.
Open

class Todo < ActiveRecord::Base

  before_save :render_note
  after_save :save_predecessors

Severity: Minor
Found in app/models/todo.rb - About 4 hrs to fix

    File todo.rb has 320 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    class Todo < ActiveRecord::Base
    
      before_save :render_note
      after_save :save_predecessors
    
    
    Severity: Minor
    Found in app/models/todo.rb - About 3 hrs to fix

      Method from_rich_message has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.from_rich_message(user, default_context_id, description, notes)
          fields = description.match(/([^>@]*)@?([^>]*)>?(.*)/)
          description = fields[1].strip
          context = fields[2].strip
          project = fields[3].strip
      Severity: Minor
      Found in app/models/todo.rb - About 3 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 from_rich_message has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def self.from_rich_message(user, default_context_id, description, notes)
          fields = description.match(/([^>@]*)@?([^>]*)>?(.*)/)
          description = fields[1].strip
          context = fields[2].strip
          project = fields[3].strip
      Severity: Minor
      Found in app/models/todo.rb - About 1 hr to fix

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

          def save_predecessors
            unless @predecessor_array.nil?  # Only save predecessors if they changed
              current_array = self.predecessors
              remove_array = current_array - @predecessor_array
              add_array = @predecessor_array - current_array
        Severity: Minor
        Found in app/models/todo.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 add_predecessor_list has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def add_predecessor_list(predecessor_list)
            return unless predecessor_list.kind_of? String
        
            @predecessor_array=predecessor_list.split(",").inject([]) do |list, todo_id|
              predecessor = self.user.todos.find( todo_id.to_i ) unless todo_id.blank?
        Severity: Minor
        Found in app/models/todo.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 project= has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def project=(value)
            if value.is_a? Project
              self.original_project=(value)
            elsif !(value.nil? || value.is_a?(NullProject))
              p = Project.where(:name => value[:name]).first
        Severity: Minor
        Found in app/models/todo.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 predecessor_dependencies= has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def predecessor_dependencies=(params)
            deps = params[:predecessor]
            return if deps.nil?
        
            # for multiple dependencies, value will be an array of id's, but for a single dependency,
        Severity: Minor
        Found in app/models/todo.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 update_state_from_project has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def update_state_from_project
            if self.project_hidden? && (!self.project.hidden?)
              if self.uncompleted_predecessors.empty?
                self.activate!
              else
        Severity: Minor
        Found in app/models/todo.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 is_successor? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def is_successor?(todo)
            if self == todo
              return true
            elsif self.successors.empty?
              return false
        Severity: Minor
        Found in app/models/todo.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