YaleSTC/shifts

View on GitHub

Showing 182 of 294 total issues

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

  def create
    @link = Link.new(params[:link])
        @link.author = current_user
        @link.department = current_department
        @link.url = "http://" << params[:link][:url] if @link.url[0,7] != "http://" && @link.url[0,8] != "https://"
Severity: Minor
Found in app/controllers/links_controller.rb - About 1 hr to fix

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

      def index_prep
        @period_start = params[:date] ? Date.parse(params[:date]).previous_sunday : Date.today.previous_sunday
        # figure out what days to display based on user preferences
        if params[:date].blank? and (current_user.user_config.view_week != "" and current_user.user_config.view_week != "whole_period")
          # only if default view and non-standard setting
    Severity: Minor
    Found in app/controllers/calendars_controller.rb - About 1 hr to fix

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

        def update
          @time_slot = TimeSlot.find(params[:id])
          parse_date_and_time_output(params[:time_slot])
          join_date_and_time(params[:time_slot])
          # if it was after midnight to begin with, then there is a problem... why?
      Severity: Minor
      Found in app/controllers/time_slots_controller.rb - About 1 hr to fix

        Method create has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def create
            set_payform_item_hours("payform_item_set")
            @payform_item_set = PayformItemSet.new(params[:payform_item_set])
            @payform_item_set.active = true #TODO: set this as a default in the database
            date = build_date_from_params(:date, params[:payform_item_set])
        Severity: Minor
        Found in app/controllers/payform_item_sets_controller.rb - About 1 hr to fix

          Method index has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def index
              if params[:shift_id]      # check if index listing is shift specific
                @shift=Shift.find(params[:shift_id])
                @subs=@shift.sub_requests
                @title_add=" for " + @shift.user.name + "'s shift in " + @shift.location.name + " on " + @shift.start.to_s(:gg)
          Severity: Minor
          Found in app/controllers/sub_requests_controller.rb - About 1 hr to fix

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

              def self.import(file)
                results = {successes: [], failures: []}
                CSV.foreach(file.path, headers: true) do |row|
                  attrs = row.to_hash
            
            
            Severity: Minor
            Found in app/models/user.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 toggle has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

              def toggle
                @calendar = Calendar.find(params[:id])
                if params[:wipe]
                  wipe = true
                else
            Severity: Minor
            Found in app/controllers/calendars_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 is_staffed_in_list? has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

              def is_staffed_in_list?(shift_list, time)
                time = time.in_time_zone
                remaining_shifts = shift_list.select{|s| s.start <= time && (s.submitted? ? s.report.departed : s.end) >= time && !s.missed? && (s.start + s.department.department_config.grace_period.minutes <= Time.now ? (s.signed_in? || s.submitted?) : true)}
                return remaining_shifts == [] ? false : true
              end
            Severity: Minor
            Found in app/models/location.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 calculate_default_times_requested_shifts has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

              def calculate_default_times_requested_shifts
                if params[:xPercentage]
                  @requested_shift.preferred_start ||= Date.today
                  @dept_start_minutes ||= current_department.department_config.schedule_start
                  @dept_end_minutes ||= current_department.department_config.schedule_end
            Severity: Minor
            Found in app/helpers/requested_shifts_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 create_from_existing_event has 27 lines of code (exceeds 25 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 1 hr to fix

              Method delete_part_of_shift has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def self.delete_part_of_shift(shift, start_of_delete, end_of_delete)
                  #Used for taking sub requests
                  if !(start_of_delete.between?(shift.start, shift.end) && end_of_delete.between?(shift.start, shift.end))
                    raise "You can\'t delete more than the entire shift"
                  elsif start_of_delete >= end_of_delete
              Severity: Minor
              Found in app/models/shift.rb - About 1 hr to fix

                Method autocomplete has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def autocomplete
                    @list = []
                    classes = params[:classes] || ["User", "Department", "Role"]
                
                    if classes.include?("User")
                Severity: Minor
                Found in app/controllers/users_controller.rb - About 1 hr to fix

                  Method create has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def create
                          parse_just_time(params[:template_time_slot])
                  
                          @week_template = Template.find(params[:template_id])
                          @template_time_slots = @week_template.template_time_slots
                  Severity: Minor
                  Found in app/controllers/template_time_slots_controller.rb - About 1 hr to fix

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

                      def update
                        @announcement = Announcement.find(params[:id]) || Announcement.new
                        parse_date_and_time_output(params[:announcement])
                        join_date_and_time(params[:announcement])
                            @announcement.update_attributes(params[:announcement])
                    Severity: Minor
                    Found in app/controllers/announcements_controller.rb - About 1 hr to fix

                      Method detailed_stats has 26 lines of code (exceeds 25 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/location.rb - About 1 hr to fix

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

                          def self.import(file)
                            results = {successes: [], failures: []}
                            CSV.foreach(file.path, headers: true) do |row|
                              attrs = row.to_hash
                        
                        
                        Severity: Minor
                        Found in app/models/user.rb - About 1 hr to fix

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

                            def update
                          
                              if params[:loc]
                                params[:user_config][:view_loc_groups] = params[:loc].keys.join(", ")
                              end
                          Severity: Minor
                          Found in app/controllers/user_configs_controller.rb - About 1 hr to fix

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

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

                                def grab
                                  begin
                                    @token_array = resolve_token(params[:token], params[:user_id])
                                    @user = User.find(params[:user_id])
                                  rescue Exception => e
                              Severity: Minor
                              Found in app/controllers/calendar_feeds_controller.rb - About 1 hr to fix

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

                                  def after_create(department)
                                    DepartmentConfig.create!({department_id: department.id,
                                                        schedule_start: 9*60,
                                                        schedule_end: 17*60,
                                                        time_increment: 15,
                                Severity: Minor
                                Found in app/models/department_observer.rb - About 1 hr to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language