JumpstartLab/tracks

View on GitHub

Showing 244 of 244 total issues

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

var ProjectItems = {
    setup_autocomplete_for_projects: function(id) {
        $(id).autocomplete({
            source: relative_to_root('projects.autocomplete'),
            autoFocus: true,
Severity: Major
Found in app/assets/javascripts/tracks.js and 1 other location - About 1 hr to fix
app/assets/javascripts/tracks.js on lines 587..596

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

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

      def validate_monthly
        case recurrence_selector
        when 0 # 'monthly_every_x_day'
          errors[:base] << "The day of the month may not be empty for recurrence setting" if monthly_every_x_day.blank?
          errors[:base] << "Every other nth month may not be empty for recurrence setting" if monthly_every_x_month.blank?
    Severity: Minor
    Found in app/models/recurring_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 get_yearly_date has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

      def get_yearly_date(previous)
        start = determine_start(previous)
        day = self.every_other1
        month = self.every_other2
    
    
    Severity: Minor
    Found in app/models/recurring_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 should_show_new_item has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

      def should_show_new_item
        source_view do |page|
          page.todo { return !@todo.hidden? }
          page.deferred { return @todo.deferred? || @todo.pending? }
          page.context {
    Severity: Minor
    Found in app/helpers/todos_helper.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_needs_to_hide_context has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

      def update_needs_to_hide_context
        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: Minor
    Found in app/helpers/todos_helper.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 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 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 validate_yearly has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

      def validate_yearly
        case recurrence_selector
        when 0 # 'yearly_every_x_day'
          errors[:base] << "The month of the year may not be empty for recurrence setting" if yearly_month_of_year.blank?
          errors[:base] << "The day of the month may not be empty for recurrence setting" if yearly_every_x_day.blank?
    Severity: Minor
    Found in app/models/recurring_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 set_session_expiration has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

      def set_session_expiration
        # http://wiki.rubyonrails.com/rails/show/HowtoChangeSessionOptions
        unless session == nil
          return if self.controller_name == 'feed' or session['noexpiry'] == "on"
          # If the method is called by the feed controller (which we don't have
    Severity: Minor
    Found in app/controllers/application_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 initialize has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def initialize
          @options = {}
          @keywords = {}
    
          @parser = OptionParser.new do |cmd|
    Severity: Minor
    Found in doc/tracks_template_cli.rb - About 1 hr to fix

      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 due_date has 30 lines of code (exceeds 25 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 1 hr to fix

          Method login has 30 lines of code (exceeds 25 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 1 hr to fix

            Method post has 29 lines of code (exceeds 25 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 1 hr to fix

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

                      $('#toggle_context_new').click(function(evt){
                          TracksForm.toggle('toggle_context_new', 'context_new', 'context-form',
                              i18n['contexts.hide_form'], i18n['contexts.hide_form_title'],
                              i18n['contexts.show_form'], i18n['contexts.show_form_title']);
                      });
              Severity: Major
              Found in app/assets/javascripts/tracks.js and 1 other location - About 1 hr to fix
              app/assets/javascripts/tracks.js on lines 764..768

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

              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

                      close: function() {
                        $('#recurring-todo-form-new-action input:text:first').focus();
                        RecurringTodosPage.hide_all_recurring();
                        RecurringTodosPage.reset_radio();
                        $('#recurring_daily').show();
              Severity: Major
              Found in app/assets/javascripts/tracks.js and 1 other location - About 1 hr to fix
              app/assets/javascripts/tracks.js on lines 1026..1031

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

              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

                      $('#toggle_project_new').click(function(evt){
                          TracksForm.toggle('toggle_project_new', 'project_new', 'project-form',
                              i18n['projects.hide_form'], i18n['projects.hide_form_title'],
                              i18n['projects.show_form'], i18n['projects.show_form_title']);
                      });
              Severity: Major
              Found in app/assets/javascripts/tracks.js and 1 other location - About 1 hr to fix
              app/assets/javascripts/tracks.js on lines 850..854

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

              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

                      close: function() {
                        $('#recurring-todo-form-edit-action input:text:first').focus();
                        RecurringTodosPage.hide_all_recurring();
                        RecurringTodosPage.reset_radio();
                        $('#recurring_daily').show();
              Severity: Major
              Found in app/assets/javascripts/tracks.js and 1 other location - About 1 hr to fix
              app/assets/javascripts/tracks.js on lines 993..998

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

              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

              Function project_defaults has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

              function project_defaults(){
                  if($('body').hasClass('contexts')){
                  // don't change the context
                  // see ticket #934
                  } else {
              Severity: Minor
              Found in app/assets/javascripts/tracks.js - 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

              Severity
              Category
              Status
              Source
              Language