JumpstartLab/tracks

View on GitHub

Showing 244 of 244 total issues

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

        $(document).on("click",".item-container a.icon_delete_item", function(evt){
            var confirm_message = $(this).attr("x_confirm_message")
            if(confirm(confirm_message)){
                delete_with_ajax_and_block_element(this.href, $(this).parents('.item-container'));
            }
Severity: Major
Found in app/assets/javascripts/tracks.js and 3 other locations - About 2 hrs to fix
app/assets/javascripts/tracks.js on lines 707..713
app/assets/javascripts/tracks.js on lines 725..731
app/assets/javascripts/tracks.js on lines 823..829

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

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

      def due_date(due)
        return "" if due.nil?
    
        days = days_from_today(due)
    
    
    Severity: Minor
    Found in app/helpers/application_helper.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 _add_tags has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

          def _add_tags incoming
            tag_cast_to_string(incoming).each do |tag_name|
              # added following check to prevent empty tags from being saved (which will fail)
              unless tag_name.blank?
                begin
    Severity: Minor
    Found in lib/is_taggable.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

    Function setup_behavior has 60 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        setup_behavior: function() {
            /* in-place edit of project name */
            $('div#project_name').editable(ProjectListPage.save_project_name, {
                style: 'padding: 0px; width=100%;',
                submit: i18n['common.ok'],
    Severity: Major
    Found in app/assets/javascripts/tracks.js - About 2 hrs to fix

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

              $(document).on("click",'a.delete_user_button', function(evt){
                  var confirm_message = $(this).attr("x_confirm_message")
                  if(confirm(confirm_message)){
                      delete_with_ajax_and_block_element(this.href, $(this).parents('.project'));
                  }
      Severity: Major
      Found in app/assets/javascripts/tracks.js and 1 other location - About 2 hrs to fix
      app/assets/javascripts/tracks.js on lines 1047..1053

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

      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

            $(document).on("click",'.item-container a.delete_icon', function(evt){
                var confirm_message = $(this).attr("x_confirm_message")
                if(confirm(confirm_message)){
                    delete_with_ajax_and_block_element(this.href, $(this).parents('.project'));
                  }
      Severity: Major
      Found in app/assets/javascripts/tracks.js and 1 other location - About 2 hrs to fix
      app/assets/javascripts/tracks.js on lines 612..618

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

      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

      Consider simplifying this complex logical expression.
      Open

          return (@remaining_in_context == 0 && (@todo_hidden_state_changed && @todo.hidden?)) ||
            (@remaining_in_context == 0 && @todo_was_deferred_from_active_state) ||
            (@remaining_in_context == 0 && @tag_was_removed) ||
            (@remaining_in_context == 0 && @todo.completed? && !(@original_item_was_deferred || @original_item_was_hidden)) if source_view_is(:tag)
      Severity: Critical
      Found in app/helpers/todos_helper.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

          Function setup_behavior has 57 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              setup_behavior: function() {
                  /* show the notes of a todo */
                  $(document).on("click",".show_notes", function () {
                      $(this).next().toggle("fast");
                      return false;
          Severity: Major
          Found in app/assets/javascripts/tracks.js - About 2 hrs to fix

            Method empty_container_msg_div_id has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
            Open

              def empty_container_msg_div_id(todo = @todo || @successor)
                raise Exception.new, "no @todo or @successor set" if !todo
            
                source_view do |page|
                  page.project  {
            Severity: Minor
            Found in app/helpers/todos_helper.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 get_weekly_date has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

              def get_weekly_date(previous)
                # determine start
                if previous == nil
                  start = self.start_from.nil? ? Time.zone.now : self.start_from
                else
            Severity: Minor
            Found in app/models/recurring_todo.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 login has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

              def login
                @page_title = "TRACKS::Login"
                cookies[:preferred_auth] = prefered_auth? unless cookies[:preferred_auth]
                case request.method
                when 'POST'
            Severity: Minor
            Found in app/controllers/login_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 16 (exceeds 5 allowed). Consider refactoring.
            Open

              def update
                # TODO: write tests for updating
                @recurring_todo.tag_with(params[:edit_recurring_todo_tag_list]) if params[:edit_recurring_todo_tag_list]
                @original_item_context_id = @recurring_todo.context_id
                @original_item_project_id = @recurring_todo.project_id
            Severity: Minor
            Found in app/controllers/recurring_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 post has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

                def post(lines, options = {})
                  uri = URI.parse(GTD_URI)
                  http = Net::HTTP.new(uri.host, uri.port)
            
                  if uri.scheme == "https"  # enable SSL/TLS
            Severity: Minor
            Found in doc/tracks_cli_client.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 csv_actions has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

              def csv_actions
                content_type = 'text/csv'
                CSV::Writer.generate(result = "") do |csv|
                  csv << ["id", "Context", "Project", "Description", "Notes", "Tags",
                    "Created at", "Due", "Completed at", "User ID", "Show from",
            Severity: Minor
            Found in app/controllers/data_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 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 update has 50 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def update
                  template = ""
              
                  params['project'] ||= {}
                  if params['project']['state']
              Severity: Minor
              Found in app/controllers/projects_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 index has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def index
                      @source_view = params['_source_view'] || 'project_list'
                      if params[:projects_and_actions]
                        projects_and_actions
                      else
                  Severity: Minor
                  Found in app/controllers/projects_controller.rb - About 1 hr to fix
                    Severity
                    Category
                    Status
                    Source
                    Language