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
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
- 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_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
- 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 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
- 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 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
- 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 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"
- 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 8 (exceeds 5 allowed). Consider refactoring. Open
def create
@task = Task.new(params[:task])
respond_to do |format|
if @task.save
- 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 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();"
- 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 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 = []
- 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 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()
- 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 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|
- 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 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
- 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 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
- 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 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
- 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_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 = []
- 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 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
- 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 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) &&
- 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 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|
- 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
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
- 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 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)
- 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"