YaleSTC/shifts

View on GitHub
app/models/task.rb

Summary

Maintainability
B
6 hrs
Test Coverage

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

  def needs_doing
    @last_completion = ShiftsTask.find_all_by_task_id(self.id).select{|st| st.task_id == self.id}.last #use find method
    if @last_completion
      hours_since = (Time.now - @last_completion.created_at)/3600
      hours_since_scheduled = (Time.now)
Severity: Minor
Found in app/models/task.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 missed has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def missed
    @last_completion = ShiftsTask.find_all_by_task_id(self.id).select{|st| st.task_id == self.id}.last #use find method
    if @last_completion
      hours_since = (Time.now - @last_completion.created_at)/3600
      hours_since_scheduled = (Time.now)
Severity: Minor
Found in app/models/task.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 done has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def done
    @last_completion = ShiftsTask.find_all_by_task_id(self.id).select{|st| st.task_id == self.id}.last #use find method
    if @last_completion
      if (self.kind == "Hourly") && completed_this_hour?(@last_completion) && completed_today?(@last_completion)
        return true
Severity: Minor
Found in app/models/task.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 missed_between has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def missed_between(start_date, end_date)
    completed_shifts_task = ShiftsTask.find_all_by_task_id(self.id).select{|st| (st.created_at >= start_date) && (st.created_at <= end_date) && !st.missed}
    shifts_at_location = Shift.find_all_by_location_id(self.location_id).select{|s| (s.start >= start_date) && (s.start <= end_date) && (s.submitted?)}

    missed_shifts_tasks_slots = []
Severity: Minor
Found in app/models/task.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 false
Severity: Major
Found in app/models/task.rb - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

          return false
    Severity: Major
    Found in app/models/task.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

            return false
      Severity: Major
      Found in app/models/task.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

              return false
        Severity: Major
        Found in app/models/task.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                  return false
          Severity: Major
          Found in app/models/task.rb - About 30 mins to fix

            There are no issues that match your filters.

            Category
            Status