berkmancenter/bookanook

View on GitHub

Showing 81 of 81 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  if ($('.location-statistics').length) {
    buildEntitiesNameHash('location');
    setSidebarLinkActive();
    $("#locations-stats-filter").submit( function(e) {
      var url = $(this).attr('action');
Severity: Major
Found in app/assets/javascripts/administrate/statistics.js and 1 other location - About 1 day to fix
app/assets/javascripts/administrate/statistics.js on lines 79..104

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 270.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  if ($('.nook-statistics').length) {
    buildEntitiesNameHash('nook');
    setSidebarLinkActive();
    $("#nooks-stats-filter").submit( function(e) {
      var url = $(this).attr('action');
Severity: Major
Found in app/assets/javascripts/administrate/statistics.js and 1 other location - About 1 day to fix
app/assets/javascripts/administrate/statistics.js on lines 107..133

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 270.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

function getDateTimeRange(timeSelector, startDate, endDate) {
  startDate = startDate || new Date();
  endDate = endDate || new Date();

  var selectedTimes = timeSelector.getSelected();
Severity: Major
Found in app/assets/javascripts/reservation.js and 1 other location - About 1 day to fix
app/assets/javascripts/administrate/components/date_time_picker.js on lines 62..78

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 208.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

  function getDateTimeRange(timeSelector, startDate, endDate) {
    startDate = startDate || new Date();
    endDate = endDate || new Date();

    var selectedTimes = timeSelector.getSelected();
app/assets/javascripts/reservation.js on lines 1..17

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 208.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  $container.highcharts({
    chart: {
        type: 'column',
        backgroundColor: '#f6f7f7'
    },
Severity: Major
Found in app/assets/javascripts/administrate/charts/hours_column.js and 1 other location - About 6 hrs to fix
app/assets/javascripts/administrate/charts/column.js on lines 33..79

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 155.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  $container.highcharts({
    chart: {
        type: 'column',
        backgroundColor: '#f6f7f7'
    },
Severity: Major
Found in app/assets/javascripts/administrate/charts/column.js and 1 other location - About 6 hrs to fix
app/assets/javascripts/administrate/charts/hours_column.js on lines 34..80

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 155.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 3 locations. Consider refactoring.
Open

    yAxis: {
      title: {
        text: null
      },
      labels: {
app/assets/javascripts/administrate/charts/days_time_heatmap.js on lines 73..97
app/assets/javascripts/administrate/charts/one_day_time_heatmap.js on lines 99..123

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 151.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 3 locations. Consider refactoring.
Open

    yAxis: {
      title: {
        text: null
      },
      labels: {
app/assets/javascripts/administrate/charts/all_days_heatmap.js on lines 93..117
app/assets/javascripts/administrate/charts/one_day_time_heatmap.js on lines 99..123

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 151.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 3 locations. Consider refactoring.
Open

    yAxis: {
      title: {
        text: null
      },
      labels: {
app/assets/javascripts/administrate/charts/all_days_heatmap.js on lines 93..117
app/assets/javascripts/administrate/charts/days_time_heatmap.js on lines 73..97

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 151.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              if (max_start != max_end) {
                hour = Math.floor(max_end);
                minutes = s.lpad((max_end - hour) * 60, 2, '0');
                $(this).parent().find('.slider-max').html((hour > 12 ? hour - 12 : hour) + ':' + minutes + (hour >= 12 ? 'PM' : 'AM'));
              }
          Severity: Major
          Found in app/assets/javascripts/filters.js and 1 other location - About 3 hrs to fix
          app/assets/javascripts/filters.js on lines 100..104

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 110.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              if (min_start != min_end) {
                hour = Math.floor(min_end);
                minutes = s.lpad((min_end - hour) * 60, 2, '0');
                $(this).parent().find('.slider-min').html((hour > 12 ? hour - 12 : hour) + ':' + minutes + (hour >= 12 ? 'PM' : 'AM'));
              }
          Severity: Major
          Found in app/assets/javascripts/filters.js and 1 other location - About 3 hrs to fix
          app/assets/javascripts/filters.js on lines 105..109

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 110.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          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

              Severity
              Category
              Status
              Source
              Language