MainStMission/food-pantry-manager

View on GitHub
app/assets/javascripts/jquery.datetimeentry.js

Summary

Maintainability
F
6 days
Test Coverage

File jquery.datetimeentry.js has 934 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* http://keith-wood.name/datetimeEntry.html
   Date and time entry for jQuery v1.1.1.
   Written by Keith Wood (kbwood{at}iinet.com.au) September 2010.
   Licensed under the MIT (https://github.com/jquery/jquery/blob/master/MIT-LICENSE.txt) license.
   Please attribute the author if you use it. */
Severity: Major
Found in app/assets/javascripts/jquery.datetimeentry.js - About 2 days to fix

    Function _parseDatetime has 93 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        _parseDatetime: function(inst, value) {
            if (!value) {
                return null;
            }
            var year = 0;
    Severity: Major
    Found in app/assets/javascripts/jquery.datetimeentry.js - About 3 hrs to fix

      Function _handleKeyPress has 68 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          _handleKeyPress: function(inst, chr) {
              chr = chr.toLowerCase();
              var field = inst.options.datetimeFormat.charAt(inst._fields[inst._field]);
              var sep = inst.options.datetimeFormat.charAt(inst._fields[inst._field] + 1);
              sep = ('yYoOnNdDwWhHmMsSa'.indexOf(sep) == -1 ? sep : '');
      Severity: Major
      Found in app/assets/javascripts/jquery.datetimeentry.js - About 2 hrs to fix

        Function _determineDatetime has 48 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            _determineDatetime: function(inst, setting) {
                var offsetNumeric = function(offset) { // E.g. +300, -2
                    var datetime = new Date();
                    datetime.setSeconds(datetime.getSeconds() + offset);
                    return datetime;
        Severity: Minor
        Found in app/assets/javascripts/jquery.datetimeentry.js - About 1 hr to fix

          Function _formatDatetime has 45 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              _formatDatetime: function(inst, format) {
                  var currentDatetime = '';
                  var ampm = format.indexOf('a') > -1;
                  for (var i = 0; i < format.length; i++) {
                      var field = format.charAt(i);
          Severity: Minor
          Found in app/assets/javascripts/jquery.datetimeentry.js - About 1 hr to fix

            Function _optionPlugin has 42 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                _optionPlugin: function(target, options, value) {
                    target = $(target);
                    var inst = target.data(this.propertyName);
                    if (!options || (typeof options == 'string' && value == null)) { // Get option
                        var name = options;
            Severity: Minor
            Found in app/assets/javascripts/jquery.datetimeentry.js - About 1 hr to fix

              Function offsetString has 39 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      var offsetString = function(offset) { // E.g. '+2m', '-4h', '+3h +30m'
                          var datetime;
                          try { // Check for string in current datetime format
                              datetime = plugin._parseDatetime(inst, offset);
                              if (datetime) {
              Severity: Minor
              Found in app/assets/javascripts/jquery.datetimeentry.js - About 1 hr to fix

                Function _doClick has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    _doClick: function(event) {
                        var input = event.target;
                        var inst = $.data(input, plugin.propertyName);
                        if (!plugin._focussed) {
                            var datetimeFormat = inst.options.datetimeFormat;
                Severity: Minor
                Found in app/assets/javascripts/jquery.datetimeentry.js - About 1 hr to fix

                  Function DatetimeEntry has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function DatetimeEntry() {
                      this._disabledInputs = []; // List of datetime inputs that have been disabled
                      this.regional = []; // Available regional settings, indexed by language code
                      this.regional[''] = { // Default regional settings
                          datetimeFormat: 'O/D/Y H:Ma', // The format of the date text:
                  Severity: Minor
                  Found in app/assets/javascripts/jquery.datetimeentry.js - About 1 hr to fix

                    Function _doKeyDown has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        _doKeyDown: function(event) {
                            if (event.keyCode >= 48) { // >= '0'
                                return true;
                            }
                            var inst = $.data(event.target, plugin.propertyName);
                    Severity: Minor
                    Found in app/assets/javascripts/jquery.datetimeentry.js - About 1 hr to fix

                      Function _expandSpinner has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          _expandSpinner: function(event) {
                              var spinner = plugin._getSpinnerTarget(event);
                              var inst = $.data(plugin._getInput(spinner), plugin.propertyName);
                              if (plugin._isDisabledPlugin(inst.input[0])) {
                                  return;
                      Severity: Minor
                      Found in app/assets/javascripts/jquery.datetimeentry.js - About 1 hr to fix

                        Function _setDatetime has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            _setDatetime: function(inst, datetime) {
                                // Normalise to base time
                                datetime = this._normaliseDatetime(this._determineDatetime(inst,
                                    datetime || inst.options.defaultDatetime) || new Date());
                                var fields = this._constrainTime(inst,
                        Severity: Minor
                        Found in app/assets/javascripts/jquery.datetimeentry.js - About 1 hr to fix

                          Function _fieldLength has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              _fieldLength: function(inst, format) {
                                  switch (format) {
                                      case 'Y':
                                          return 4;
                                      case 'n': case 'N':
                          Severity: Minor
                          Found in app/assets/javascripts/jquery.datetimeentry.js - About 1 hr to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                if (offsetX < range.boundingWidth) { // And compare
                                                    break;
                                                }
                            Severity: Major
                            Found in app/assets/javascripts/jquery.datetimeentry.js - About 45 mins to fix

                              Consider simplifying this complex logical expression.
                              Open

                                      else if (chr >= '0' && chr <= '9') { // Allow direct entry of datetime
                                          var key = parseInt(chr, 10);
                                          var value = parseInt(inst._lastChr + chr, 10);
                                          var year = (!field.match(/y/i) ? inst._selectedYear : value);
                                          var month = (!field.match(/o|n/i) ? inst._selectedMonth + 1 :
                              Severity: Major
                              Found in app/assets/javascripts/jquery.datetimeentry.js - About 40 mins to fix

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

                                    _copyDate: function(dateFrom, dateTo) {
                                        dateTo.setFullYear(dateFrom.getFullYear());
                                        dateTo.setMonth(dateFrom.getMonth());
                                        dateTo.setDate(dateFrom.getDate());
                                    },
                                Severity: Major
                                Found in app/assets/javascripts/jquery.datetimeentry.js and 1 other location - About 1 hr to fix
                                app/assets/javascripts/jquery.datetimeentry.js on lines 965..969

                                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 68.

                                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

                                    _copyTime: function(timeFrom, timeTo) {
                                        timeTo.setHours(timeFrom.getHours());
                                        timeTo.setMinutes(timeFrom.getMinutes());
                                        timeTo.setSeconds(timeFrom.getSeconds());
                                    },
                                Severity: Major
                                Found in app/assets/javascripts/jquery.datetimeentry.js and 1 other location - About 1 hr to fix
                                app/assets/javascripts/jquery.datetimeentry.js on lines 956..960

                                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 68.

                                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

                                            $('<div class="' + plugin._expandClass + '" style="position: absolute; left: ' +
                                                (offset.left - (inst.options.spinnerBigSize[0] - inst.options.spinnerSize[0]) / 2 -
                                                (relative ? relative.left : 0)) + 'px; top: ' +
                                Severity: Major
                                Found in app/assets/javascripts/jquery.datetimeentry.js and 1 other location - About 1 hr to fix
                                app/assets/javascripts/jquery.datetimeentry.js on lines 442..446

                                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 56.

                                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 (value.substring(index).substr(0, dayNames[j].length).toLowerCase() ==
                                                                dayNames[j].toLowerCase()) {
                                                            index += dayNames[j].length + 1;
                                                            break;
                                                        }
                                Severity: Minor
                                Found in app/assets/javascripts/jquery.datetimeentry.js and 1 other location - About 40 mins to fix
                                app/assets/javascripts/jquery.datetimeentry.js on lines 665..670

                                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 49.

                                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 (value.substring(index).substr(0, monthNames[j].length).toLowerCase() ==
                                                                monthNames[j].toLowerCase()) {
                                                            month = j + 1;
                                                            index += monthNames[j].length;
                                                            break;
                                Severity: Minor
                                Found in app/assets/javascripts/jquery.datetimeentry.js and 1 other location - About 40 mins to fix
                                app/assets/javascripts/jquery.datetimeentry.js on lines 676..680

                                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 49.

                                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

                                                    currentDatetime += inst.options[field == 'W' ? 'dayNames' : 'dayNamesShort']
                                                        [new Date(inst._selectedYear, inst._selectedMonth, inst._selectedDay).getDay()] +
                                Severity: Minor
                                Found in app/assets/javascripts/jquery.datetimeentry.js and 1 other location - About 40 mins to fix
                                app/assets/javascripts/jquery.datetimeentry.js on lines 822..824

                                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 48.

                                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

                                                return inst.options[format == 'W' ? 'dayNames' : 'dayNamesShort']
                                                    [new Date(inst._selectedYear, inst._selectedMonth, inst._selectedDay).
                                                    getDay()].length + 3;
                                Severity: Minor
                                Found in app/assets/javascripts/jquery.datetimeentry.js and 1 other location - About 40 mins to fix
                                app/assets/javascripts/jquery.datetimeentry.js on lines 759..760

                                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 48.

                                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 (maxTime && this._normaliseDatetime(new Date(datetime.getTime()), 'd') > maxTime) {
                                            this._copyTime(maxTime, datetime);
                                        }
                                Severity: Minor
                                Found in app/assets/javascripts/jquery.datetimeentry.js and 1 other location - About 35 mins to fix
                                app/assets/javascripts/jquery.datetimeentry.js on lines 938..940

                                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 47.

                                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 (minTime && this._normaliseDatetime(new Date(datetime.getTime()), 'd') < minTime) {
                                            this._copyTime(minTime, datetime);
                                        }
                                Severity: Minor
                                Found in app/assets/javascripts/jquery.datetimeentry.js and 1 other location - About 35 mins to fix
                                app/assets/javascripts/jquery.datetimeentry.js on lines 941..943

                                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 47.

                                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

                                                    (chr == inst.options.ampmNames[1].substring(0, 1).toLowerCase() &&
                                                    inst._selectedHour < 12)) {
                                Severity: Minor
                                Found in app/assets/javascripts/jquery.datetimeentry.js and 1 other location - About 30 mins to fix
                                app/assets/javascripts/jquery.datetimeentry.js on lines 1112..1113

                                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 45.

                                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 ((chr == inst.options.ampmNames[0].substring(0, 1).toLowerCase() &&
                                                    inst._selectedHour >= 12) ||
                                Severity: Minor
                                Found in app/assets/javascripts/jquery.datetimeentry.js and 1 other location - About 30 mins to fix
                                app/assets/javascripts/jquery.datetimeentry.js on lines 1114..1115

                                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 45.

                                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

                                There are no issues that match your filters.

                                Category
                                Status