wikimedia/mediawiki-core

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

Summary

Maintainability
F
4 days
Test Coverage

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

/*!
 * MediaWiki Widgets – CalendarWidget class.
 *
 * @copyright 2011-2015 MediaWiki Widgets Team and others; see AUTHORS.txt
 * @license The MIT License (MIT); see LICENSE.txt
Severity: Minor
Found in resources/src/mediawiki.widgets/mw.widgets.CalendarWidget.js - About 5 hrs to fix

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

        mw.widgets.CalendarWidget.prototype.updateUI = function ( fade ) {
            var $bodyWrapper = this.$bodyWrapper;
    
            if ( this.lazyInitOnToggle ) {
                // We're being called from the constructor and not being shown yet, do nothing
    Severity: Major
    Found in resources/src/mediawiki.widgets/mw.widgets.CalendarWidget.js - About 5 hrs to fix

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

          mw.widgets.CalendarWidget.prototype.onKeyDown = function ( e ) {
              var
                  dir = OO.ui.Element.static.getDir( this.$element ),
                  nextDirectionKey = dir === 'ltr' ? OO.ui.Keys.RIGHT : OO.ui.Keys.LEFT,
                  prevDirectionKey = dir === 'ltr' ? OO.ui.Keys.LEFT : OO.ui.Keys.RIGHT,
      Severity: Minor
      Found in resources/src/mediawiki.widgets/mw.widgets.CalendarWidget.js - About 1 hr to fix

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

            mw.widgets.CalendarWidget.prototype.buildHeaderButtons = function () {
                this.labelButton = new OO.ui.ButtonWidget( {
                    tabIndex: -1,
                    label: '',
                    framed: false,
        Severity: Minor
        Found in resources/src/mediawiki.widgets/mw.widgets.CalendarWidget.js - About 1 hr to fix

          Function toggle has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              mw.widgets.CalendarWidget.prototype.toggle = function ( visible ) {
                  visible = visible === undefined ? !this.visible : !!visible;
                  var change = visible !== this.isVisible();
                  if ( this.lazyInitOnToggle && visible ) {
                      this.lazyInitOnToggle = false;
          Severity: Minor
          Found in resources/src/mediawiki.widgets/mw.widgets.CalendarWidget.js - About 1 hr to fix

            Function MWWCalendarWidget has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                mw.widgets.CalendarWidget = function MWWCalendarWidget( config ) {
                    // Config initialization
                    config = config || {};
            
                    // Parent constructor
            Severity: Minor
            Found in resources/src/mediawiki.widgets/mw.widgets.CalendarWidget.js - About 1 hr to fix

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

                          if (
                              ( this.isClippedVertically() || this.isFloatableOutOfView() ) &&
                              this.originalVerticalPosition !== 'center'
                          ) {
                              // If opening the menu in one direction causes it to be clipped, flip it
              Severity: Major
              Found in resources/src/mediawiki.widgets/mw.widgets.CalendarWidget.js and 1 other location - About 4 hrs to fix
              resources/lib/ooui/oojs-ui-core.js on lines 8823..8840

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

              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

                  mw.widgets.CalendarWidget.prototype.onPrevButtonClick = function () {
                      switch ( this.displayLayer ) {
                          case 'month':
                              this.moment.subtract( 1, 'month' );
                              break;
              Severity: Major
              Found in resources/src/mediawiki.widgets/mw.widgets.CalendarWidget.js and 1 other location - About 3 hrs to fix
              resources/src/mediawiki.widgets/mw.widgets.CalendarWidget.js on lines 438..451

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

              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

                  mw.widgets.CalendarWidget.prototype.onNextButtonClick = function () {
                      switch ( this.displayLayer ) {
                          case 'month':
                              this.moment.add( 1, 'month' );
                              break;
              Severity: Major
              Found in resources/src/mediawiki.widgets/mw.widgets.CalendarWidget.js and 1 other location - About 3 hrs to fix
              resources/src/mediawiki.widgets/mw.widgets.CalendarWidget.js on lines 418..431

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

              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

                              for ( var y = 0; y < 20; y++ ) {
                                  items.push(
                                      $( '<div>' )
                                          .addClass( 'mw-widget-calendarWidget-item mw-widget-calendarWidget-year' )
                                          .toggleClass( 'mw-widget-calendarWidget-item-selected', currentYear.isSame( selected, 'year' ) )
              Severity: Major
              Found in resources/src/mediawiki.widgets/mw.widgets.CalendarWidget.js and 1 other location - About 2 hrs to fix
              resources/src/mediawiki.widgets/mw.widgets.CalendarWidget.js on lines 252..261

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

              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

                              for ( var m = 0; m < 12; m++ ) {
                                  items.push(
                                      $( '<div>' )
                                          .addClass( 'mw-widget-calendarWidget-item mw-widget-calendarWidget-month' )
                                          .toggleClass( 'mw-widget-calendarWidget-item-selected', currentMonth.isSame( selected, 'month' ) )
              Severity: Major
              Found in resources/src/mediawiki.widgets/mw.widgets.CalendarWidget.js and 1 other location - About 2 hrs to fix
              resources/src/mediawiki.widgets/mw.widgets.CalendarWidget.js on lines 289..298

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

              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

                  mw.widgets.CalendarWidget.static.flippedPositions = {
                      below: 'above',
                      above: 'below',
                      top: 'bottom',
                      bottom: 'top'
              Severity: Minor
              Found in resources/src/mediawiki.widgets/mw.widgets.CalendarWidget.js and 1 other location - About 50 mins to fix
              resources/lib/ooui/oojs-ui-core.js on lines 4617..4622

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

              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

                      this.prevButton = new OO.ui.ButtonWidget( {
                          tabIndex: -1,
                          framed: false,
                          icon: 'previous',
                          classes: [ 'mw-widget-calendarWidget-prevButton' ]
              Severity: Minor
              Found in resources/src/mediawiki.widgets/mw.widgets.CalendarWidget.js and 1 other location - About 40 mins to fix
              resources/src/mediawiki.widgets/mw.widgets.CalendarWidget.js on lines 375..380

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

              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

                      this.nextButton = new OO.ui.ButtonWidget( {
                          tabIndex: -1,
                          framed: false,
                          icon: 'next',
                          classes: [ 'mw-widget-calendarWidget-nextButton' ]
              Severity: Minor
              Found in resources/src/mediawiki.widgets/mw.widgets.CalendarWidget.js and 1 other location - About 40 mins to fix
              resources/src/mediawiki.widgets/mw.widgets.CalendarWidget.js on lines 369..374

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

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

                              case OO.ui.Keys.PAGEUP:
                                  this.moment.subtract( 1, this.precision === 'month' ? 'year' : 'month' );
                                  break;
              Severity: Major
              Found in resources/src/mediawiki.widgets/mw.widgets.CalendarWidget.js and 3 other locations - About 35 mins to fix
              resources/src/mediawiki.widgets/mw.widgets.CalendarWidget.js on lines 599..601
              resources/src/mediawiki.widgets/mw.widgets.CalendarWidget.js on lines 602..604
              resources/src/mediawiki.widgets/mw.widgets.CalendarWidget.js on lines 608..610

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

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

                              case OO.ui.Keys.PAGEDOWN:
                                  this.moment.add( 1, this.precision === 'month' ? 'year' : 'month' );
                                  break;
              Severity: Major
              Found in resources/src/mediawiki.widgets/mw.widgets.CalendarWidget.js and 3 other locations - About 35 mins to fix
              resources/src/mediawiki.widgets/mw.widgets.CalendarWidget.js on lines 599..601
              resources/src/mediawiki.widgets/mw.widgets.CalendarWidget.js on lines 602..604
              resources/src/mediawiki.widgets/mw.widgets.CalendarWidget.js on lines 605..607

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

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

                              case OO.ui.Keys.DOWN:
                                  this.moment.add( 1, this.precision === 'month' ? 'month' : 'week' );
                                  break;
              Severity: Major
              Found in resources/src/mediawiki.widgets/mw.widgets.CalendarWidget.js and 3 other locations - About 35 mins to fix
              resources/src/mediawiki.widgets/mw.widgets.CalendarWidget.js on lines 599..601
              resources/src/mediawiki.widgets/mw.widgets.CalendarWidget.js on lines 605..607
              resources/src/mediawiki.widgets/mw.widgets.CalendarWidget.js on lines 608..610

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

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

                              case OO.ui.Keys.UP:
                                  this.moment.subtract( 1, this.precision === 'month' ? 'month' : 'week' );
                                  break;
              Severity: Major
              Found in resources/src/mediawiki.widgets/mw.widgets.CalendarWidget.js and 3 other locations - About 35 mins to fix
              resources/src/mediawiki.widgets/mw.widgets.CalendarWidget.js on lines 602..604
              resources/src/mediawiki.widgets/mw.widgets.CalendarWidget.js on lines 605..607
              resources/src/mediawiki.widgets/mw.widgets.CalendarWidget.js on lines 608..610

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

              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