ari/jobsworth

View on GitHub
app/helpers/tasks_helper.rb

Summary

Maintainability
D
2 days
Test Coverage

Method render_task_dependants has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
Open

  def render_task_dependants(t, depth, root_present)
    res = ''
    @printed_ids ||= []

    return if @printed_ids.include? t.id
Severity: Minor
Found in app/helpers/tasks_helper.rb - About 6 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

File tasks_helper.rb has 294 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module TasksHelper
  def render_task_form(show_timer = true)
    render partial: 'tasks/form', locals: {show_timer: show_timer}
  end

Severity: Minor
Found in app/helpers/tasks_helper.rb - About 3 hrs to fix

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

      def milestones_to_select_tag(milestones)
        options = [%Q[<option value="0" title="#{t('forms.select.please_select')}">#{t('forms.select.none')}</option>]] + milestones.collect do |milestone|
          date = milestone.due_at.nil? ? t('shared.not_set') : l(milestone.due_at, format: current_user.date_format)
    
          selected = if (@task.milestone_id == milestone.id) || (@task.milestone_id.nil? && milestone.id == '0')
    Severity: Minor
    Found in app/helpers/tasks_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 render_task_dependants has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def render_task_dependants(t, depth, root_present)
        res = ''
        @printed_ids ||= []
    
        return if @printed_ids.include? t.id
    Severity: Minor
    Found in app/helpers/tasks_helper.rb - About 1 hr to fix

      Method human_future_date has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def human_future_date(date, tz)
          return t('shared.unknown') unless date
      
          tz_day_end = tz.now.end_of_day
          local_date = tz.utc_to_local(date.utc)
      Severity: Minor
      Found in app/helpers/tasks_helper.rb - About 1 hr to fix

        Method due_date_field has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

          def due_date_field(task, permissions)
            task_due_at = task.due_at.nil? ? '' : task.due_at.utc.strftime(current_user.date_format)
            milestone_due_at = task.milestone.try(:due_at)
            placeholder = milestone_due_at.nil? ? '' : milestone_due_at.strftime(current_user.date_format)
            date_tooltip = if task.due_at.nil? && !milestone_due_at.nil?
        Severity: Minor
        Found in app/helpers/tasks_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 due_date_field has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def due_date_field(task, permissions)
            task_due_at = task.due_at.nil? ? '' : task.due_at.utc.strftime(current_user.date_format)
            milestone_due_at = task.milestone.try(:due_at)
            placeholder = milestone_due_at.nil? ? '' : milestone_due_at.strftime(current_user.date_format)
            date_tooltip = if task.due_at.nil? && !milestone_due_at.nil?
        Severity: Minor
        Found in app/helpers/tasks_helper.rb - About 1 hr to fix

          Method milestones_to_select_tag has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def milestones_to_select_tag(milestones)
              options = [%Q[<option value="0" title="#{t('forms.select.please_select')}">#{t('forms.select.none')}</option>]] + milestones.collect do |milestone|
                date = milestone.due_at.nil? ? t('shared.not_set') : l(milestone.due_at, format: current_user.date_format)
          
                selected = if (@task.milestone_id == milestone.id) || (@task.milestone_id.nil? && milestone.id == '0')
          Severity: Minor
          Found in app/helpers/tasks_helper.rb - About 1 hr to fix

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

              def options_for_task_services(customers, task)
                services = []
                customers.each { |c| services.concat(c.services.all) }
                services = services.uniq
            
            
            Severity: Minor
            Found in app/helpers/tasks_helper.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 task_detail has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def task_detail(task, user = current_user)
                task.due_at ||= task.milestone.due_at if task.milestone
                options = {
                    task.human_name(:status) => task.human_value(:open_or_closed),
                    task.human_name(:project) => task.project.name,
            Severity: Minor
            Found in app/helpers/tasks_helper.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 perms has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def perms
                if @perms.nil?
                  @perms = {}
                  permissions = ['comment', 'edit', 'reassign', 'close', 'milestone']
                  permissions.each do |p|
            Severity: Minor
            Found in app/helpers/tasks_helper.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