YaleSTC/shifts

View on GitHub

Showing 182 of 294 total issues

File shift.rb has 453 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class Shift < ActiveRecord::Base
  include ActionView::Helpers::DateHelper

  delegate :loc_group, to: 'location'
  belongs_to :calendar
Severity: Minor
Found in app/models/shift.rb - About 6 hrs to fix

    Class Shift has 47 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class Shift < ActiveRecord::Base
      include ActionView::Helpers::DateHelper
    
      delegate :loc_group, to: 'location'
      belongs_to :calendar
    Severity: Minor
    Found in app/models/shift.rb - About 6 hrs to fix

      Method calendar_day_preprocessing has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
      Open

        def calendar_day_preprocessing(day)
          @location_rows = {}
          @location_rows_timeslots = {}
      
      
      
      Severity: Minor
      Found in app/helpers/calendars_helper.rb - About 5 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 User has 41 methods (exceeds 20 allowed). Consider refactoring.
      Open

      class User < ActiveRecord::Base
        acts_as_authentic do |options|
          options.maintain_sessions false
        end
      
      
      Severity: Minor
      Found in app/models/user.rb - About 5 hrs to fix

        Method day_preprocessing has a Cognitive Complexity of 34 (exceeds 5 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: Minor
        Found in app/helpers/shifts_helper.rb - About 5 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 location_preprocessing has a Cognitive Complexity of 33 (exceeds 5 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: Minor
        Found in app/helpers/shifts_helper.rb - About 4 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 a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
        Open

          def calendar_day_preprocessing(day)
            @location_rows = {}
            @location_rows_timeslots = {}
        
            #different calendars are different colors
        Severity: Minor
        Found in app/helpers/shifts_helper.rb - About 4 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 save_import has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
        Open

          def save_import
            if params[:commit]=="Cancel"
              redirect_to import_department_users_path(@department) and return
            end
            @users=params[:users_to_import].collect{|i| params[:user][i]}
        Severity: Minor
        Found in app/controllers/users_controller.rb - About 4 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 application_controller.rb has 354 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        class ApplicationController < ActionController::Base
          # almost everything we do is restricted to a department so we always load_department
          # feel free to skip_before_filter when desired
          before_filter :load_app_config
          before_filter :department_chooser
        Severity: Minor
        Found in app/controllers/application_controller.rb - About 4 hrs to fix

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

            def update
              @user_profile = UserProfile.find(params[:id])
              @user_profile.update_attributes(params[:user_profile]) #necessary for profile pics to save
          
              @user = User.find(@user_profile.user_id)
          Severity: Minor
          Found in app/controllers/user_profiles_controller.rb - About 4 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 29 (exceeds 5 allowed). Consider refactoring.
          Open

            def update
              @punch_clock_set = PunchClockSet.find(params[:id])
              messages = []
              @punch_clock_set.punch_clocks.each do |pc|
                if params[:pause]
          Severity: Minor
          Found in app/controllers/punch_clock_sets_controller.rb - About 4 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 ApplicationController has 32 methods (exceeds 20 allowed). Consider refactoring.
          Open

          class ApplicationController < ActionController::Base
            # almost everything we do is restricted to a department so we always load_department
            # feel free to skip_before_filter when desired
            before_filter :load_app_config
            before_filter :department_chooser
          Severity: Minor
          Found in app/controllers/application_controller.rb - About 4 hrs to fix

            Method add_job_after has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
            Open

              def add_job_after
                p = session[:external]
                unless p.blank?
                  #if currently logged in user of RT and Payform are different
                  if current_user.login != p[:netid]
            Severity: Minor
            Found in app/controllers/hooks_controller.rb - About 3 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 25 (exceeds 5 allowed). Consider refactoring.
            Open

              def create
                if @user = User.where(login: params[:user][:login]).first
                  if @user.departments.include? @department #if user is already in this department
                    flash[:notice] = "This user already exists in this department."
                  else
            Severity: Minor
            Found in app/controllers/users_controller.rb - About 3 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 23 (exceeds 5 allowed). Consider refactoring.
            Open

              def update
                #TODO: prevent params hacking w/ regard to setting roles and login and payrate
                params[:user][:role_ids] ||= []
                @user = User.find(params[:id])
                #store role changes, or else they'll overwrite roles in other departments
            Severity: Minor
            Found in app/controllers/users_controller.rb - About 3 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 user.rb has 302 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            require 'net/ldap'
            require 'rails_extensions'
            require 'memoist'
            
            class User < ActiveRecord::Base
            Severity: Minor
            Found in app/models/user.rb - About 3 hrs to fix

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

                def calendar_day_preprocessing(day)
                  @location_rows = {}
                  @location_rows_timeslots = {}
              
              
              
              Severity: Major
              Found in app/helpers/calendars_helper.rb - About 3 hrs to fix

                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

                  Severity
                  Category
                  Status
                  Source
                  Language