Showing 34 of 81 total issues
Function initializeOneDayTimeHeatMap
has 120 lines of code (exceeds 25 allowed). Consider refactoring. Open
function initializeOneDayTimeHeatMap($container, data, selectedDay, selectedDayName) {
// extract the dates falling on particular day and
// fill up with 0 reservation on all hours
function initialChartData() {
Function initializeAllDaysHeatMap
has 116 lines of code (exceeds 25 allowed). Consider refactoring. Open
function initializeAllDaysHeatMap($container, data) {
// initialize chart with 0 reservations
function initialChartData() {
var datetimeHash = {};
Class OpenSchedule
has 32 methods (exceeds 20 allowed). Consider refactoring. Open
class OpenSchedule < ActiveRecord::Base
after_initialize :set_defaults
after_initialize :init_spans
validate :num_spans_divides_num_blocks_evenly
Function initializeDaysTimeHeatMap
has 96 lines of code (exceeds 25 allowed). Consider refactoring. Open
function initializeDaysTimeHeatMap($container, data) {
// initialize the cart data with 0 reservations
function initialChartData() {
var datetimeArray = [];
Function initializeDaysTimeHeatMap
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
function initializeDaysTimeHeatMap($container, data) {
// initialize the cart data with 0 reservations
function initialChartData() {
var datetimeArray = [];
- 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 initializeOneDayTimeHeatMap
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
function initializeOneDayTimeHeatMap($container, data, selectedDay, selectedDayName) {
// extract the dates falling on particular day and
// fill up with 0 reservation on all hours
function initialChartData() {
- 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
`` has 26 functions (exceeds 20 allowed). Consider refactoring. Open
_.extend(TimeSelect.prototype, {
toMoment: function(time) {
if (moment.isMoment(time)) { return time; }
if (_.isNumber(time)) {
var prefix = '';
Class Reservation
has 25 methods (exceeds 20 allowed). Consider refactoring. Open
class Reservation < ActiveRecord::Base
belongs_to :nook
belongs_to :requester, class_name: 'User', foreign_key: 'user_id',
inverse_of: :reservations
Function initializeAllDaysHeatMap
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
function initializeAllDaysHeatMap($container, data) {
// initialize chart with 0 reservations
function initialChartData() {
var datetimeHash = {};
- 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 initializeColumnChart
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
function initializeColumnChart($container, data) {
// data is key-value pair where key is nook
// and value is array of reservations
// preprocess it to count reservations happening in particular month
Function initializeHoursColumnChart
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
function initializeHoursColumnChart($container, data) {
// count the duration of reservations and add to each nook's monthly count
function preprocess(data) {
for (var i = 0; i < data.length; i++) {
Method create
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def create
@reservation = Reservation.new(reservation_params)
@reservation.requester = current_user
if params[:reservation][:nook_id]
@nook = Nook.find(params[:reservation][:nook_id])
- 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
@reservation = Reservation.new(reservation_params)
@reservation.requester = current_user
if params[:reservation][:nook_id]
@nook = Nook.find(params[:reservation][:nook_id])
Function initializeCalendar
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
function initializeCalendar(reservations) {
var events = []
// create events array from reservations
$(reservations).each( function( index, reservation ) {
Function initAutocomplete
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
function initAutocomplete() {
// render the map in location show page
if ( $('#location_show_map').length) {
var mapi = document.getElementById('location_show_map');
Method update
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def update
if @reservation.requester == current_user && @reservation.modifiable?
if @reservation.update(reservation_params)
flash[:notice] = t('reservations.updated')
if request.xhr?
- 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 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update
update_params = resource_params
update_params.delete(:amenities)
update_params.delete(:open_schedule)
update_params.delete(:admins)
Method create
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create
create_params = resource_params
create_params.delete(:amenities)
create_params.delete(:open_schedule)
create_params.delete(:admins)
Method create_reservations
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create_reservations(count, start_date, end_date)
random = Random.new
days = (end_date - start_date).to_i + 1
start_date = start_date.beginning_of_day
Function TimeSelect
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
var TimeSelect = function(parent, options) {
var self = this;
self.parent = parent;
self.format = 'HHmm';
self.selected = []; // Stored as start moments like 100 and 1300