YaleSTC/shifts

View on GitHub

Showing 182 of 294 total issues

Avoid deeply nested control flow statements.
Open

          if @payform_item.save
            flash[:notice] = "Successfully updated payform."
            if p[:url]
              # SUCCESS!!!
              session[:external] = nil
Severity: Major
Found in app/controllers/hooks_controller.rb - About 45 mins to fix

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

      def take
        @sub_request = SubRequest.find(params[:id])
        return unless require_department_membership(@sub_request.shift.department)
        #The form returns string values of "true" or "false", we must convert these to boolean
        just_mandatory = params[:sub_request][:mandatory_start] == "true" ? true : false
    Severity: Minor
    Found in app/controllers/sub_requests_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 default_period_date has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.default_period_date(given_date, dept)
        if dept.department_config.monthly
          given_date_day = given_date.mday
          if dept.department_config.end_of_month
            dept.department_config.day = given_date.end_of_month
    Severity: Minor
    Found in app/models/payform.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 shift_is_within_time_slot has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def shift_is_within_time_slot
        unless self.power_signed_up
          if (self.calendar.default || self.calendar.active)
            c = TimeSlot.where("location_id = ? AND start <= ? AND end >= ? AND active  = ?", self.location_id, self.start, self.end, true).count
          else
    Severity: Minor
    Found in app/models/shift.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 set_sources has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def set_sources(notice)
        if params[:department_wide_locations] && current_user.is_admin_of?(current_department)
          notice.department_wide = true
          notice.save!
        end
    Severity: Minor
    Found in app/controllers/notices_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 css_class has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def css_class(current_user = nil)
        if current_user and self.user == current_user
          css_class = "user"
        else
          css_class = "shift"
    Severity: Minor
    Found in app/models/shift.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
        @task = Task.new(params[:task])
    
        respond_to do |format|
          if @task.save
    Severity: Minor
    Found in app/controllers/tasks_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 payform_skip_button has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def payform_skip_button
        if @payform.submitted and !@payform.approved and !@payform.printed
          if current_user.is_admin_of?(@payform.department)
             if !@payform.skipped
               link_to "<span><strong>Skip and go to next</strong></span>".html_safe, skip_payform_path(@payform), class: "button", onclick: "this.blur();"
    Severity: Minor
    Found in app/helpers/payforms_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 set_payform_item_hours has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def set_payform_item_hours(model_name)
        if params[:calculate_hours] == 'user_input'
          params[model_name.to_sym][:hours] = params[:other][:hours].to_f + params[:other][:minutes].to_f/60
        else
          start_params = []
    Severity: Minor
    Found in app/controllers/application_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 writefiles has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def writefiles(delivery_method, mail_settings, auth_settings, using_cas)
        File.rename('config/environment.rb', 'config/environment.rb.backup')
    
        newtext=File.open('config/environment.rb.backup','r').collect.join()
    
    
    Severity: Minor
    Found in setup/gui_setup.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 check_for_conflicts has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.check_for_conflicts(shifts, wipe, shift_scope)
        return "" if shifts.empty?
        table = Shift.arel_table
        shifts_with_conflict = Array.new
        shifts.each_slice(450) do |shs|
    Severity: Minor
    Found in app/models/shift.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 redirect_to_next_payform has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def redirect_to_next_payform
        if Payform.unapproved.unskipped.any?
          payform_source = Payform.unapproved.unskipped
        else
          payform_source = Payform.unapproved
    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 make_future has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.make_future(event, location, wipe)
        cal = event.calendar
        if cal.active 
          shift_scope = Shift.active
        else
    Severity: Minor
    Found in app/models/shift.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 grab has a Cognitive Complexity of 7 (exceeds 5 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 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 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

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

      def self.make_future(event, wipe)
        dates = event.dates_array
        cal = event.calendar
        if cal.active
          time_slot_scope = TimeSlot.active
    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 fetch_timeslots has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def fetch_timeslots(time_slot_day,location)
        result = []
        timeslots = TimeSlot.all(conditions: ['start > ? and start < ? and location_id = ?',time_slot_day.beginning_of_day,time_slot_day.end_of_day,location.id])
        for timeslot in timeslots do
          if ((timeslot.start < timeslot.start.beginning_of_day + @dept_start_hour.hours) &&
    Severity: Minor
    Found in app/helpers/repeating_events_helper.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/location.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

    Function description has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    function description(type)
    {
      var return_value = "";
      if(type == "text_area" || type == "picture_link") return "";
      else
    Severity: Minor
    Found in app/assets/javascripts/user_profile_fields_form.js - 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 index has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def index
        if params[:show_inactive]
          @users = @department.users
        else
          @users = current_department.active_users.sort_by(&:reverse_name)
    Severity: Minor
    Found in app/controllers/users_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

    Severity
    Category
    Status
    Source
    Language