bronycub/sugarcub

View on GitHub
core/static/vendor/datetimepicker/jquery.datetimepicker.js

Summary

Maintainability
F
5 mos
Test Coverage

Function datetimepicker has 1293 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    $.fn.datetimepicker = function (opt, opt2) {
        var result = this,
            KEY0 = 48,
            KEY9 = 57,
            _KEY0 = 96,
Severity: Major
Found in core/static/vendor/datetimepicker/jquery.datetimepicker.js - About 6 days to fix

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

    /**
     * @preserve jQuery DateTimePicker plugin v2.5.4
     * @homepage http://xdsoft.net/jqplugins/datetimepicker/
     * @author Chupurnov Valeriy (<chupurnov@gmail.com>)
     */
    Severity: Major
    Found in core/static/vendor/datetimepicker/jquery.datetimepicker.js - About 5 days to fix

      Function setOptions has 161 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

                  datetimepicker.setOptions = function (_options) {
                      var highlightedDates = {};
      
                      options = $.extend(true, {}, options, _options);
      
      
      Severity: Major
      Found in core/static/vendor/datetimepicker/jquery.datetimepicker.js - About 6 hrs to fix

        Function xdsoftScroller has 140 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            $.fn.xdsoftScroller = function (percent) {
                return this.each(function () {
                    var timeboxparent = $(this),
                        pointerEventToXY = function (e) {
                            var out = {x: 0, y: 0},
        Severity: Major
        Found in core/static/vendor/datetimepicker/jquery.datetimepicker.js - About 5 hrs to fix

          Function setMask has 115 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                      function setMask(options) {
          
                          var isValidValue = function (mask, value) {
                              var reg = mask
                                  .replace(/([\[\]\/\{\}\(\)\-\.\+]{1})/g, '\\$1')
          Severity: Major
          Found in core/static/vendor/datetimepicker/jquery.datetimepicker.js - About 4 hrs to fix

            Consider simplifying this complex logical expression.
            Open

                                    if (((key >= KEY0 && key <= KEY9) || (key >= _KEY0 && key <= _KEY9)) || (key === BACKSPACE || key === DEL)) {
                                        pos = getCaretPos(this);
                                        digit = (key !== BACKSPACE && key !== DEL) ? String.fromCharCode((_KEY0 <= key && key <= _KEY9) ? key - KEY0 : key) : '_';
            
                                        if ((key === BACKSPACE || key === DEL) && pos) {
            Severity: Critical
            Found in core/static/vendor/datetimepicker/jquery.datetimepicker.js - About 3 hrs to fix

              Function line_time has 33 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                                      line_time = function line_time(h, m) {
                                          var now = _xdsoft_datetime.now(), optionDateTime, current_time,
                                              isALlowTimesInit = options.allowTimes && $.isArray(options.allowTimes) && options.allowTimes.length;
                                          now.setHours(h);
                                          h = parseInt(now.getHours(), 10);
              Severity: Minor
              Found in core/static/vendor/datetimepicker/jquery.datetimepicker.js - About 1 hr to fix

                Consider simplifying this complex logical expression.
                Open

                                            if ((options.initTime || options.defaultSelect || datetimepicker.data('changed')) && current_time.getHours() === parseInt(h, 10) && ((!isALlowTimesInit && options.step > 59) || current_time.getMinutes() === parseInt(m, 10))) {
                                                if (options.defaultSelect || datetimepicker.data('changed')) {
                                                    classes.push('xdsoft_current');
                                                } else if (options.initTime) {
                                                    classes.push('xdsoft_init_time');
                Severity: Major
                Found in core/static/vendor/datetimepicker/jquery.datetimepicker.js - About 1 hr to fix

                  Consider simplifying this complex logical expression.
                  Open

                                      } else if (e.type === 'mousedown' || e.type === 'mouseup' || e.type === 'mousemove' || e.type === 'mouseover' || e.type === 'mouseout' || e.type === 'mouseenter' || e.type === 'mouseleave') {
                                          out.x = e.clientX;
                                          out.y = e.clientY;
                                      }
                  Severity: Major
                  Found in core/static/vendor/datetimepicker/jquery.datetimepicker.js - About 1 hr to fix

                    Consider simplifying this complex logical expression.
                    Open

                                                if ((options.minDateTime !== false && options.minDateTime > optionDateTime) || (options.maxTime !== false && _xdsoft_datetime.strtotime(options.maxTime).getTime() < now.getTime()) || (options.minTime !== false && _xdsoft_datetime.strtotime(options.minTime).getTime() > now.getTime())) {
                                                    classes.push('xdsoft_disabled');
                                                } else if ((options.minDateTime !== false && options.minDateTime > optionDateTime) || ((options.disabledMinTime !== false && now.getTime() > _xdsoft_datetime.strtotime(options.disabledMinTime).getTime()) && (options.disabledMaxTime !== false && now.getTime() < _xdsoft_datetime.strtotime(options.disabledMaxTime).getTime()))) {
                                                    classes.push('xdsoft_disabled');
                                                } else if (input.is('[readonly]')) {
                    Severity: Major
                    Found in core/static/vendor/datetimepicker/jquery.datetimepicker.js - About 40 mins to fix

                      Consider simplifying this complex logical expression.
                      Open

                                                  } else if ((maxDate !== false && start > maxDate) || (minDate !== false && start < minDate) || (customDateSettings && customDateSettings[0] === false)) {
                                                      classes.push('xdsoft_disabled');
                                                  } else if (options.disabledDates.indexOf(dateHelper.formatDate(start, options.formatDate)) !== -1) {
                                                      classes.push('xdsoft_disabled');
                                                  } else if (options.disabledWeekDays.indexOf(day) !== -1) {
                      Severity: Major
                      Found in core/static/vendor/datetimepicker/jquery.datetimepicker.js - About 40 mins to fix

                        Consider simplifying this complex logical expression.
                        Open

                                                            if (!options.datepicker && options.timepicker && splittedHours >= 0 && splittedHours < 24 && splittedMinutes >= 0 && splittedMinutes < 60) {
                                                                $(this).val([splittedHours, splittedMinutes].map(function (item) {
                                                                    return item > 9 ? item : '0' + item;
                                                                }).join(':'));
                                                            } else {
                        Severity: Major
                        Found in core/static/vendor/datetimepicker/jquery.datetimepicker.js - About 40 mins to fix

                          Consider simplifying this complex logical expression.
                          Open

                                                      } else if ((options.minDateTime !== false && options.minDateTime > optionDateTime) || ((options.disabledMinTime !== false && now.getTime() > _xdsoft_datetime.strtotime(options.disabledMinTime).getTime()) && (options.disabledMaxTime !== false && now.getTime() < _xdsoft_datetime.strtotime(options.disabledMaxTime).getTime()))) {
                                                          classes.push('xdsoft_disabled');
                                                      } else if (input.is('[readonly]')) {
                                                          classes.push('xdsoft_disabled');
                                                      }
                          Severity: Major
                          Found in core/static/vendor/datetimepicker/jquery.datetimepicker.js - About 40 mins to fix

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

                            ;(function (factory) {
                                if ( typeof define === 'function' && define.amd ) {
                                    // AMD. Register as an anonymous module.
                                    define(['jquery', 'jquery-mousewheel'], factory);
                                } else if (typeof exports === 'object') {
                            Severity: Major
                            Found in core/static/vendor/datetimepicker/jquery.datetimepicker.js and 1 other location - About 4 mos to fix
                            core/static/vendor/datetimepicker/build/jquery.datetimepicker.full.js on lines 583..2963

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

                            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