YaleSTC/shifts

View on GitHub

Showing 182 of 294 total issues

Method check_alerts? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def check_alerts?(string)
    if string == self.exact_alert
      return false
    elsif self.lower_bound && string.to_f < self.lower_bound
      return false
Severity: Minor
Found in app/models/data_field.rb - About 25 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_style has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def shift_style(shift)
    @right_overflow = @left_overflow = false

    #necessary for AJAX rerendering
    #we should extract all of this stuff from controllers and here and make a universal shifts helper method -njg
Severity: Minor
Found in app/helpers/calendars_helper.rb - About 25 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 6 (exceeds 5 allowed). Consider refactoring.
Open

  def create
    set_payform_item_hours("payform_item")
    @payform_item = PayformItem.new(params[:payform_item])
    @payform_item.payform = Payform.find(params[:payform_id])
    return unless user_is_owner_or_admin_of(@payform_item.payform, @payform_item.department)
Severity: Minor
Found in app/controllers/payform_items_controller.rb - About 25 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 copy has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def self.copy(old_calendar, new_calendar, wipe)
    errors = ""

    old_calendar.repeating_events.each do |r|
      new_repeating_event = r.dup
Severity: Minor
Found in app/models/calendar.rb - About 25 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 select_integer has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def select_integer (object, column, start, stop, interval = 1, default = nil)
    output = "<select id=\"#{object}_#{column}\" name=\"#{object}[#{column}]\">"
    for i in start..stop
      if i%interval == 0
        output << "\n<option value=\"#{i}\""
Severity: Minor
Found in app/helpers/application_helper.rb - About 25 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 update has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def update
    set_payform_item_hours("payform_item")
    @payform_item = PayformItem.find(params[:id])
    return unless user_is_owner_or_admin_of(@payform_item.payform, @payform_item.department)
    @payform_item.attributes = params[:payform_item]
Severity: Minor
Found in app/controllers/payform_items_controller.rb - About 25 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 6 (exceeds 5 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 25 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 submit has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def submit(description = "Punch clock for #{self.user.name}.")
    self.pause unless self.paused?
    if self.save
      payform_item = PayformItem.new({date: Date.today,
                                    category: Category.where(name: "Punch Clocks").first,
Severity: Minor
Found in app/models/punch_clock.rb - About 25 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 determine_auth_type has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def determine_auth_type(user,l)
    if u = User.where(login: user.login).first
      if u.auth_type == l
        true
      else
Severity: Minor
Found in app/helpers/users_helper.rb - About 25 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 destroy has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def destroy
    @punch_clock = PunchClock.find(params[:id])
    return unless user_is_owner_or_admin_of(@punch_clock, @punch_clock.department)
    if @punch_clock.destroy
      flash[:notice] = "Successfully canceled punch clock."
Severity: Minor
Found in app/controllers/punch_clocks_controller.rb - About 25 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 user_does_not_have_concurrent_shift has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def user_does_not_have_concurrent_shift
    c = Shift.for_user(self.user).in_department(self.department).overlaps(self.start, self.end)
    if self.calendar.active
      c = c.active
    else
Severity: Minor
Found in app/models/shift.rb - About 25 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 new has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def new
    shift = Shift.find_by_id(params[:shift_id])
    if shift && shift.scheduled? #avoids attempting to call for start times of a non-existant shift
      @sub_request = SubRequest.new(shift_id: params[:shift_id])
      @sub_request.mandatory_start = @sub_request.start = @sub_request.shift.start
Severity: Minor
Found in app/controllers/sub_requests_controller.rb - About 25 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 destroy has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def destroy
    @payform_item = PayformItem.find(params[:id])
    return unless user_is_owner_or_admin_of(@payform_item.payform, @payform_item.department)
    if @payform_item.update_attributes(reason: params[:payform_item][:reason], active: false)
      if @payform_item.payform.user != current_user
Severity: Minor
Found in app/controllers/payform_items_controller.rb - About 25 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 6 (exceeds 5 allowed). Consider refactoring.
Open

  def create
    shift = Shift.find(params[:shift_id])
    if shift.start > 1.day.from_now
      flash[:error] = "You can't sign into a shift too far in advance"
      redirect_to dashboard_path and return
Severity: Minor
Found in app/controllers/reports_controller.rb - About 25 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 show has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def show
    @report = params[:id] ? Report.find(params[:id]) : Report.where(shift_id: params[:shift_id]).first
    # @tasks = Task.in_location(@report.shift.location).active.after_now.delete_if{|t| t.kind == "Weekly" && t.day_in_week != @report.shift.start.strftime("%a")}
    tasks = Task.in_location(@report.shift.location).active.after_now
    # filters out daily and weekly tasks scheduled for a time later in the day
Severity: Minor
Found in app/controllers/reports_controller.rb - About 25 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_app_config has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def create_app_config
    AppConfig.first.destroy if AppConfig.first
    @app_config=AppConfig.new(params[:app_config])
    @app_config.calendar_feed_hash = SecureRandom.hex(32) # generates 64 character string
    @app_config.use_ldap = params[:app_config][:use_ldap] && params[:app_config][:use_ldap] == "1" ? true : false
Severity: Minor
Found in app/controllers/first_run_controller.rb - About 25 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 search has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def search
    @user_profile_fields =  UserProfileField.where(index_display: true, department_id: @department.id)
    users = current_department.active_users
    #filter results if we are searching
    if params[:search]
Severity: Minor
Found in app/controllers/user_profiles_controller.rb - About 25 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 department_chooser has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def department_chooser
    if (params[:su_mode] && current_user.superuser?)
      current_user.update_attribute(:supermode, params[:su_mode]=='ON')
      flash[:notice] = "Supermode is now #{current_user.supermode? ? 'ON' : 'OFF'}"
      redirect_to :back
Severity: Minor
Found in app/controllers/application_controller.rb - About 25 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 update has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def update
        parse_just_time(params[:requested_shift])
    @requested_shift = RequestedShift.find(params[:id])
        @week_template = Template.find(params[:template_id])
        respond_to do |format|
Severity: Minor
Found in app/controllers/requested_shifts_controller.rb - About 25 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 6 (exceeds 5 allowed). Consider refactoring.
Open

  def create
    @user_profile = UserProfile.new(params[:user_profile])
    if @user_profile.save
      flash[:noticcurrent_user.is_admin_of(@department)] = "Successfully created user profile."
      if params[:user_profile] && params[:user_profile][:photo]
Severity: Minor
Found in app/controllers/user_profiles_controller.rb - About 25 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