YaleSTC/shifts

View on GitHub

Showing 182 of 294 total issues

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

  def update
    @sub_request = SubRequest.find(params[:id])
    return unless user_is_owner_or_admin_of(@sub_request.shift, current_department)
    begin
      SubRequest.transaction do
Severity: Minor
Found in app/controllers/sub_requests_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 detailed_stats has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def detailed_stats(start_date, end_date)
    shifts_set = shifts.on_days(start_date, end_date).active
    detailed_stats = {}

    shifts_set.each do |s|
Severity: Minor
Found in app/models/user.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 search has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def search
    users = current_department.active_users
    start_date = interpret_start
    end_date = interpret_end
    #filter results if we are searching
Severity: Minor
Found in app/controllers/payforms_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 check_for_conflicts has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def self.check_for_conflicts(time_slots, wipe, time_slot_scope)
    return "" if time_slots.empty?
    table = TimeSlot.arel_table
    time_slots_with_conflict = Array.new
    time_slots.each_slice(450) do |tss|
Severity: Minor
Found in app/models/time_slot.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 narrow_down has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def narrow_down(payforms)
    if ( !params[:unsubmitted] and !params[:submitted] and !params[:approved] and !params[:skipped] and !params[:printed]  )
      params[:unsubmitted] = params[:submitted] = params[:approved] = true
    end
    scope = []
Severity: Minor
Found in app/controllers/payforms_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 ["user_profile_entries[#{id}]", :content, options.map{|opt| [opt, opt]}, {selected: content}]
Severity: Major
Found in app/models/user_profile_entry.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 options.map{|v| ["data_fields[#{id}]", 1, v]}
        Severity: Major
        Found in app/models/data_field.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                return "Future"
          Severity: Major
          Found in app/models/shift.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 "Completed"
              Severity: Major
              Found in app/models/shift.rb - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                        return options.map{|v| ["user_profile_entries[#{id}]", v]}
                Severity: Major
                Found in app/models/user_profile_entry.rb - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                          return options.map{|v| ["user_profile_entries[#{id}]", v, chosen.include?(v) ? {checked: true} : {}]}
                  Severity: Major
                  Found in app/models/user_profile_entry.rb - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                          return options.map{|v| ["user_profile_entries[#{id}]", :content, v, content==v ? {checked: true} : {}]}
                    Severity: Major
                    Found in app/models/user_profile_entry.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

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

                            def no_concurrent_timeslots
                              dont_conflict_with_self = (self.new_record? ? "" : "AND id != #{self.id}")
                          
                              if self.calendar.active
                                c = TimeSlot.where("start < ? AND end > ? AND location_id = ? AND active = ? #{dont_conflict_with_self}", self.end, self.start, self.location, true).count
                          Severity: Minor
                          Found in app/models/time_slot.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

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

                            def create
                              parse_date_and_time_output(params[:sub_request])
                              join_date_and_time(params[:sub_request])
                              @sub_request = SubRequest.new(params[:sub_request])
                              @sub_request.shift = Shift.find(params[:shift_id])
                          Severity: Minor
                          Found in app/controllers/sub_requests_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

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

                            def submit
                              @payform = Payform.find(params[:id])
                              return unless user_is_owner_or_admin_of(@payform, @payform.department)
                              @payform.submitted = Time.now
                          
                          
                          Severity: Minor
                          Found in app/controllers/payforms_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

                          Severity
                          Category
                          Status
                          Source
                          Language