YaleSTC/shifts

View on GitHub

Showing 294 of 294 total issues

Method day_preprocessing has 70 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def day_preprocessing(day)
    @location_rows = {}

    #for AJAX; needs cleanup if we have time
    @loc_groups = current_user.user_config.view_loc_groups.select{|l| !l.locations.empty?}
Severity: Major
Found in app/helpers/shifts_helper.rb - About 2 hrs to fix

    Method update has a Cognitive Complexity of 20 (exceeds 5 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 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 parse_date_and_time_output has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

      def parse_date_and_time_output(form_output)
            time_attribute_names = ["start", "end", "mandatory_start", "mandatory_end"]
        time_attribute_names.each do |field_name|
    
          unless form_output["#{field_name}_time(5i)"].blank? || form_output["#{field_name}_time(4i)"].blank?
    Severity: Minor
    Found in app/controllers/application_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 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

      Identical blocks of code found in 2 locations. 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: Major
      Found in app/models/location.rb and 1 other location - About 2 hrs to fix
      app/models/user.rb on lines 303..342

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 98.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Identical blocks of code found in 2 locations. 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: Major
      Found in app/models/user.rb and 1 other location - About 2 hrs to fix
      app/models/location.rb on lines 121..150

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 98.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      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 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

      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

      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 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
              @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
              #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

          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

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

            def time_slot_style(time_slot, time_slot_day)
              @right_overflow = @left_overflow = false
              #not DRY, thrown in for AJAX reasons for now. sorry :( -ryan
              @dept_start_hour ||= current_department.department_config.schedule_start / 60
              @dept_end_hour ||= current_department.department_config.schedule_end / 60
          Severity: Major
          Found in app/helpers/time_slots_helper.rb and 1 other location - About 2 hrs to fix
          app/helpers/calendars_helper.rb on lines 32..51

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 88.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

            def time_slot_style(time_slot, time_slot_day)
              @right_overflow = @left_overflow = false
              #not DRY, thrown in for AJAX reasons for now. sorry :( -ryan
              @dept_start_hour ||= current_department.department_config.schedule_start / 60
              @dept_end_hour ||= current_department.department_config.schedule_end / 60
          Severity: Major
          Found in app/helpers/calendars_helper.rb and 1 other location - About 2 hrs to fix
          app/helpers/time_slots_helper.rb on lines 3..22

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 88.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          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

            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
              Severity
              Category
              Status
              Source
              Language