wikimedia/mediawiki-core

View on GitHub
resources/src/mediawiki.widgets.datetime/DateTimeInputWidget.js

Summary

Maintainability
F
5 days
Test Coverage

File DateTimeInputWidget.js has 566 lines of code (exceeds 250 allowed). Consider refactoring.
Open

( function () {

    /**
     * @classdesc DateTimeInputWidgets can be used to input a date, a time, or
     * a date and time, in either UTC or the user's local timezone.
Severity: Major
Found in resources/src/mediawiki.widgets.datetime/DateTimeInputWidget.js - About 1 day to fix

    Function setupFields has 113 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        mw.widgets.datetime.DateTimeInputWidget.prototype.setupFields = function () {
            var i, $field, spec, placeholder, sz, maxlength,
                spanValFunc = function ( v ) {
                    if ( v === undefined ) {
                        return this.data( 'mw-widgets-datetime-dateTimeInputWidget-value' );
    Severity: Major
    Found in resources/src/mediawiki.widgets.datetime/DateTimeInputWidget.js - About 4 hrs to fix

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

          mw.widgets.datetime.DateTimeInputWidget = function MwWidgetsDatetimeDateTimeInputWidget( config ) {
              // Configuration initialization
              config = $.extend( {
                  type: 'datetime',
                  clearable: true,
      Severity: Major
      Found in resources/src/mediawiki.widgets.datetime/DateTimeInputWidget.js - About 4 hrs to fix

        Function updateFieldsFromValue has 46 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            mw.widgets.datetime.DateTimeInputWidget.prototype.updateFieldsFromValue = function () {
                var i, $field, spec, intercalary, sz,
                    date = this.getValueAsDate();
        
                if ( date === null ) {
        Severity: Minor
        Found in resources/src/mediawiki.widgets.datetime/DateTimeInputWidget.js - About 1 hr to fix

          Consider simplifying this complex logical expression.
          Open

                      if ( date.getTime() < -62167219200000 || date.getTime() > 253402300799999 ||
                          date.getUTCFullYear() !== +m[ 1 ] ||
                          date.getUTCMonth() + 1 !== +m[ 2 ] ||
                          date.getUTCDate() !== +m[ 3 ] ||
                          date.getUTCHours() !== +m[ 4 ] ||
          Severity: Critical
          Found in resources/src/mediawiki.widgets.datetime/DateTimeInputWidget.js - About 1 hr to fix

            Function updateValueFromFields has 40 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                mw.widgets.datetime.DateTimeInputWidget.prototype.updateValueFromFields = function () {
                    var i, v, $field, spec, curDate, newDate,
                        components = {},
                        anyInvalid = false,
                        anyEmpty = false,
            Severity: Minor
            Found in resources/src/mediawiki.widgets.datetime/DateTimeInputWidget.js - About 1 hr to fix

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

                  mw.widgets.datetime.DateTimeInputWidget.prototype.cleanUpValue = function ( value ) {
                      var date, pad;
              
                      if ( value === '' ) {
                          return '';
              Severity: Minor
              Found in resources/src/mediawiki.widgets.datetime/DateTimeInputWidget.js - About 1 hr to fix

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

                    mw.widgets.datetime.DateTimeInputWidget.prototype.parseDateValue = function ( value ) {
                        var date, m;
                
                        value = String( value );
                        switch ( this.type ) {
                Severity: Minor
                Found in resources/src/mediawiki.widgets.datetime/DateTimeInputWidget.js - About 1 hr to fix

                  Function onFieldWheel has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      mw.widgets.datetime.DateTimeInputWidget.prototype.onFieldWheel = function ( $field, e ) {
                          var delta = 0,
                              spec = $field.data( 'mw-widgets-datetime-dateTimeInputWidget-fieldSpec' );
                  
                          if ( this.isDisabled() || !this.getFocusedField().length ) {
                  Severity: Minor
                  Found in resources/src/mediawiki.widgets.datetime/DateTimeInputWidget.js - About 1 hr to fix

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

                        mw.widgets.datetime.DateTimeInputWidget.prototype.onFieldKeyDown = function ( $field, e ) {
                            var spec = $field.data( 'mw-widgets-datetime-dateTimeInputWidget-fieldSpec' );
                    
                            if ( !this.isDisabled() ) {
                                switch ( e.which ) {
                    Severity: Minor
                    Found in resources/src/mediawiki.widgets.datetime/DateTimeInputWidget.js - About 1 hr to fix

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

                              if ( !this.sawWheelEvent ) {
                                  if ( e.originalEvent.wheelDeltaX ) {
                                      delta = -e.originalEvent.wheelDeltaX;
                                  } else if ( e.originalEvent.wheelDeltaY ) {
                                      delta = e.originalEvent.wheelDeltaY;
                      resources/lib/ooui/oojs-ui-core.js on lines 13997..14007

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

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

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

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

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

                      Refactorings

                      Further Reading

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

                              if ( config.formatter instanceof mw.widgets.datetime.DateTimeFormatter ) {
                                  this.formatter = config.formatter;
                              } else if ( $.isPlainObject( config.formatter ) ) {
                                  this.formatter = new mw.widgets.datetime.ProlepticGregorianDateTimeFormatter( config.formatter );
                              } else {
                      resources/src/mediawiki.widgets.datetime/CalendarWidget.js on lines 69..75

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

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

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

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

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

                      Refactorings

                      Further Reading

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

                              if ( config.max instanceof Date && config.max.getTime() <= 253402300799999 ) {
                                  this.max = config.max;
                              } else {
                                  this.max = new Date( 253402300799999 ); // 9999-12-31T12:59:59.999Z
                              }
                      resources/src/mediawiki.widgets.datetime/CalendarWidget.js on lines 55..59

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

                      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 ( e.originalEvent.deltaY ) {
                                  delta = -e.originalEvent.deltaY;
                              } else if ( e.originalEvent.deltaX ) {
                                  delta = e.originalEvent.deltaX;
                              }
                      resources/lib/ooui/oojs-ui-core.js on lines 13990..13994

                      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 5 locations. Consider refactoring.
                      Open

                          mw.widgets.datetime.DateTimeInputWidget.prototype.onFieldChange = function () {
                              this.updateValueFromFields();
                          };
                      resources/lib/ooui/oojs-ui-core.js on lines 2143..2145
                      resources/lib/ooui/oojs-ui-core.js on lines 2231..2233
                      resources/lib/ooui/oojs-ui-widgets.js on lines 925..927
                      resources/src/mediawiki.widgets.datetime/DateTimeInputWidget.js on lines 590..592

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

                      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 5 locations. Consider refactoring.
                      Open

                          mw.widgets.datetime.DateTimeInputWidget.prototype.onHandleClick = function () {
                              this.focus();
                          };
                      resources/lib/ooui/oojs-ui-core.js on lines 2143..2145
                      resources/lib/ooui/oojs-ui-core.js on lines 2231..2233
                      resources/lib/ooui/oojs-ui-widgets.js on lines 925..927
                      resources/src/mediawiki.widgets.datetime/DateTimeInputWidget.js on lines 714..716

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

                      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