Showing 182 of 294 total issues
Method parse_date_and_time_output
has 35 lines of code (exceeds 25 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?
Method update
has 34 lines of code (exceeds 25 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
Method create
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create
errors = []
parse_date_and_time_output(params[:time_slot])
join_date_and_time(params[:time_slot])
@time_slot = TimeSlot.new(params[:time_slot])
Method create
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create
@week_template = Template.find(params[:template_id])
@hours_week = (@week_template.min_total_hours..@week_template.max_total_hours).to_a
@shifts_week = (@week_template.min_number_of_shifts..@week_template.max_number_of_shifts).to_a
@hours_shift = (@week_template.min_continuous_hours..@week_template.max_continuous_hours).to_a
Method create
has 32 lines of code (exceeds 25 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
Method calculate_default_times_time_slots
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def calculate_default_times_time_slots
if params[:date]
#sometimes from the tooltip, sometimes week start date
@default_start_date = Date.parse(params[:date])
elsif @time_slot.start
- Read upRead up
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 proper_times
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def proper_times
if self.preferred_start
errors.add(:base, "Preferred start time must be after or the same as the acceptable start time") if self.preferred_start < self.acceptable_start
end
if self.preferred_end
- Read upRead up
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_email_group_settings
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def default_email_group_settings
params[:email_group] ||= {}
if params[:email_group]["start_time(1i)"]
@start_time ||= DateTime.new(params[:email_group][:"start_time(1i)"].to_i,params[:email_group][:"start_time(2i)"].to_i,params[:email_group][:"start_time(3i)"].to_i,params[:email_group][:"start_time(4i)"].to_i,params[:email_group][:"start_time(5i)"].to_i)
else
- Read upRead up
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 send_warnings
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def send_warnings
message = params[:post]["body"]
start_date = Date.parse(params[:post]["date"])
@department = current_department
@users = current_department.active_users.sort_by(&:name)
- Read upRead up
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 needs_doing
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def needs_doing
@last_completion = ShiftsTask.find_all_by_task_id(self.id).select{|st| st.task_id == self.id}.last #use find method
if @last_completion
hours_since = (Time.now - @last_completion.created_at)/3600
hours_since_scheduled = (Time.now)
- Read upRead up
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 delete_part_of_shift
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def self.delete_part_of_shift(shift, start_of_delete, end_of_delete)
#Used for taking sub requests
if !(start_of_delete.between?(shift.start, shift.end) && end_of_delete.between?(shift.start, shift.end))
raise "You can\'t delete more than the entire shift"
elsif start_of_delete >= end_of_delete
- Read upRead up
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
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def missed
@last_completion = ShiftsTask.find_all_by_task_id(self.id).select{|st| st.task_id == self.id}.last #use find method
if @last_completion
hours_since = (Time.now - @last_completion.created_at)/3600
hours_since_scheduled = (Time.now)
- Read upRead up
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_entry
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def make_entry
@shift = current_user.current_shift
@all_tasks = params[:all_tasks]
if @all_tasks == "true"
@tasks = all_allowed_tasks
- Read upRead up
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 11 (exceeds 5 allowed). Consider refactoring. Open
def index
if params[:shift_id] # check if index listing is shift specific
@shift=Shift.find(params[:shift_id])
@subs=@shift.sub_requests
@title_add=" for " + @shift.user.name + "'s shift in " + @shift.location.name + " on " + @shift.start.to_s(:gg)
- Read upRead up
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 11 (exceeds 5 allowed). Consider refactoring. Open
def destroy
@notice = Notice.find(params[:id])
unless @notice.class.name == "Sticky" || current_user.is_admin_of?(current_department) || current_user == @notice.author
flash[:error] = "You are not authorized to remove this #{@notice.type.downcase}"
redirect_to :back and return
- Read upRead up
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 11 (exceeds 5 allowed). Consider refactoring. Open
def create
# raise params.to_yaml
parse_just_time(params[:requested_shift])
@requested_shift = RequestedShift.new(params[:requested_shift])
@requested_shift.preferred_start = nil unless params[:preferred_start_choice]
- Read upRead up
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 31 lines of code (exceeds 25 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
Method index
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def index
@period_start = params[:date] ? Date.parse(params[:date]).previous_sunday : Date.today.previous_sunday
@upcoming_shifts = Shift.where("user_id = ? and end > ? and department_id = ? and scheduled = ? and active = ?", current_user, Time.now.utc, current_department.id, true, true).order(:start).limit(5)
# for user view preferences partial
Method take
has 31 lines of code (exceeds 25 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
Method make_future
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.make_future(event, location, wipe)
cal = event.calendar
if cal.active
shift_scope = Shift.active
else