YaleSTC/shifts

View on GitHub

Showing 182 of 294 total issues

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

  def update
    parse_date_and_time_output(params[:shift])
    join_date_and_time(params[:shift])
    @shift = Shift.find(params[:id])
    return unless user_is_owner_or_admin_of(@shift, @shift.department)
Severity: Minor
Found in app/controllers/shifts_controller.rb - About 1 hr to fix

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

      def obeys_signup_priority
    
        return if (self.power_signed_up || !self.scheduled || !self.calendar.active)
    
        #check for all higher-priority locations in this loc group
    Severity: Minor
    Found in app/models/shift.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 fetch_timeslots has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      def fetch_timeslots(time_slot_day,location)
        result = []
        timeslots = TimeSlot.on_48h(time_slot_day).in_location(location).active
        for timeslot in timeslots do
    
    
    Severity: Minor
    Found in app/helpers/time_slots_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 payform_update_button has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      def payform_update_button
        if @payform.submitted
          if current_user.is_admin_of?(@payform.department)
            if @payform.approved && !@payform.printed
              link_to "<span><strong>Print</strong></span>".html_safe, print_payform_path(@payform), class: "button", onclick: "this.blur();"
    Severity: Minor
    Found in app/helpers/payforms_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 type has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      def type
        if self.start <= Time.now
          if self.missed
            return "Missed"
          end
    Severity: Minor
    Found in app/models/shift.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 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 show has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      def show
        @payform = Payform.find(params[:id])
        flash[:error] = "Payform does not exist." unless @payform
        flash[:error] = "The payform (from #{@payform.department.name}) is not in this department (#{current_department.name})." unless @payform.department == current_department
        flash[:warning] = "This payform is for a current/future time period" if @payform.date > Date.today
    Severity: Minor
    Found in app/controllers/payforms_controller.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 create_from_existing_event has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.create_from_existing_event( event )
        if event.calendar.default?
          return false #cannot make repeating events on the default calendar
        else
          repeating_event = RepeatingEvent.new
    Severity: Minor
    Found in app/models/repeating_event.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 copy has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      def copy
        @old_calendar = Calendar.find(params[:id])
        @new_calendar = Calendar.new(params[:calendar])
        @new_calendar.department = @department
        wipe = params[:wipe] ? true : false
    Severity: Minor
    Found in app/controllers/calendars_controller.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 create has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      def create
        @report_item = ReportItem.new(params[:report_item])
        @report_item.time = Time.now
        @report_item.ip_address = request.remote_ip
        @report_item.report = params[:report_id] ? Report.find(params[:report_id]) : Shift.find(params[:shift_id]).report
    Severity: Minor
    Found in app/controllers/report_items_controller.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 exceeds_max_staff? has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      def exceeds_max_staff?
        count = 0
        shifts_in_period = []
        Shift.where(location_id: self.location_id, scheduled: true).each do |shift|
          shifts_in_period << shift if (self.start..self.end).to_a.overlaps((shift.start..shift.end).to_a) && self.end != shift.start && self.start != shift.end
    Severity: Minor
    Found in app/models/shift.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 shift_style has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      def shift_style(shift, after = nil)
        @right_overflow = @left_overflow = false
    
        #necessary for AJAX rerendering
        #we should extract all of this stuff from controllers and here and make a universal shifts helper method -njg
    Severity: Minor
    Found in app/helpers/shifts_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 create has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      def create
        @punch_clock_set = PunchClockSet.new(params[:punch_clock_set])
        @punch_clock_set.department = current_department
        if @punch_clock_set.save
          flash[:notice] = "Mass punch clock was successfully created."
    Severity: Minor
    Found in app/controllers/punch_clock_sets_controller.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 sub_taken_watch has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

      def sub_taken_watch(user, owner, new_shift, email_start, email_end, dept, disp)
    Severity: Major
    Found in app/mailers/user_mailer.rb - About 50 mins to fix

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

        def update
          @payform_item_set = PayformItemSet.find(params[:id])
          set_payform_item_hours("payform_item_set")
          date = build_date_from_params(:date, params[:payform_item_set])
          @new_users = parse_users_autocomplete(params[:auto_ids])
      Severity: Minor
      Found in app/controllers/payform_item_sets_controller.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 create has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def create
          @data_object = DataObject.new(params[:data_object])
          @data_object.data_type_id = params[:data_type_id] if params[:data_type_id]
          return unless check_data_object_admin_permission(@data_object)
          if @data_object.save
      Severity: Minor
      Found in app/controllers/data_objects_controller.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 wipe_range has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

        def self.wipe_range(start_time, end_time, wipe_timeslots, wipe_shifts, loc_ids, cal_ids)
      Severity: Minor
      Found in app/models/calendar.rb - About 45 mins to fix

        Method select_integer has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

          def select_integer (object, column, start, stop, interval = 1, default = nil)
        Severity: Minor
        Found in app/helpers/application_helper.rb - About 45 mins to fix

          Method sort has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            def sort(requested_shifts) #if the refactored view ends up working out, this should be moved to the shifts_helpers
              rows = []
              rejected = requested_shifts.sort_by(&:acceptable_start)
              current_row = 0
              while !rejected.empty?
          Severity: Minor
          Found in app/helpers/templates_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 loc_group_checked_event? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            def loc_group_checked_event?(loc_group, repeating_event)
              checked = true
              current_department.loc_groups.each do |lg|
                if lg == loc_group
                  lg.locations.each do |loc|
          Severity: Minor
          Found in app/helpers/repeating_events_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

          Severity
          Category
          Status
          Source
          Language