Dogfalo/materialize

View on GitHub
js/date_picker/picker.date.js

Summary

Maintainability
F
1 wk
Test Coverage

File picker.date.js has 852 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*!
 * Date picker for pickadate.js v3.5.0
 * http://amsul.github.io/pickadate.js/date.htm
 */

Severity: Major
Found in js/date_picker/picker.date.js - About 2 days to fix

    Function nodes has 269 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    DatePicker.prototype.nodes = function( isOpen ) {
    
        var
            calendar = this,
            settings = calendar.settings,
    Severity: Major
    Found in js/date_picker/picker.date.js - About 1 day to fix

      Function DatePicker has 84 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function DatePicker( picker, settings ) {
      
          var calendar = this,
              element = picker.$node[ 0 ],
              elementValue = element.value,
      Severity: Major
      Found in js/date_picker/picker.date.js - About 3 hrs to fix

        Function activate has 60 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        DatePicker.prototype.activate = function( type, datesToEnable ) {
        
            var calendar = this,
                disabledItems = calendar.item.disable,
                disabledItemsCount = disabledItems.length
        Severity: Major
        Found in js/date_picker/picker.date.js - About 2 hrs to fix

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

          DatePicker.prototype.formats = (function() {
          
              // Return the length of the first word in a collection.
              function getWordLengthFromCollection( string, collection, dateObject ) {
          
          
          Severity: Major
          Found in js/date_picker/picker.date.js - About 2 hrs to fix

            Consider simplifying this complex logical expression.
            Open

                if ( !options || !options.nav ) if (
                    /* 1 */ ( !isFlippedBase && calendar.disabled( dateObject ) ) ||
                    /* 2 */ ( isFlippedBase && calendar.disabled( dateObject ) && ( hasEnabledWeekdays || hasEnabledBeforeTarget || hasEnabledAfterTarget ) ) ||
                    /* 3 */ ( !isFlippedBase && (dateObject.pick <= minLimitObject.pick || dateObject.pick >= maxLimitObject.pick) )
                ) {
            Severity: Critical
            Found in js/date_picker/picker.date.js - About 2 hrs to fix

              Function validate has 50 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              DatePicker.prototype.validate = function( type, dateObject, options ) {
              
                  var calendar = this,
              
                      // Keep a reference to the original date.
              Severity: Minor
              Found in js/date_picker/picker.date.js - About 2 hrs to fix

                Function item has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                                item: function( rowCounter ) {
                
                                    // If Monday is the first day and the month starts on Sunday, shift the date back a week.
                                    var shiftDateBy = settings.firstDay && calendar.create([ viewsetObject.year, viewsetObject.month, 1 ]).day === 0 ? -7 : 0
                
                
                Severity: Minor
                Found in js/date_picker/picker.date.js - About 1 hr to fix

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

                  DatePicker.defaults = (function( prefix ) {
                  
                      return {
                  
                          // The title label to use for the month nav buttons
                  Severity: Minor
                  Found in js/date_picker/picker.date.js - About 1 hr to fix

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

                            createYearLabel = function(override) {
                    
                                var focusedYear = viewsetObject.year,
                    
                                // If years selector is set to a literal "true", set it to 5. Otherwise
                    Severity: Minor
                    Found in js/date_picker/picker.date.js - About 1 hr to fix

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

                              createMonthLabel = function(override) {
                      
                                  var monthsCollection = settings.showMonthsShort ? settings.monthsShort : settings.monthsFull
                      
                                   // Materialize modified
                      Severity: Minor
                      Found in js/date_picker/picker.date.js - About 1 hr to fix

                        Function item has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                                                    item: function( targetDate ) {
                        
                                                        // Convert the time date from a relative date to a target date.
                                                        targetDate = calendar.create([ viewsetObject.year, viewsetObject.month, targetDate + ( settings.firstDay ? 1 : 0 ) ])
                        
                        
                        Severity: Minor
                        Found in js/date_picker/picker.date.js - About 1 hr to fix

                          Function deactivate has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          DatePicker.prototype.deactivate = function( type, datesToDisable ) {
                          
                              var calendar = this,
                                  disabledItems = calendar.item.disable.slice(0)
                          
                          
                          Severity: Minor
                          Found in js/date_picker/picker.date.js - About 1 hr to fix

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

                            DatePicker.prototype.navigate = function( type, value, options ) {
                            
                                var targetDateObject,
                                    targetYear,
                                    targetMonth,
                            Severity: Minor
                            Found in js/date_picker/picker.date.js - About 1 hr to fix

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

                              DatePicker.prototype.create = function( type, value, options ) {
                              
                                  var isInfiniteValue,
                                      calendar = this
                              
                              
                              Severity: Minor
                              Found in js/date_picker/picker.date.js - About 1 hr to fix

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

                                DatePicker.prototype.set = function( type, value, options ) {
                                
                                    var calendar = this,
                                        calendarItem = calendar.item
                                
                                
                                Severity: Minor
                                Found in js/date_picker/picker.date.js - About 1 hr to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                                          if ( !matchFound[3] ) matchFound.push( 'inverted' )
                                  Severity: Major
                                  Found in js/date_picker/picker.date.js - About 45 mins to fix

                                    Avoid deeply nested control flow statements.
                                    Open

                                                        else if ( _.isDate( unitToEnable ) ) {
                                                            matchFound = [ unitToEnable.getFullYear(), unitToEnable.getMonth(), unitToEnable.getDate(), 'inverted' ]
                                                        }
                                    Severity: Major
                                    Found in js/date_picker/picker.date.js - About 45 mins to fix

                                      Consider simplifying this complex logical expression.
                                      Open

                                              if ( isFlippedBase && !hasEnabledWeekdays && ( ( !hasEnabledAfterTarget && interval > 0 ) || ( !hasEnabledBeforeTarget && interval < 0 ) ) ) {
                                                  interval *= -1
                                              }
                                      Severity: Major
                                      Found in js/date_picker/picker.date.js - About 40 mins to fix

                                        Consider simplifying this complex logical expression.
                                        Open

                                                        if (
                                                            _.isInteger( unitToDisable ) ||
                                                            _.isDate( unitToDisable ) ||
                                                            $.isArray( unitToDisable ) ||
                                                            ( $.isPlainObject( unitToDisable ) && unitToDisable.from && unitToDisable.to )
                                        Severity: Major
                                        Found in js/date_picker/picker.date.js - About 40 mins to fix

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

                                                                  ( isOpen ? '' : 'disabled' ) + ' ' + _.ariaAttr({ controls: calendar.$node[0].id + '_table' }) + ' ' +
                                                                  'title="' + settings.labelYearSelect + '"'
                                          Severity: Major
                                          Found in js/date_picker/picker.date.js and 1 other location - About 1 hr to fix
                                          js/date_picker/picker.date.js on lines 1073..1075

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

                                          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

                                                              ( isOpen ? '' : 'disabled' ) + ' ' +
                                                              _.ariaAttr({ controls: calendar.$node[0].id + '_table' }) + ' ' +
                                                              'title="' + settings.labelMonthSelect + '"'
                                          Severity: Major
                                          Found in js/date_picker/picker.date.js and 1 other location - About 1 hr to fix
                                          js/date_picker/picker.date.js on lines 1148..1149

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

                                          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

                                                  _.node( 'button', settings.today, "btn-flat picker__today waves-effect",
                                                      'type=button data-pick=' + nowObject.pick +
                                                      ( isOpen && !calendar.disabled(nowObject) ? '' : ' disabled' ) + ' ' +
                                                      _.ariaAttr({ controls: calendar.$node[0].id }) ) +
                                                  _.node( 'button', settings.clear, "btn-flat picker__clear waves-effect",
                                          Severity: Major
                                          Found in js/date_picker/picker.date.js and 1 other location - About 1 hr to fix
                                          js/date_picker/picker.date.js on lines 1317..1328

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

                                          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

                                                  mmmm: function( string, dateObject ) {
                                          
                                                      var collection = this.settings.monthsFull
                                          
                                                      // If there's a string, get length of the relevant month from the full
                                          Severity: Major
                                          Found in js/date_picker/picker.date.js and 1 other location - About 1 hr to fix
                                          js/date_picker/picker.date.js on lines 691..698

                                          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 ( matchFound ) for ( index = 0; index < disabledItemsCount; index += 1 ) {
                                                          if ( calendar.isDateExact( disabledItems[index], unitToEnable ) ) {
                                                              disabledItems[index] = null
                                                              break
                                                          }
                                          Severity: Major
                                          Found in js/date_picker/picker.date.js and 1 other location - About 1 hr to fix
                                          js/date_picker/picker.date.js on lines 936..941

                                          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 ( isExactRange ) for ( index = 0; index < disabledItemsCount; index += 1 ) {
                                                          if ( calendar.isDateOverlap( disabledItems[index], unitToEnable ) ) {
                                                              disabledItems[index] = null
                                                              break
                                                          }
                                          Severity: Major
                                          Found in js/date_picker/picker.date.js and 1 other location - About 1 hr to fix
                                          js/date_picker/picker.date.js on lines 927..932

                                          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

                                                  mmm: function( string, dateObject ) {
                                          
                                                      var collection = this.settings.monthsShort
                                          
                                                      // If there's a string, get length of the relevant month from the short
                                          Severity: Major
                                          Found in js/date_picker/picker.date.js and 1 other location - About 1 hr to fix
                                          js/date_picker/picker.date.js on lines 699..706

                                          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

                                          There are no issues that match your filters.

                                          Category
                                          Status