wikimedia/mediawiki-core

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

Summary

Maintainability
F
3 days
Test Coverage

File CalendarWidget.js has 383 lines of code (exceeds 250 allowed). Consider refactoring.
Open

( function () {

    /**
     * A widget for selecting a date from a calendar.
     *
Severity: Minor
Found in resources/src/mediawiki.widgets.datetime/CalendarWidget.js - About 5 hrs to fix

    Function MwWidgetsDatetimeCalendarWidget has 111 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        mw.widgets.datetime.CalendarWidget = function MwWidgetsDatetimeCalendarWidget( config ) {
            var $colgroup, $headTR, headings, i;
    
            // Configuration initialization
            config = $.extend( {
    Severity: Major
    Found in resources/src/mediawiki.widgets.datetime/CalendarWidget.js - About 4 hrs to fix

      Function updateUI has 78 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          mw.widgets.datetime.CalendarWidget.prototype.updateUI = function () {
              var r, c, row, day, k, $cell,
                  width = this.minWidth,
                  nullCols = [],
                  focusedDate = this.getFocusedDate(),
      Severity: Major
      Found in resources/src/mediawiki.widgets.datetime/CalendarWidget.js - About 3 hrs to fix

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

            mw.widgets.datetime.CalendarWidget.prototype.adjustDate = function ( date, component, delta ) {
                var newDate,
                    data = this.calendarData;
        
                if ( !data ) {
        Severity: Minor
        Found in resources/src/mediawiki.widgets.datetime/CalendarWidget.js - About 1 hr to fix

          Function onKeyDown has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              mw.widgets.datetime.CalendarWidget.prototype.onKeyDown = function ( e ) {
                  var focusedDate = this.getFocusedDate();
          
                  if ( !this.isDisabled() ) {
                      switch ( e.which ) {
          Severity: Minor
          Found in resources/src/mediawiki.widgets.datetime/CalendarWidget.js - About 1 hr to fix

            Function setSelected has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                mw.widgets.datetime.CalendarWidget.prototype.setSelected = function ( dates ) {
                    var i, changed = false;
            
                    if ( dates instanceof Date ) {
                        dates = [ dates ];
            Severity: Minor
            Found in resources/src/mediawiki.widgets.datetime/CalendarWidget.js - About 1 hr to fix

              Avoid too many return statements within this function.
              Open

                                  return false;
              Severity: Major
              Found in resources/src/mediawiki.widgets.datetime/CalendarWidget.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                                    return false;
                Severity: Major
                Found in resources/src/mediawiki.widgets.datetime/CalendarWidget.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                                      return false;
                  Severity: Major
                  Found in resources/src/mediawiki.widgets.datetime/CalendarWidget.js - About 30 mins to fix

                    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 {
                    Severity: Major
                    Found in resources/src/mediawiki.widgets.datetime/CalendarWidget.js and 1 other location - About 3 hrs to fix
                    resources/src/mediawiki.widgets.datetime/DateTimeInputWidget.js on lines 119..125

                    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
                            }
                    Severity: Major
                    Found in resources/src/mediawiki.widgets.datetime/CalendarWidget.js and 1 other location - About 1 hr to fix
                    resources/src/mediawiki.widgets.datetime/DateTimeInputWidget.js on lines 96..100

                    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

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

                            if ( !this.$widget || OO.ui.contains( this.$element[ 0 ], document.activeElement, true ) ) {
                                this.$element.trigger( 'focus' );
                            }
                    Severity: Major
                    Found in resources/src/mediawiki.widgets.datetime/CalendarWidget.js and 2 other locations - About 1 hr to fix
                    resources/src/mediawiki.widgets.datetime/CalendarWidget.js on lines 473..475
                    resources/src/mediawiki.widgets.datetime/CalendarWidget.js on lines 488..490

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

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

                            if ( !this.$widget || OO.ui.contains( this.$element[ 0 ], document.activeElement, true ) ) {
                                this.$element.trigger( 'focus' );
                            }
                    Severity: Major
                    Found in resources/src/mediawiki.widgets.datetime/CalendarWidget.js and 2 other locations - About 1 hr to fix
                    resources/src/mediawiki.widgets.datetime/CalendarWidget.js on lines 461..463
                    resources/src/mediawiki.widgets.datetime/CalendarWidget.js on lines 473..475

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

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

                            if ( !this.$widget || OO.ui.contains( this.$element[ 0 ], document.activeElement, true ) ) {
                                this.$element.trigger( 'focus' );
                            }
                    Severity: Major
                    Found in resources/src/mediawiki.widgets.datetime/CalendarWidget.js and 2 other locations - About 1 hr to fix
                    resources/src/mediawiki.widgets.datetime/CalendarWidget.js on lines 461..463
                    resources/src/mediawiki.widgets.datetime/CalendarWidget.js on lines 488..490

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

                    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

                                    new OO.ui.ButtonWidget( {
                                        icon: 'previous',
                                        framed: false,
                                        classes: [ 'mw-widgets-datetime-calendarWidget-previous' ],
                                        tabIndex: -1
                    Severity: Major
                    Found in resources/src/mediawiki.widgets.datetime/CalendarWidget.js and 1 other location - About 1 hr to fix
                    resources/src/mediawiki.widgets.datetime/CalendarWidget.js on lines 123..128

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

                    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

                                    new OO.ui.ButtonWidget( {
                                        icon: 'next',
                                        framed: false,
                                        classes: [ 'mw-widgets-datetime-calendarWidget-next' ],
                                        tabIndex: -1
                    Severity: Major
                    Found in resources/src/mediawiki.widgets.datetime/CalendarWidget.js and 1 other location - About 1 hr to fix
                    resources/src/mediawiki.widgets.datetime/CalendarWidget.js on lines 117..122

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

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

                            OO.ui.mixin.TabIndexedElement.call( this, $.extend( {}, config, { $tabIndexed: this.$element } ) );
                    Severity: Major
                    Found in resources/src/mediawiki.widgets.datetime/CalendarWidget.js and 2 other locations - About 40 mins to fix
                    resources/src/mediawiki.widgets/mw.widgets.CategoryMultiselectWidget.js on lines 63..63
                    resources/src/mediawiki.widgets/mw.widgets.UsersMultiselectWidget.js on lines 50..50

                    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

                    There are no issues that match your filters.

                    Category
                    Status