berkmancenter/bookanook

View on GitHub

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() {
Severity: Major
Found in app/assets/javascripts/administrate/charts/one_day_time_heatmap.js - About 4 hrs to fix

    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 = {};
    Severity: Major
    Found in app/assets/javascripts/administrate/charts/all_days_heatmap.js - About 4 hrs to fix

      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
      Severity: Minor
      Found in app/models/open_schedule.rb - About 4 hrs to fix

        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 = [];
        Severity: Major
        Found in app/assets/javascripts/administrate/charts/days_time_heatmap.js - About 3 hrs to fix

          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 = [];
          Severity: Minor
          Found in app/assets/javascripts/administrate/charts/days_time_heatmap.js - About 3 hrs 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

          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() {
          Severity: Minor
          Found in app/assets/javascripts/administrate/charts/one_day_time_heatmap.js - About 3 hrs 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

          `` 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 = '';
          Severity: Minor
          Found in app/assets/javascripts/time_select.js - About 3 hrs to fix

            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
            
            
            Severity: Minor
            Found in app/models/reservation.rb - About 2 hrs to fix

              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 = {};
              Severity: Minor
              Found in app/assets/javascripts/administrate/charts/all_days_heatmap.js - About 2 hrs 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

              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
              Severity: Major
              Found in app/assets/javascripts/administrate/charts/column.js - About 2 hrs to fix

                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++) {
                Severity: Major
                Found in app/assets/javascripts/administrate/charts/hours_column.js - About 2 hrs to fix

                  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])
                  Severity: Minor
                  Found in app/controllers/reservations_controller.rb - About 2 hrs 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 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])
                  Severity: Minor
                  Found in app/controllers/reservations_controller.rb - About 1 hr to fix

                    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 ) {
                    Severity: Minor
                    Found in app/assets/javascripts/administrate/admin_calendar.js - About 1 hr to fix

                      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');
                      Severity: Minor
                      Found in app/assets/javascripts/administrate/geolocation.js - About 1 hr to fix

                        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?
                        Severity: Minor
                        Found in app/controllers/reservations_controller.rb - About 1 hr 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 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)
                        Severity: Minor
                        Found in app/controllers/admin/locations_controller.rb - About 1 hr to fix

                          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)
                          Severity: Minor
                          Found in app/controllers/admin/locations_controller.rb - About 1 hr to fix

                            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
                            
                            
                            Severity: Minor
                            Found in lib/populate_reservations.rb - About 1 hr to fix

                              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
                              Severity: Minor
                              Found in app/assets/javascripts/time_select.js - About 1 hr to fix
                                Severity
                                Category
                                Status
                                Source
                                Language