Showing 182 of 294 total issues
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
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
- 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 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
- 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 19 (exceeds 5 allowed). Consider refactoring. Open
def index
@start_date = interpret_start
@end_date = interpret_end
@user_stats = {}
@location_stats = {}
- 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
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
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 = {}
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}]
- 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 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
- 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 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
- 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 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"
- 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 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]
- 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
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
Function initialize
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
function initialize(element) {
$(element+' td.click_to_show').click(function (e) {
popup_show($(this), e);
return false;
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?
Method update
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def update
@punch_clock = PunchClock.find(params[:id])
return unless user_is_owner_or_admin_of(@punch_clock, @punch_clock.department)
if params[:pause]
message = @punch_clock.pause || "Successfully paused punch clock."
- 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
File users_controller.rb
has 254 lines of code (exceeds 250 allowed). Consider refactoring. Open
class UsersController < ApplicationController
before_filter :require_admin_or_superuser, except: 'autocomplete'
def index
if params[:show_inactive]
Method adjust_sub_requests
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def adjust_sub_requests
self.sub_requests.each do |sub|
if sub.start > self.end || sub.end < self.start
sub.destroy
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 data_fields_with_contents
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def data_fields_with_contents
begin
content_arrays = self.content.split(';;').map{|str| str.split('::')}
content_arrays.each do |a|
if DataField.find_with_destroyed(a.first).display_type == "check_box"
- 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 44 lines of code (exceeds 25 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
Method combine_with_surrounding_shifts
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def combine_with_surrounding_shifts
if (shift_later = Shift.where("start = ? AND user_id = ? AND location_id = ? AND calendars.active = ?", self.end, self.user_id, self.location_id, self.calendar.active?).includes(:calendar).first) && (!shift_later.has_sub?)
if (self.report.nil? || self.report.departed.nil?) && (shift_later.report.nil?)
self.end = shift_later.end
shift_later.sub_requests.each { |s| s.shift = self }
- 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"