JumpstartLab/tracks

View on GitHub
app/controllers/todos_controller.rb

Summary

Maintainability
F
2 wks
Test Coverage

File todos_controller.rb has 1197 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class TodosController < ApplicationController

  skip_before_filter :login_required, :only => [:index, :calendar, :tag]
  prepend_before_filter :login_or_feed_token_required, :only => [:index, :calendar, :tag]
  append_before_filter :find_and_activate_ready, :only => [:index, :list_deferred]
Severity: Major
Found in app/controllers/todos_controller.rb - About 3 days to fix

    Method create has a Cognitive Complexity of 99 (exceeds 5 allowed). Consider refactoring.
    Open

      def create
        @source_view = params['_source_view'] || 'todo'
        @default_context = current_user.contexts.where(:name => params['default_context_name']).first
        @default_project = current_user.projects.where(:name => params['default_project_name']).first unless params['default_project_name'].blank?
    
    
    Severity: Minor
    Found in app/controllers/todos_controller.rb - About 1 day 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 create_multiple has a Cognitive Complexity of 67 (exceeds 5 allowed). Consider refactoring.
    Open

      def create_multiple
        if project_specified_by_name(params[:project_name])
          project = current_user.projects.where(:name => params[:project_name]).first_or_create
          @new_project_created = project.new_record_before_save?
          @project_id = project.id
    Severity: Minor
    Found in app/controllers/todos_controller.rb - About 1 day 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

    Class TodosController has 62 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class TodosController < ApplicationController
    
      skip_before_filter :login_required, :only => [:index, :calendar, :tag]
      prepend_before_filter :login_or_feed_token_required, :only => [:index, :calendar, :tag]
      append_before_filter :find_and_activate_ready, :only => [:index, :list_deferred]
    Severity: Major
    Found in app/controllers/todos_controller.rb - About 1 day to fix

      Method toggle_check has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring.
      Open

        def toggle_check
          @todo = current_user.todos.find(params['id'])
          @source_view = params['_source_view'] || 'todo'
          @original_item_due = @todo.due
          @original_item_was_deferred = @todo.deferred?
      Severity: Minor
      Found in app/controllers/todos_controller.rb - About 1 day 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 determine_remaining_in_context_count has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
      Open

        def determine_remaining_in_context_count(context_id = @todo.context_id)
          source_view do |from|
            from.deferred {
              # force reload to todos to get correct count and not a cached one
              @remaining_in_context = current_user.contexts.find(context_id).todos.deferred_or_blocked.count
      Severity: Minor
      Found in app/controllers/todos_controller.rb - About 4 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 create has 87 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def create
          @source_view = params['_source_view'] || 'todo'
          @default_context = current_user.contexts.where(:name => params['default_context_name']).first
          @default_project = current_user.projects.where(:name => params['default_project_name']).first unless params['default_project_name'].blank?
      
      
      Severity: Major
      Found in app/controllers/todos_controller.rb - About 3 hrs to fix

        Method create_multiple has 77 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def create_multiple
            if project_specified_by_name(params[:project_name])
              project = current_user.projects.where(:name => params[:project_name]).first_or_create
              @new_project_created = project.new_record_before_save?
              @project_id = project.id
        Severity: Major
        Found in app/controllers/todos_controller.rb - About 3 hrs to fix

          Method destroy has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
          Open

            def destroy
              @source_view = params['_source_view'] || 'todo'
              @todo = current_user.todos.find(params['id'])
              @original_item_due = @todo.due
              @context_id = @todo.context_id
          Severity: Minor
          Found in app/controllers/todos_controller.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 check_for_next_todo has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

            def check_for_next_todo(todo)
              # check if this todo has a related recurring_todo. If so, create next todo
              new_recurring_todo = nil
              recurring_todo = nil
              if todo.from_recurring_todo?
          Severity: Minor
          Found in app/controllers/todos_controller.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 has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

            def update
              @todo = current_user.todos.find(params['id'])
              @source_view = params['_source_view'] || 'todo'
              # init_data_for_sidebar unless mobile?
          
          
          Severity: Minor
          Found in app/controllers/todos_controller.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 toggle_check has 61 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def toggle_check
              @todo = current_user.todos.find(params['id'])
              @source_view = params['_source_view'] || 'todo'
              @original_item_due = @todo.due
              @original_item_was_deferred = @todo.deferred?
          Severity: Major
          Found in app/controllers/todos_controller.rb - About 2 hrs to fix

            Method index has 57 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def index
                @source_view = params['_source_view'] || 'todo'
                init_data_for_sidebar unless mobile?
                
                @todos = current_user.todos.includes(Todo::DEFAULT_INCLUDES)
            Severity: Major
            Found in app/controllers/todos_controller.rb - About 2 hrs to fix

              Method destroy has 52 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def destroy
                  @source_view = params['_source_view'] || 'todo'
                  @todo = current_user.todos.find(params['id'])
                  @original_item_due = @todo.due
                  @context_id = @todo.context_id
              Severity: Major
              Found in app/controllers/todos_controller.rb - About 2 hrs to fix

                Method tag has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def tag
                    get_params_for_tag_view
                    @page_title = t('todos.tagged_page_title', :tag_name => @tag_title)
                    @source_view = params['_source_view'] || 'tag'
                
                
                Severity: Minor
                Found in app/controllers/todos_controller.rb - About 1 hr to fix

                  Method determine_remaining_in_context_count has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def determine_remaining_in_context_count(context_id = @todo.context_id)
                      source_view do |from|
                        from.deferred {
                          # force reload to todos to get correct count and not a cached one
                          @remaining_in_context = current_user.contexts.find(context_id).todos.deferred_or_blocked.count
                  Severity: Minor
                  Found in app/controllers/todos_controller.rb - About 1 hr to fix

                    Method new has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def new
                        @projects = current_user.projects.active
                        @contexts = current_user.contexts
                        respond_to do |format|
                          format.m {
                    Severity: Minor
                    Found in app/controllers/todos_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 calendar has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def calendar
                        @source_view = params['_source_view'] || 'calendar'
                        @page_title = t('todos.calendar_page_title')
                    
                        @projects = current_user.projects
                    Severity: Minor
                    Found in app/controllers/todos_controller.rb - About 1 hr to fix

                      Method index has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def index
                          @source_view = params['_source_view'] || 'todo'
                          init_data_for_sidebar unless mobile?
                          
                          @todos = current_user.todos.includes(Todo::DEFAULT_INCLUDES)
                      Severity: Minor
                      Found in app/controllers/todos_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 auto_complete_for_predecessor has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def auto_complete_for_predecessor
                          unless params['id'].nil?
                            get_todo_from_params
                            # Begin matching todos in current project, excluding @todo itself
                            @items = @todo.project.todos.not_completed.
                      Severity: Minor
                      Found in app/controllers/todos_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 determine_down_count has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def determine_down_count
                          source_view do |from|
                            from.todo do
                              @down_count = current_user.todos.active.not_hidden.count
                            end
                      Severity: Minor
                      Found in app/controllers/todos_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 update has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def update
                          @todo = current_user.todos.find(params['id'])
                          @source_view = params['_source_view'] || 'todo'
                          # init_data_for_sidebar unless mobile?
                      
                      
                      Severity: Minor
                      Found in app/controllers/todos_controller.rb - About 1 hr to fix

                        Method defer has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          def defer
                            @source_view = params['_source_view'] || 'todo'
                            numdays = params['days'].to_i
                        
                            @todo = current_user.todos.find(params[:id])
                        Severity: Minor
                        Found in app/controllers/todos_controller.rb - About 1 hr to fix

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

                            def determine_completed_count
                              source_view do |from|
                                from.todo do
                                  @completed_count = current_user.todos.not_hidden.completed.count
                                end
                          Severity: Minor
                          Found in app/controllers/todos_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 determine_down_count has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            def determine_down_count
                              source_view do |from|
                                from.todo do
                                  @down_count = current_user.todos.active.not_hidden.count
                                end
                          Severity: Minor
                          Found in app/controllers/todos_controller.rb - About 1 hr to fix

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

                              def add_predecessor
                                @source_view = params['_source_view'] || 'todo'
                                @predecessor = current_user.todos.find(params['predecessor'])
                                @predecessors = @predecessor.predecessors
                                @todo = current_user.todos.includes(Todo::DEFAULT_INCLUDES).find(params['successor'])
                            Severity: Minor
                            Found in app/controllers/todos_controller.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 update_project has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                            Open

                              def update_project
                                @project_changed = false;
                                if params['todo']['project_id'].blank? && !params['project_name'].nil?
                                  if params['project_name'] == 'None'
                                    project = Project.null_object
                            Severity: Minor
                            Found in app/controllers/todos_controller.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 initialize has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                            Open

                                def initialize(params, prefs)
                                  @params = params['request'] || params
                                  @prefs = prefs
                                  @attributes = params['request'] && params['request']['todo']  || params['todo']
                            
                            
                            Severity: Minor
                            Found in app/controllers/todos_controller.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 find_todos_with_tag_expr has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                            Open

                              def find_todos_with_tag_expr(tag_expr)
                                # optimize for the common case: selecting only one tag
                                if @single_tag
                                  tag = Tag.where(:name => @tag_name).first
                                  tag_id = tag.nil? ? -1 : tag.id
                            Severity: Minor
                            Found in app/controllers/todos_controller.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 tag has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                            Open

                              def tag
                                get_params_for_tag_view
                                @page_title = t('todos.tagged_page_title', :tag_name => @tag_title)
                                @source_view = params['_source_view'] || 'tag'
                            
                            
                            Severity: Minor
                            Found in app/controllers/todos_controller.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

                            Method update_dependency_state has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                            Open

                              def update_dependency_state
                                # assumes @todo.save was called so that the predecessor_list is persistent
                                if @original_item_predecessor_list != params[:predecessor_list]
                                  # Possible state change with new dependencies
                                  if @todo.uncompleted_predecessors.empty?
                            Severity: Minor
                            Found in app/controllers/todos_controller.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

                            Method update_due_and_show_from_dates has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                            Open

                              def update_due_and_show_from_dates
                                if params["todo"].has_key?("due")
                                  begin
                                    params["todo"]["due"] = parse_date_per_user_prefs(params["todo"]["due"])
                                  rescue
                            Severity: Minor
                            Found in app/controllers/todos_controller.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

                            Avoid too many return statements within this method.
                            Open

                                  return current_user.todos.not_completed.where('todos.due > ?', due_this_month_date).count
                            Severity: Major
                            Found in app/controllers/todos_controller.rb - About 30 mins to fix

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

                                def get_due_id_for_calendar(due)
                                  return "" if due.nil?
                                  due_today_date = Time.zone.now
                                  due_this_week_date = Time.zone.now.end_of_week
                                  due_next_week_date = due_this_week_date + 7.days
                              Severity: Minor
                              Found in app/controllers/todos_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

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

                                    elsif !(p.context_id.nil? || p.context_id.blank?)
                                      context = current_user.contexts.where(:id=>p.context_id).first
                                      @todo.errors[:context] << "unknown" if context.nil?
                              Severity: Minor
                              Found in app/controllers/todos_controller.rb and 1 other location - About 20 mins to fix
                              app/controllers/todos_controller.rb on lines 126..128

                              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 28.

                              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

                                    elsif !(p.project_id.nil? || p.project_id.blank?)
                                      project = current_user.projects.where(:id => p.project_id).first
                                      @todo.errors[:project] << "unknown" if project.nil?
                              Severity: Minor
                              Found in app/controllers/todos_controller.rb and 1 other location - About 20 mins to fix
                              app/controllers/todos_controller.rb on lines 136..138

                              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 28.

                              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

                              There are no issues that match your filters.

                              Category
                              Status