bronycub/sugarcub

View on GitHub
core/static/vendor/bootstrap-datepicker/js/bootstrap-datepicker.js

Summary

Maintainability
F
4 mos
Test Coverage

File bootstrap-datepicker.js has 1832 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* =========================================================
 * bootstrap-datepicker.js
 * Repo: https://github.com/eternicode/bootstrap-datepicker/
 * Demo: http://eternicode.github.io/bootstrap-datepicker/
 * Docs: http://bootstrap-datepicker.readthedocs.org/
Severity: Major
Found in core/static/vendor/bootstrap-datepicker/js/bootstrap-datepicker.js - About 5 days to fix

    Function fill has 149 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            fill: function(){
                var d = new Date(this.viewDate),
                    year = d.getUTCFullYear(),
                    month = d.getUTCMonth(),
                    startYear = this.o.startDate !== -Infinity ? this.o.startDate.getUTCFullYear() : -Infinity,
    Severity: Major
    Found in core/static/vendor/bootstrap-datepicker/js/bootstrap-datepicker.js - About 5 hrs to fix

      Function parseDate has 129 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              parseDate: function(date, format, language, assumeNearby){
                  if (!date)
                      return undefined;
                  if (date instanceof Date)
                      return date;
      Severity: Major
      Found in core/static/vendor/bootstrap-datepicker/js/bootstrap-datepicker.js - About 5 hrs to fix

        Function click has 112 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                click: function(e){
                    e.preventDefault();
                    e.stopPropagation();
        
                    var target, dir, day, year, month, monthChanged, yearChanged;
        Severity: Major
        Found in core/static/vendor/bootstrap-datepicker/js/bootstrap-datepicker.js - About 4 hrs to fix

          Function _process_options has 102 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  _process_options: function(opts){
                      // Store raw options for reference
                      this._o = $.extend({}, this._o, opts);
                      // Processed options
                      var o = this.o = $.extend({}, this._o);
          Severity: Major
          Found in core/static/vendor/bootstrap-datepicker/js/bootstrap-datepicker.js - About 4 hrs to fix

            Function keydown has 99 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    keydown: function(e){
                        if (!this.picker.is(':visible')){
                            if (e.keyCode === 40 || e.keyCode === 27) { // allow down to re-show picker
                                this.show();
                                e.stopPropagation();
            Severity: Major
            Found in core/static/vendor/bootstrap-datepicker/js/bootstrap-datepicker.js - About 3 hrs to fix

              Function _buildEvents has 72 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      _buildEvents: function(){
                          var events = {
                              keyup: $.proxy(function(e){
                                  if ($.inArray(e.keyCode, [27, 37, 39, 38, 40, 32, 13, 9]) === -1)
                                      this.update();
              Severity: Major
              Found in core/static/vendor/bootstrap-datepicker/js/bootstrap-datepicker.js - About 2 hrs to fix

                Function place has 69 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                        place: function(){
                            if (this.isInline)
                                return this;
                            var calendarWidth = this.picker.outerWidth(),
                                calendarHeight = this.picker.outerHeight(),
                Severity: Major
                Found in core/static/vendor/bootstrap-datepicker/js/bootstrap-datepicker.js - About 2 hrs to fix

                  Function update has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                          update: function(){
                              if (!this._allow_update)
                                  return this;
                  
                              var oldDates = this.dates.copy(),
                  Severity: Major
                  Found in core/static/vendor/bootstrap-datepicker/js/bootstrap-datepicker.js - About 2 hrs to fix

                    Function _fill_yearsView has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                            _fill_yearsView: function(selector, cssClass, factor, step, currentYear, startYear, endYear, callback){
                                var html, view, year, steps, startStep, endStep, thisYear, i, classes, tooltip, before;
                    
                                html      = '';
                                view      = this.picker.find(selector);
                    Severity: Major
                    Found in core/static/vendor/bootstrap-datepicker/js/bootstrap-datepicker.js - About 2 hrs to fix

                      Function Datepicker has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          var Datepicker = function(element, options){
                              $(element).data('datepicker', this);
                              this._process_options(options);
                      
                              this.dates = new DateArray();
                      Severity: Major
                      Found in core/static/vendor/bootstrap-datepicker/js/bootstrap-datepicker.js - About 2 hrs to fix

                        Function getClassNames has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                                getClassNames: function(date){
                                    var cls = [],
                                        year = this.viewDate.getUTCFullYear(),
                                        month = this.viewDate.getUTCMonth(),
                                        today = new Date();
                        Severity: Minor
                        Found in core/static/vendor/bootstrap-datepicker/js/bootstrap-datepicker.js - About 1 hr to fix

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

                                  updateNavArrows: function(){
                                      if (!this._allow_update)
                                          return;
                          
                                      var d = new Date(this.viewDate),
                          Severity: Minor
                          Found in core/static/vendor/bootstrap-datepicker/js/bootstrap-datepicker.js - About 1 hr to fix

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

                                var DateArray = (function(){
                                    var extras = {
                                        get: function(i){
                                            return this.slice(i)[0];
                                        },
                            Severity: Minor
                            Found in core/static/vendor/bootstrap-datepicker/js/bootstrap-datepicker.js - About 1 hr to fix

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

                                  var datepickerPlugin = function(option){
                                      var args = Array.apply(null, arguments);
                                      args.shift();
                                      var internal_return;
                                      this.each(function(){
                              Severity: Minor
                              Found in core/static/vendor/bootstrap-datepicker/js/bootstrap-datepicker.js - About 1 hr to fix

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

                                        moveMonth: function(date, dir){
                                            if (!isValidDate(date))
                                                return this.o.defaultViewDate;
                                            if (!dir)
                                                return date;
                                Severity: Minor
                                Found in core/static/vendor/bootstrap-datepicker/js/bootstrap-datepicker.js - About 1 hr to fix

                                  Function dateUpdated has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                          dateUpdated: function(e){
                                              // `this.updating` is a workaround for preventing infinite recursion
                                              // between `changeDate` triggering and `setUTCDate` calling.  Until
                                              // there is a better mechanism.
                                              if (this.updating)
                                  Severity: Minor
                                  Found in core/static/vendor/bootstrap-datepicker/js/bootstrap-datepicker.js - About 1 hr to fix

                                    Function formatDate has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                            formatDate: function(date, format, language){
                                                if (!date)
                                                    return '';
                                                if (typeof format === 'string')
                                                    format = DPGlobal.parseFormat(format);
                                    Severity: Minor
                                    Found in core/static/vendor/bootstrap-datepicker/js/bootstrap-datepicker.js - About 1 hr to fix

                                      Function _fill_yearsView has 8 arguments (exceeds 4 allowed). Consider refactoring.
                                      Open

                                              _fill_yearsView: function(selector, cssClass, factor, step, currentYear, startYear, endYear, callback){
                                      Severity: Major
                                      Found in core/static/vendor/bootstrap-datepicker/js/bootstrap-datepicker.js - About 1 hr to fix

                                        Avoid deeply nested control flow statements.
                                        Open

                                                              else if (e.keyCode === 37 || e.keyCode === 39){
                                                                  newViewDate = this.moveAvailableDate(focusDate, dir, 'moveDay');
                                                              }
                                                              else if (!this.weekOfDateIsDisabled(focusDate)){
                                                                  newViewDate = this.moveAvailableDate(focusDate, dir, 'moveWeek');
                                        Severity: Major
                                        Found in core/static/vendor/bootstrap-datepicker/js/bootstrap-datepicker.js - About 45 mins to fix

                                          Avoid deeply nested control flow statements.
                                          Open

                                                      if (e.keyCode === 38 || e.keyCode === 40) {
                                                        dir = dir * 4;
                                                      }
                                          Severity: Major
                                          Found in core/static/vendor/bootstrap-datepicker/js/bootstrap-datepicker.js - About 45 mins to fix

                                            Avoid deeply nested control flow statements.
                                            Open

                                                                      if (newViewDate)
                                                                          this._trigger('changeMonth', this.viewDate);
                                            Severity: Major
                                            Found in core/static/vendor/bootstrap-datepicker/js/bootstrap-datepicker.js - About 45 mins to fix

                                              Avoid too many return statements within this function.
                                              Open

                                                          return default_value === undefined ? false : default_value;
                                              Severity: Major
                                              Found in core/static/vendor/bootstrap-datepicker/js/bootstrap-datepicker.js - About 30 mins to fix

                                                Avoid too many return statements within this function.
                                                Open

                                                                return 4;
                                                Severity: Major
                                                Found in core/static/vendor/bootstrap-datepicker/js/bootstrap-datepicker.js - About 30 mins to fix

                                                  Avoid too many return statements within this function.
                                                  Open

                                                                        return UTCDate(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate());
                                                  Severity: Major
                                                  Found in core/static/vendor/bootstrap-datepicker/js/bootstrap-datepicker.js - About 30 mins to fix

                                                    Avoid too many return statements within this function.
                                                    Open

                                                                return date;
                                                    Severity: Major
                                                    Found in core/static/vendor/bootstrap-datepicker/js/bootstrap-datepicker.js - About 30 mins to fix

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

                                                      (function(factory){
                                                          if (typeof define === "function" && define.amd) {
                                                              define(["jquery"], factory);
                                                          } else if (typeof exports === 'object') {
                                                              factory(require('jquery'));
                                                      core/static/vendor/bootstrap-datepicker/dist/js/bootstrap-datepicker.js on lines 7..2096

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

                                                      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