YaleSTC/shifts

View on GitHub

Showing 182 of 294 total issues

Method calendar_day_preprocessing has 68 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def calendar_day_preprocessing(day)
    @location_rows = {}
    @location_rows_timeslots = {}

    #different calendars are different colors
Severity: Major
Found in app/helpers/shifts_helper.rb - About 2 hrs to fix

    Method take has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.take(sub_request, user, just_mandatory)
        if sub_request.user_is_eligible?(user)
            SubRequest.transaction do
              old_shift = sub_request.shift
              owner = old_shift.user
    Severity: Minor
    Found in app/models/sub_request.rb - About 2 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

    Method restrictions has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

      def restrictions
        unless self.power_signed_up
          errors.add(:user, "is required") and return if self.user.nil?
          self.user.restrictions.each do |restriction|
            if restriction.max_hours
    Severity: Minor
    Found in app/models/shift.rb - About 2 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

    Method index has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

      def index
        @start_date = interpret_start
        @end_date = interpret_end
        @user_stats = {}
        @location_stats = {}
    Severity: Minor
    Found in app/controllers/stats_controller.rb - About 2 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 shifts_helper.rb has 270 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module ShiftsHelper
    
      #WILL BE CHANGED TO SHIFTS:
      def shift_style(shift, after = nil)
        @right_overflow = @left_overflow = false
    Severity: Minor
    Found in app/helpers/shifts_helper.rb - About 2 hrs to fix

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

        def index
          @start_date = interpret_start
          @end_date = interpret_end
          @user_stats = {}
          @location_stats = {}
      Severity: Major
      Found in app/controllers/stats_controller.rb - About 2 hrs to fix

        Method prepare_form_helpers has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

          def prepare_form_helpers
            if display_type == "text_field"
              return ["user_profile_entries[#{id}]", :content, {value: content}]
            elsif display_type == "picture_link"
              return ["user_profile_entries[#{id}]", :content, {value: content}]
        Severity: Minor
        Found in app/models/user_profile_entry.rb - About 2 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

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

          def update
            @report = Report.find(params[:id])
            return unless user_is_owner_or_admin_of(@report.shift, @report.shift.department) || current_user.is_admin_of?(@report.shift.location)
        
            if (params[:sign_out] and @report.departed.nil?) #don't allow duplicate signout messages
        Severity: Minor
        Found in app/controllers/reports_controller.rb - About 2 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

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

          def create
            parse_date_and_time_output(params[:shift])
            join_date_and_time(params[:shift])
            @shift = Shift.new(params[:shift])
            @shift.department = @shift.location.department
        Severity: Minor
        Found in app/controllers/shifts_controller.rb - About 2 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

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

          def update
            @old_repeating_event = RepeatingEvent.find(params[:id])
            parse_date_and_time_output(params[:repeating_event])
            params[:repeating_event][:days] = params[:days]
            if params[:repeating_event][:slot_or_shift] == "time_slot"
        Severity: Minor
        Found in app/controllers/repeating_events_controller.rb - About 2 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

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

          def create
            #TODO: persistent calendar selection? it would be nice...
            parse_date_and_time_output(params[:repeating_event])
            session[:calendar] = params[:repeating_event][:calendar_id]
            params[:repeating_event][:days] = params[:days]
        Severity: Minor
        Found in app/controllers/repeating_events_controller.rb - About 2 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

        Class RepeatingEvent has 22 methods (exceeds 20 allowed). Consider refactoring.
        Open

        class RepeatingEvent < ActiveRecord::Base
          belongs_to :calendar
          has_many :time_slots
          has_many :shifts
          validate :loc_ids_present
        Severity: Minor
        Found in app/models/repeating_event.rb - About 2 hrs to fix

          Function initialize has 58 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function initialize(element) {
          
            $(element+' td.click_to_show').click(function (e) {
              popup_show($(this), e);
              return false;
          Severity: Major
          Found in app/assets/javascripts/tooltip.js - About 2 hrs to fix

            Method location_preprocessing has 58 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def location_preprocessing(location, day)
                timeslots = @location_rows_timeslots[location]
                shifts = @location_rows[location].flatten
            
                #what times is this location open?
            Severity: Major
            Found in app/helpers/shifts_helper.rb - About 2 hrs to fix

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

                def update
                  @punch_clock = PunchClock.find(params[:id])
                  return unless user_is_owner_or_admin_of(@punch_clock, @punch_clock.department)
                  if params[:pause]
                    message = @punch_clock.pause || "Successfully paused punch clock."
              Severity: Minor
              Found in app/controllers/punch_clocks_controller.rb - About 2 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 users_controller.rb has 254 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              class UsersController < ApplicationController
                before_filter :require_admin_or_superuser, except: 'autocomplete'
              
                def index
                  if params[:show_inactive]
              Severity: Minor
              Found in app/controllers/users_controller.rb - About 2 hrs to fix

                Method adjust_sub_requests has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                Open

                  def adjust_sub_requests
                    self.sub_requests.each do |sub|
                      if sub.start > self.end || sub.end < self.start
                        sub.destroy
                      else
                Severity: Minor
                Found in app/models/shift.rb - About 2 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

                Method data_fields_with_contents has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                Open

                  def data_fields_with_contents
                    begin
                      content_arrays = self.content.split(';;').map{|str| str.split('::')}
                      content_arrays.each do |a|
                        if DataField.find_with_destroyed(a.first).display_type == "check_box"
                Severity: Minor
                Found in app/models/data_entry.rb - About 2 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

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

                  def create
                    parse_date_and_time_output(params[:shift])
                    join_date_and_time(params[:shift])
                    @shift = Shift.new(params[:shift])
                    @shift.department = @shift.location.department
                Severity: Minor
                Found in app/controllers/shifts_controller.rb - About 1 hr to fix

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

                    def combine_with_surrounding_shifts
                      if (shift_later = Shift.where("start = ? AND user_id = ? AND location_id = ? AND calendars.active = ?", self.end, self.user_id, self.location_id, self.calendar.active?).includes(:calendar).first) && (!shift_later.has_sub?)
                            if (self.report.nil? || self.report.departed.nil?) && (shift_later.report.nil?)
                              self.end = shift_later.end
                              shift_later.sub_requests.each { |s| s.shift = self }
                  Severity: Minor
                  Found in app/models/shift.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

                  Severity
                  Category
                  Status
                  Source
                  Language